Continuously streaming random audio from database

后端 未结 1 384
野趣味
野趣味 2021-01-27 00:45

I\'m planning out a project for a very simple audio streamer that would take a mysql database list of songs hosted on my local server, and then randomly stream a song from the l

1条回答
  •  悲哀的现实
    2021-01-27 01:41

    HTML5 audio tag has an event "onended" which is run when the media reaches its end, but since you wish to keep playing you should use the "onwaiting" event, which also fires when the media reaches its end, but keeps itself ready to accept a new track/data.

    You can then use the XMLHttpRequest object to query for the next track to play, eg.

    
    
    

    The xml would be in the form of:

     
     
        next_song.ogg
    
    

    0 讨论(0)
提交回复
热议问题