Jump to content

"Current song is playing: Some Song Name"


Anders Moen

Recommended Posts

Hello!A friend of mine has designed a site, and he said they want a "Current song is playing"-thing, and he gave me a link to a site that had something like this (nordicradio.no) and I looked into their source and I found out they're using AJAX (http://nordicradio.no/07/js/ajax.js) but how does the file that's being included in the JS file look like (http://www.nordicradio.no/07/inc/currentsong.php)?Thanks in advance.If you don't understand what I mean, tell me :)

Link to comment
Share on other sites

First, a little clarification. If his site says "Current Song Playing" is that because he has music playing when you visit his website or is he trying to tell you the song that is currently playing on his/her favorite radio station?Assuming it is the former, is the music being streamed, is it compiled in a flash file (swf), is it directly being played via the <object> tag? Is it the same song each page, is a a song per page, is it random, is it in a framed window so that it doesn't reload and start from the same place on every page load?

Link to comment
Share on other sites

Nope, it's not music on the site itself. It's a radiostation and it says what their radiostation is currently playing (it's a radio company)No, it's Flash. At least there's no JS or object-code there I think. No, it's not in a frame or anything, it's just there...lol

Link to comment
Share on other sites

The music player, in this case Flash, would need to write out an XML file every time it changes songs to say what it is currently playing, including possibly the start time and length to set up timing for when the Javascript needs to go out and check the file again. If you have the player recording what it is playing in the form of an XML file, then it's trivial to get Javascript to read that file and display it on the page.

Link to comment
Share on other sites

Ok, so you meant

No, it's Flash.
No, it's not Flash.Content does not just show up on a webpage, there needs to be a reference to it. You can't display an image without an <img> tag, and you can't play music without a music player of some sort, even if the player is on the client. Whatever is playing the music needs to write out what it is playing.
Link to comment
Share on other sites

technically speaking, you don' t need anything fancy to display this information. The tricky/fancy part is on the operations side - how and where is the radio station able to write something about what is currently being played. The the old days, for example, a DJ would have had to manually type something in to something like a content management system when each song was played. For obvious reason it is clear to see why you never had that information until playback became digital.So, what are the capabilities of the digital play back interface the station uses. Naturally it runs on a computer which immediately make ANY information available to anyone given there is a network connection somewhere and that the (here is the big thing) software system they use can be programed to export the information in real time.Having said all that, your options are driven by the software's capabilities. I imagine there would be two commons situations:a.) the software could write a physical file to the server, like log, that would some how indicate what is being played not and maybe even what has been played.b.) the software would do the same thing as [a] but all in a database instead of a physical file.That leaves you with a few creative solutions. If its a file, either define it to be saved on a web accessible location and use javascript, <iframe>, or a server side include to pull the content into a web page. If the website is not hosted locally, then a script would have to be created to FTP the file up to the server periodically. If its a database run application, then you either open the database to be called by the website (again working around the internal/external hosting issue by making it accessible externally) or write something locally that writes a file and then does solution [a].Of course, ideally, the software might even be able to upload something all by itself - like webcam software can.In any respect, you solution starts with the radio station software capabilities.[edit] The ajax is used to call that php file. That php file is either parsing something - xml, txt, or query a database. Where and how that data is defined is what I refer to in my post.By the way, they are not using the concept of AJAX quite that well. They should only have to include the PHP file in that location. The PHP file should be programmed along with other technologies (like AJAX) and only be refreshed when the song changes - but that might be a little more complicated than its worth to most - so this does work - just as annoying as a "real time online chat" program that is built on <meta> refresh tags.:)

Link to comment
Share on other sites

Ok, sorry about the delay anyone.Anyways, how can I do this? Should I i.e type in all songs that's gonna be played today and when they start & when they end, and then use AJAX to update it each time the clock is enough for the next song to start?And I don't know any AJAX, so someone's gotta help me with that...

Link to comment
Share on other sites

Yeah, I was thinking of that, but how would I update the thing?I mean, I was thinking of making the people who works there just fill in the whole playlist for i.e a week, when it starts/stops (clocktime I mean), but how would I do it with updating the "Current song is playing: " without updating the whole site?Help anyone?

Link to comment
Share on other sites

You could have the times in the file, your software would have to parse the file and figure out which song should be playing now. You can do that with XML. But it would be much better if the XML list was exported automatically, by the software actually playing the song, instead of having people who work there fill something out. It may work to have them fill out the list each day, but not only would it take a while to make that list, they might decide to play something not on the list, or they might not start the songs exactly on time. That would mean that as the day goes on each song is going to be more and more delayed, so at the end of the day the list will be totally off. For an entire week it would be even worse. The best thing to do is have the software export the playlist as it plays, not have the people fill it out.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...