Go
Not registered? Sign up!

Playlist start time

Google Translate
49 posts | return to the Setup Problems forum | get the rss feed for this thread

Mar. 25, 2009Domenico

how can configure the playlist in such a way that the video will be implemented on a fixed schedule?

Mar. 25, 2009lefTy

Can you provide some more details?

Mar. 26, 2009Domenico

ok excuse me for english.
I want the videos in the playlist are played at specific times.
example
video1.flv hours 10:00 a.m.
video2.flv hours 13:00
etc..
when I open the web pages the jw player must "read" the current time and play as scheduled in the playlist

thanks

Mar. 26, 2009lefTy

You can:

1) enter the time in a meta element of the playlist:<meta rel='starttime'>10</meta>

2) when the player loads, it will get the playlist, look for the first starttime that is less than the current time and play that track.

Assuming that if the time is between 11 and 13 you want to play the same track, etc. Of course the details can be adjusted to match your exact requirements.

So as an example:
 Time   Track
  0-2     0
  2-5     1
  5-7     2
  7-11    3
 11-13    4
 13-17    6
 17-19    7
 19-21    8
 21-23    9
 23-24   10

Mar. 26, 2009domenico

i have no a rmtp server,
i,m use php streaming

can work the same

Mar. 27, 2009domenico

this is a example of my playlist, but not working.
where wrong ?

<code>
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>

<track>

<creator>Retro Bus</creator>
<title>retrobus</title>
<location>retrobus.flv</location>
<meta rel='starttime'>12</meta>


</track>

<track>

<creator>LipoPropulsion</creator>
<title>liposmall</title>
<location>liposmall.flv</location>
<meta rel='starttime'>13</meta>
</track>


</trackList>
</playlist>
</code>

Mar. 27, 2009lefTy

You also need some JavaScript to parse the playlist and find the correct track by starttime.

I don't have time to do it now, but in afew days, I'll assemble the JS code.

Mar. 27, 2009domenico

ok
thanks you

Mar. 28, 2009lefTy


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

  <head>

    <title>Simple Play On Schedule - JWMP v4.4.x - swfobject v2.2</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        'file':                                  'playlist_domenico.xml',
        'playlist':                              'right',
        'playlistsize':                          '400',
        'repeat':                                'none',
        'shuffle':                               'false',
        'stretching':                            'none',
        'skin':                                  'bright',
        'frontcolor':                            '86C29D',  // text & icons                  (green)
        'backcolor':                             '003367',  // playlist background           (blue)
        'lightcolor':                            'C286BA',  // selected text/track highlight (red)
        'screencolor':                           '000000',  // screen background             (white)
        'id':                                    'playerId1',
        'autostart':                             'false'
      };

      var params =
      {
        'allowfullscreen':                       'true',
        'allowscriptaccess':                     'always',
        'bgcolor':                               '#000000'
      };

      var attributes =
      {
        'name':                                  'playerId1',
        'id':                                    'playerId1'
      };
      
      swfobject.embedSWF('player-4.4.189.swf', 'player1', '900', '327', '9.0.124', false, flashvars, params, attributes);
    </script>

    <script type="text/javascript">
      var player    =  null;
      var playlist  =  null;


      function playerReady(obj)
      {
        player = gid(obj.id);
        startTime();
      };


      function startTime()
      {
        playlist = player.getPlaylist();

        if((playlist !== null) && (playlist !== undefined))
        {
          var currentTime = new Date();
          var hours = currentTime.getHours();

          for(var j in playlist)
          {
//alert(hours + ' : ' + playlist[j].starttime);
            if(playlist[j].starttime > hours)
            {
              player.sendEvent('ITEM', (j - 1));
              gid('start').innerHTML = 'START TIME: ' + playlist[j - 1].starttime + '   CURRENT TIME: ' + hours + '   ITEM: ' + (j -1);
              break;
            }
          }
        }
        else
        {
          setTimeout("startTime();", 50);
        }
      };


      function gid(name)
      {
        return document.getElementById(name);
      };
    </script>

  </head>

  <body>

    <div id="playercontainer1" class="playercontainer"><a id="player1" class="player1" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>
    <div id="start" style="font-family:arial;">START TIME:     CURRENT TIME:     ITEM:</div>

  </body>

</html>



<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
  <trackList>
    <track>
      <creator>Retro Bus</creator>
      <title>retrobus</title>
      <location>/Movies/video1.flv</location>
      <meta rel='starttime'>0</meta>
    </track>
    <track>
      <creator>LipoPropulsion</creator>
      <title>liposmall</title>
      <location>/Movies/video2.flv</location>
      <meta rel='starttime'>4</meta> 
    </track>
    <track>
      <creator>Retro Bus</creator>
      <title>retrobus</title>
      <location>/Movies/video3.flv</location>
      <meta rel='starttime'>8</meta>
    </track>
    <track>
      <creator>LipoPropulsion</creator>
      <title>liposmall</title>
      <location>/Movies/video4.flv</location>
      <meta rel='starttime'>12</meta> 
    </track>
    <track>
      <creator>Retro Bus</creator>
      <title>retrobus</title>
      <location>/Movies/video5.flv</location>
      <meta rel='starttime'>16</meta>
    </track>
    <track>
      <creator>LipoPropulsion</creator>
      <title>liposmall</title>
      <location>/Movies/video.flv</location>
      <meta rel='starttime'>20</meta> 
    </track>
    <track>
      <creator>LipoPropulsion</creator>
      <title>liposmall</title>
      <location>/Movies/video.flv</location>
      <meta rel='starttime'>24</meta> 
    </track>
  </trackList>
</playlist>

Mar. 28, 2009Domenico

i have tested your script, but not working.
i
this is my link

http://eurotechonline.altervista.org/prova

Mar. 28, 2009lefTy

Works for me: http://willswonders.myip.org:8082/Simple_PlayOnSchedule.html

Mar. 29, 2009Domenico

ok, it works.
you could do all this with the playlist on mysql db?

Mar. 29, 2009lefTy

It doesn't matter where the playlist comes from, as long as it has the starttime meta element. So your playlist generator has to include some method of determining the starttime and including the meta element in the playlist.

Mar. 29, 2009domenico

ok.
the script sets the video to start, implement, and then not go ahead with the playlist but stops.
where is the problem?

Apr. 20, 2009satamusic @gmail

could this be implemented, instead of a daily schedule, by specific day and time on a single month?

my situation is the following: i have several feeds that show live webcams, but i only want the live content from 9pm to 3am, only on weekends, and during the day (or non-weekends) i want the player to show another feed, that shows pre-recorded content.

would it be easier with the livestream plugin?

Apr. 21, 2009sigord40

Any help with my problem please??

I want to create an xml mp3 playlist that plays 20 tracks. I want to start the playlist off at 18:00 GMT.

I then want to make it so that if another user logs on at 18:15 GMT then the playlist starts playing for them from 15 minutes in, which may be half way through the third track for example.

Can someone tell me if this is possible? I have tried to tweak the code posted by 'lefTy' on this thread, with no luck.

HELP!!

Apr. 21, 2009Sebastian

Hi,

how does the correct format looks like if you want to play a video at 3:34 pm?

I tried a lot, but nothing works.
- 3:34
- 3.34
- 15:34
- 15-34
...

Whats the right solution?

Greetz

Apr. 21, 2009brokenString

The code posted above only checks the hours.

To check hours and minutes, you would have to enhance the code; something like this:
      function startTime()
      {
        playlist = player.getPlaylist();

        if((playlist !== null) && (playlist !== undefined))
        {
          var currentTime = new Date();
          var hoursminutes = currentTime.getHours() + '.' + currentTime.getMinutes();

          for(var j in playlist)
          {
//alert(hoursminutes + ' : ' + playlist[j].starttime);
            if(playlist[j].starttime > hoursminutes)
            {
              player.sendEvent('ITEM', (j - 1));
              gid('start').innerHTML = 'START TIME: ' + playlist[j - 1].starttime + '   CURRENT TIME: ' + hoursminutes + '   ITEM: ' + (j -1);
              break;
            }
          }
        }
        else
        {
          setTimeout("startTime();", 50);
        }
      };


Then write the time in a 24 hour decimal format of HH.MM so we don't have to split on a colon:
<meta rel='starttime'>15.34</meta>

Apr. 21, 2009Sebastian

Very nice, thank you!

I just want to share a small bug, it wasn't easy to find the reason for it ;-)

Sometimes, the stream didn't start at my first visit, only after a simple reload of the browser. Why? I think the playlist comes up a bit too slow, so the player doesn't know where to start. After the reload, the playlist is already in the cache and the stream can start.

You can test this bug by switching off the browser cache.

The solution might be a preloader for the playlist. The playlist has to be load always at first, then the other stuff can follow.

Otherwise every new user will see nothing (or a wrong starttime). Just want to mention...

Apr. 21, 2009brokenString

The function startTime() checks to see if the playlist is available from the player before it does anything.

If the playlist has not been loaded and parsed into an object, and is not available from the player, the function tries again in 100ms.

So something else is wrong.

Please post a link to a test page which displays the errant behavior.

Apr. 22, 2009Sebastian

This shows the alpha development:
=> Player: http://dev.clipcast.de/clipcast-live/
=> Playlist: http://dev.clipcast.de/fileadmin/user_upload/playlist/playlist.xml

Most of the time the playlist won't be load at first. After pressing F5 the player starts again at the right position. But sometimes it takes up to 10 reloads...

Btw: I use a RTMP-Stream, not the progressive download. A RTMP-Stream can start a bit faster. Perhaps a problem?

Apr. 22, 2009brokenString

Sorry, I can't reproduce the errant behavior.

I tested many times:

1) change the computer's time,

2) clear the brosere's cache,

3) re-load your page.

The player always started on the correct track.

Any more details about the failure?

Apr. 23, 2009Sebastian

Yes, that's the problem :-(

In some cases the error is very hard to reproduce. I will test a bit more to give you a feedback soon...

Thank you for your effort, I really appreciate it!

Apr. 24, 2009Martin Campbell

I experienced a similar problem. Try adding in a small delay to your PlayerReady function.

setTimeout("startTime()", 650);

Adding in the delay solved the problem and the initial playlist that is loaded is parsed with the player starting at the right track.

Martin

Apr. 24, 2009brokenString

Using a delay is very problematic. For most users, the delay is far too long, yet there is always the case where the delay isn't long enough and the application fails.

The method that we're using waits until it receives a valid playlist (usually between 50-100ms), then performs the indexing. This makes it both quick and robust.

Apr. 24, 2009Hi

Sorry,

So as I understood, this script will play the track from where it should be started?

for example, I have many tracks, and one of them scheduled to play at 13:00 am, lets call it track007, and the track duration is 5:24 minutes. Now, a visitor opened the website at 13:02:00 am , then track007 will start from minute 2:01 ?

is this possible?

Apr. 24, 2009Hi

And I forgot to say, that I'm using mix between rtmp, and fake php stream, or as you call it, scheduled play-list with files, and the files in the sever not rtmp....

Apr. 24, 2009brokenString

The script starts the track at 00:00.

You could enhance the script to SEEK to a position within the selected track, that was based upon the amount of time that had elapsed since your start time.

After the index, calculate the offset and send a seek.

player.sendEvent('ITEM', (j - 1));
var offset = hoursminutes - playlist[j - 1].starttime;
player.sendEvent('SEEK', offset);

Apr. 26, 2009Martin Campbell

I agree that using a delay is not a good idea, so I have replaced the delay with a listener in an addlisteners function that is called by the playerReady function.

player.addModelListener("STATE", "startTime");

Then removed it before instructing the player.

player.removeModelListener("STATE", "startTime");
player.sendEvent('STOP');
player.sendEvent('ITEM', (j-1));

This works, once for the page, and once correctly again if the page is re-loaded. Then the playlist will simply carry on in sequential order.

I'm not sure if this is the most efficient way of solving this problem (ie using ModelListener), so any better solutions would be interesting. Thanks for the "seek" enhancement, I'll test this too, particularly if the time elapsed is greater than the length of the item.

Martin

Apr. 26, 2009Martin Campbell

Re; The SEEK calculation. I think that the "offset" as worked out above is in 1/100's of minutes, so you need to multiply it by 100 and then by 60 to convert it into seconds.

Apr. 28, 2009satamusic@gmail

thanks for the above contributions.

if any one is interested in extending the above code examples (for pay) to a solution that lets you schedule what gets played per week, per day, per hour, right down to the minute;

i am aware that Longtail mentions they don't take any flash work for less than $2000, so freelancers please reply. i'm sure this work is nowhere near $2000.

i'm sending this to the longttailvideo contact form too.

Cesar satamusic@gmail.com

May. 12, 2009Sebastian

Hey all,

some nice suggestions above, thank you!

Anyway... by now I'm not very happy with this type of schedule. Using Javascript to read the current position in the playlist is always a bit risky. Thinking about different plattforms (e.g. mobile devices) or gaming devices, they will often block JS (whops!) or something else.

Currently I try to build a playlist with the known structure, but all the videos should be stored in a live-instance of my Adobe Flash Media Server. So we get one RTMP-Link for the Player. I like the approach of a server-side playlist and not one on the client side.

Does anyone has some experience with this?

May. 23, 2009Mattias

Thanks to all of those who participated in this thread. I've been pondering this problem for a while and you've all helped immensely. Gratzie!

Jun. 02, 2009Cesar

thanks again for your contributions. Longtail has not replied to me, they might not be interested in small projects under $5000 (hint*hint*contactus!).

any developers willing to implement this please contact me @ satamusic@gmail.com

alivepubs.com

Jun. 28, 2009Roy

I have tryed the supported script but i did not work. I did everything i had read here but nothing works. The player always started with the first clip. Can someone please look at it ?
http://www.videosdelen.nl/flvplayer/index2.html

xml :

http://www.videosdelen.nl/flvplayer/playlist2.html

I also had another question. is the time that you fill in the xml file the server time or the time of windows ?

Jun. 28, 2009lost

The time in the playlist is the time on the client.

This should work better — tested & working.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

  <head>

    <title>Simple Play On Schedule - JWMP v4.4.x - swfobject v2.1</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        'file':                                  'playlist_domenico.xml',
        'playlist':                              'right',
        'playlistsize':                          '400',
        'repeat':                                'none',
        'shuffle':                               'false',
        'stretching':                            'none',
        'skin':                                  'bright',
        'frontcolor':                            '86C29D',  // text & icons                  (green)
        'backcolor':                             '003367',  // playlist background           (blue)
        'lightcolor':                            'C286BA',  // selected text/track highlight (red)
        'screencolor':                           '000000',  // screen background             (white)
        'id':                                    'playerID1',
        'autostart':                             'true'
      };

      var params =
      {
        'allowfullscreen':                       'true',
        'allowscriptaccess':                     'always',
        'bgcolor':                               '#000000'
      };

      var attributes =
      {
        'name':                                  'playerID1',
        'id':                                    'playerID1'
      };
      
      swfobject.embedSWF('player-4.5.223.swf', 'player1', '900', '327', '9.0.124', false, flashvars, params, attributes);
    </script>

    <script type="text/javascript">
      var player    =  null;
      var playlist  =  null;


      function playerReady(obj)
      {
        player = gid(obj.id);
        startTime();
      };


      function startTime()
      {
        playlist = player.getPlaylist();

        if(playlist.length > 0)
        {
          var currentTime  = new Date();
          var hoursminutes = 1 * (currentTime.getHours() + '.' + currentTime.getMinutes());

          for(var j in playlist)
          {
alert(hoursminutes + ' : ' + playlist[j].starttime);
            if(playlist[j].starttime > hoursminutes)
            {
alert('Track: ' + j + ' Start Time: ' + playlist[j].starttime);
              player.sendEvent('ITEM', (j - 1));
              gid('start').innerHTML = 'START TIME: ' + playlist[j - 1].starttime + '   CURRENT TIME: ' + hoursminutes + '   ITEM: ' + (j -1);
              break;
            }
          }
        }
        else
        {
          setTimeout("startTime();", 100);
        }
      };


      function gid(name)
      {
        return document.getElementById(name);
      };
    </script>

  </head>

  <body>

    <div id="playercontainer1" class="playercontainer"><a id="player1" class="player" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>
    <div id="start" style="font-family:arial;">START TIME:     CURRENT TIME:     ITEM:</div>

  </body>

</html>


Change the playlist filename and the player version.

Comment out the alerts when they get annoying.

Jun. 29, 2009Roy

It did not work for me :( when i set the time in the playlist on 15:05 and 15:11 and i visit the site onn 15:11 i get two messages that you can see in the screenshot i uploaded. And than the player start with the first movie file !

http://img1.foto-hosting.nl/33427playlist1.jpg

http://img1.foto-hosting.nl/229035playlist2.jpg

Jun. 29, 2009lost

Here's the exact code that I posted above, functioning correctly: http://willswonders.myip.org:8074/Roy.html

The playlist is available at: http://willswonders.myip.org:8074/playlist_domenico.xml if it would be helpful to you.

See brokenString's post of Apr. 21, 2009 for the correct time format if you are using hours and minutes.

Jun. 29, 2009Roy

i copied your code exactly but it didn't work for me. You can see it on this url :

http://www.videosdelen.nl/flvplayer/index2.html

http://www.videosdelen.nl/flvplayer/playlist2.xml

Jun. 29, 2009lost

You have a mistake here:
<location>/Moviehttp://www.videosdelen.nl/flv/video3.flv</location>

Jun. 29, 2009Roy

changed it but it gives the same problem...

Jun. 29, 2009lost

You need to add a few more tracks to your playlist because it will always go backward one track.

In other words, if the local time is 16:30 and the starttime is 17, the player will load the previous track with a starttime of 16 until the local time is 17:01, if there is a starttime greater than 17.

The last track should have a starttime of 24, which will never be played, because it will always go back one track.

Jun. 29, 2009Roy

Oke i got it working now with hours. But when i do it with minutes it do not work. It always plays the first track.

Working version with hours :
http://www.videosdelen.nl/flvplayer/index2.html

Not working version with hours and minutes :
http://www.videosdelen.nl/flvplayer/index3.html

http://www.videosdelen.nl/flvplayer/playlist3.xml

Jun. 29, 2009lost

Damn strings!

Replace this whole function.
      function startTime()
      {
        playlist = player.getPlaylist();

        if(playlist.length > 0)
        {
          var currentTime  = new Date();
          var hoursminutes = 1 * (currentTime.getHours() + '.' + ((currentTime.getMinutes() < 10) ? '0' + currentTime.getMinutes() : currentTime.getMinutes()));
//alert('hoursminutes: ' + hoursminutes);

          for(var j in playlist)
          {
            gid('start').innerHTML = 'ITEM: ' + j + ' START TIME: ' + playlist[j].starttime + ' CURRENT TIME: ' + hoursminutes;
//alert(j + ' : ' + hoursminutes + ' : ' + playlist[j].starttime);

            if((1 * playlist[j].starttime) > hoursminutes)
            {
              player.sendEvent('ITEM', (j - 1));
              gid('start').innerHTML = 'ITEM: ' + (j - 1) + ' START TIME: ' + playlist[j - 1].starttime + '   CURRENT TIME: ' + hoursminutes;
//alert('Track: ' + (j - 1) + ' Start Time: ' + playlist[j - 1].starttime);
              break;
            }
          }
        }
        else
        {
          setTimeout("startTime();", 100);
        }
      };


I also took care of the case where minutes have a leading zero.

Jun. 29, 2009Roy

It works perfectly now !!!! Thanks you for all your help !!

Jun. 29, 2009lost

You're welcome.  Enjoy!
 
 
    Good Luck!

Jul. 03, 2009Adam

I am a developer new to using the JWPlayer. So far, so good.

As an OOP I like reuse. Therefore, my implementation includes the use of XML playlist. However, my host is smart to the FLV extension. I am certain they are blocking binaries with no extension and those with FLV.

I did find that I can play file with extension TXT while setting flashvar 'type' to 'video'. If only a playlist 'type' entry was supported.

Would support 'type' in the playlist be a worthy feature request? If so, how do I log such?

Thanks,

Adam

http://adamcox.net
http://vorba.com

Jul. 03, 2009lost

You can put any of the File properties flashvars that you want in the playlist using a meta element for XSPF or the jwplayer namespace for MediaRSS. You can also use your own flashvars for special needs.

XSPF<meta rel='type'>video</meta>
MediaRSS<jwplayer:type>video</jwplayer:type>
See: http://developer.longtailvideo.com/trac/wiki/FlashFormats#XMLPlaylists

File properties: http://developer.longtailvideo.com/trac/wiki/FlashVars#Fileproperties

Jul. 04, 2009Adam

I was "lost" and now I'm found. Appreciate it!

Add a reaction

You can also return to the category or try this search for related threads.


 

Search the Forums

Go

Support

Support Here are some helpful links to learn more about the JW Player™:

Monetize Your Video

Monetize Your Video Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!

Why Buy a License?

Why Buy a License? If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.