[Playlist] XSPF Start/End time Zeitgeist

Nathan Freitas nathan at openvision.tv
Fri Jun 2 00:53:35 UTC 2006


Greetings, all. I just joined the list, but have been thinking about 
playlists for awhile now. I'm the founder of ONTV and the developer of 
ION, an open-source  media aggregator/player desktop app with 
RSS/XSPF/Torrents, etc (check it out at: http://iondb.com)

Anyhow, Lucas asked me to re-post an email I just sent him here to 
contribute to the discussion on XSPF playlist start and end times. It's 
something I've been considering. Excited to see what everyone here has 
to say...

***************
Lucas,

I saw your blog post about people wanting the ability to specify start 
and end times in XSPF playlists. This is something I've been pondering 
and trying to get done for Kent Bye and his Echo Chamber Project, and 
also for my own projects.

Here's what I've got so far. Let me know if someone else is on this 
path, and/or what you think of this approach. Kent, also, this is for 
you, so let me know if this fits your needs.

First, I've added some "<meta>" tags to my XSPF document. These are 
values in seconds.

<track>
<meta rel="startTime">10</meta>
<meta rel="endTime">20</meta>
<location>http://audio.sxsw.com/2006/mp3/Tapes_N_Tapes-Cowbell.mp3</location> 

<image>http://g-images.amazon.com/images/G/01/ciu/91/b9/1035224128a0d8535456a010._AA229_.L.jpg</image> 

<annotation>Tapes N Tapes</annotation>
<info>http://2006.sxsw.com/music/showcases/band/4247.html</info>
</track>

I think this is a valid way of adding metadata into XSPF. Is there a 
better way? As an attribute perhaps?

So, then in the MusicPlayer code, you add something like this to the 
XSPF parsing:

if((track_child.nodeName=="meta")&&(track_child.attributes.rel=="startTime")){ 

        track_obj.startTime = track_child.firstChild.nodeValue;
}
                        
if((track_child.nodeName=="meta")&&(track_child.attributes.rel=="endTime")){ 

         track_obj.endTime = track_child.firstChild.nodeValue;
}

The next import thing is that you load the sound as an "event" sound 
instead of an MP3 stream. This means Flash will load the entire file 
before playback. The variable "false" indicates to Flash not to stream 
this:

mysound.loadSound(playlist_array[track_index].location,false);

The downside to this is that it takes a bit for a long mp3 to fully 
load. There is another way using the "getBytesLoaded()" call that you 
could determine if enough bytes have been buffered for playback or not.

Then for playback, you start playback at the indicated "startTime":

seekTrack(playlist_array[track_index].startTime)


The final bit is to monitor playback (checking "mysound.position" value 
in Flash), and then stop and go to the next track when it reaches the 
"endTime".

I am stuck on this last piece unfortunately. I figured I would give a 
brain dump to you and Kent so that we might collectively figure it out, 
and/or you could pass this information on to someone else who might be 
able to lend a hand.

Best,
   Nathan




-- 
my app)) get ION at http://iondb.com
biz & blog)) http://openvision.tv/blog
feed)) http://feeds.feedburner.com/PeopleWithIdeas
skypeme)) nathanialfreitas





More information about the Playlist mailing list