Jump to content
Sign in to follow this  
Twango

HTML5 Audio Cycle With PHP

Recommended Posts

Ok, so I REALLY want to make an internet radio thing. I want there to be like a MySQL table with the file names for each audio file, and PHP echos the SRC of an HTML5 Audio Tag to that file. I have NO idea how to do that.The only thing I could think, would be like a table like follows:id: SRC: length:1 audio.mp3 30 And then another table that has the current song, like follows: currentsong: SRC: timestart: length:1 audio.mp3 14:25:20 30 And then a Cron Job that runs a file like CheckUpdate.php, that basically checks to see if the time is equal to the length + timestart, and if it is, set the currentsong to the next?For the Cycling on the webpage, I know I could use Dynamic Ajax, but would this work for the cycling? Thanks.If you have any other ideas, please tell me!

Share this post


Link to post
Share on other sites

Since you'd need to update the src on the page, you'd also have to use AJAX for that part as well. Check at some reasonable interval if the track has ended, and shortly before it ends, initiate a request where by PHP will give you the src for the next track, and perform the change once the track is actually over.

Share this post


Link to post
Share on other sites

@boen_robot, I know that, but I'm saying how do I get it so every listener's on the same track?

Share this post


Link to post
Share on other sites

I also can't figure out how to change the source of HTML5 audio with JS. Help?

Share this post


Link to post
Share on other sites

<div>

I know that, but I'm saying how do I get it so every listener's on the same track?
</div><div>you can store the track information in file and fetch it from there when listener wants to hear it.<br /><br /><div>
<div> </div><div>I also can't figure out how to change the source of HTML5 audio with JS. Help?</div><p>
</p><p>https://developer.mozilla.org/en/Using_audio_and_video_in_Firefox</p></div></div><div> </div><div> </div>

Share this post


Link to post
Share on other sites

@Birbal that doesn't help me at all. I know what I need to do, but don't know how to go about doing it.

Share this post


Link to post
Share on other sites

which part you need help? can you be specific? for the audio handling the link i gave has good information and elaboration of what you need.

Share this post


Link to post
Share on other sites
@boen_robot, I know that, but I'm saying how do I get it so every listener's on the same track?
Initially, you check the current track with PHP, and output that as the "src". This alone ensures people are listening to the same track.To make sure that people are not only listening to the same track, but the same point of it too, you could include fragment identifiers in the URL (see the page birbal linked; the part about "playback range").From then on, via periodic AJAX requests, JavaScript asks PHP for the current track, and updates the src accordingly.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...