javascript - jQuery Load XML and Refresh Based on XML Variable -
i building player online radio station. stream providing xml file displays current song information. xml file hosted on stream server not server website running on.
here sample of whats in xml. lets pretend comes http://randomserver/station.xml
<playlist> <stationcallsign>kcxr</stationcallsign> <programtype>pgm</programtype> <mediatype>aud</mediatype> <title>break free</title> <artist>decyfer down</artist> <album>end of grey</album> <cover> http://cdnrf.securenetsystems.net/file_radio/album_art/o/1/5/51oo0rbqatl.jpg </cover> <duration>199</duration> <campaignid/> <fileid/> <programstartts>30 sep 2015 17:48:22</programstartts> <adblockpos>1</adblockpos> </playlist> i need pull data display on webpage , refresh based on how many seconds in "duration" field. refresh of when song changes.
here html output need.
<div id="playerdiv" class="player-div" style="display: block;"> <div id="album-art"> <img id="now-playing-album-art" src="http://cdnrf.securenetsystems.net/file_radio/album_art/e/1/5/51eeztxmyul.jpg" class="player-div-img cp" width="250" height="250" title=""> </div> <div id="now-playing" class="now-playing ts"> <span id="now-playing-title" class="menuheader f15em">lights out</span> - <span id="now-playing-artist">silverline</span> <div id="now-playing-album">lights out</div> </div> [playercode] </div> i hoping use mobile jquery functions on mobile devices.
it sounds might need little more research ajax requests.
settimeout(function() { jquery.ajax('http://randomserver/station.xml', { success: function() { //parse xml , update document }, error: function() { //handle error } } }, songduration); with jquery can download xml file , update song
in above code settimeout(callback,timeinmillis) allows set time in milliseconds callback occur. callback makes xmlhttprequest url of choice , updates page if successful in getting page.
you can use default javascript xml parser parse response server.
resources used:
Comments
Post a Comment