A while ago I wrote a blog entry that discussed how to add a playlist to a CFMEDIAPLAYER tag. The idea was simple. Given a query - turn it into a grid control that could then drive the content for the media player control. Misty posted a comment about M3U support so I thought I'd write up a quick example.
For those who don't know, a M3U file (Wikipedia Entry) is simply a text file that represents a playlist. I've normally seen this used for MP3 collections, but it can really be used for any type of media.
Since it is just a text file, it would be trivial to update the old example to take its data from a file instead. First, let's build a simple M3U file.
I'm using the same URLs from before. Note the use of #-prefixed lines as comments. I need to ensure we ignore those lines when parsing in the data. Let's look at that code:
I begin by reading in the file and then splitting it into an array. Using the new ColdFusion 10 arrayFilter function, I can quickly remove the comment lines. I create a new query object and then loop through each line and add it to the data. My titles are just numerical but could be specified in some other manner. Also note that I could have skipped the filter entirely and just used arrayEach. That would have made the code a bit slimmer.
That's it. The end result is a query object with URLs based on the M3U file. I've pasted the entire template before.