Jump to content

HTML5 Audio Cycle With PHP


Twango

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!

Link to comment
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.

Link to comment
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>
Link to comment
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.

Link to comment
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.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...