JW player xml playlist and javascript

↘锁芯ラ 提交于 2019-12-13 04:41:31

问题


I want to use a javascript countdown function similar to this http://jsfiddle.net/Apnu2/6/ when a 'title' element in my xml file has a value of 'R15', 'R30', 'R45', or 'R60'. The numeric value after the letter 'R' is the countdown time I want to pass the javascript function.

Here is a sample layout. The first element will play a video. The second element should call the javascript function mentioned above, and the third element is another video that should play after the countdown javascript functions reaches zero.

<?xml version="1.0"?>
<rss xmlns:media="http://search.yahoo.com/mrss/"xmlns:jwplayer="http://developer.longtailvideo.com/trac/" version="2.0">
<Channel>
  <Title>MRSS Playlist Playlist</Title>
    <item>
      <title>04:48</title>
      <media:content url="videos/Set1_mid.flv"></media:content>
      <media:thumbnail url="thumbs/set1_mid.jpg"></media:thumbnail>
      <description>5 minute cardio with handweights</description>
      <jwplayer:duration>288</jwplayer:duration>
      <jwplayer:start>0</jwplayer:start>
    </item>
    <item>
      <title>R15</title>
      <media:content url="nothing"></media:content>
      <media:thumbnail url="nothing"></media:thumbnail>
      <description>rest option</description>
      <jwplayer:duration>15</jwplayer:duration>
      <jwplayer:start>0</jwplayer:start>
    </item>
    <item>
      <title>01:20</title>
      <media:content url="http://youtu.be/WG2N0WKmquE"></media:content>
      <media:thumbnail url="http://img.youtube.com/vi/WG2N0WKmquE/3.jpg"></media:thumbnail>
      <description>harder than what it looks</description>
      <jwplayer:duration>580</jwplayer:duration>
      <jwplayer:start>500</jwplayer:start>
    </item>
</Channel>
</rss>

Right now my playlist just plays one video after the next, which is good; but I'm having trouble listening for the title value mentioned above, running the javascript code, then returning back to the next element in the playlist when the javascript function is complete.

Please let me know if my questions doesn't make sense. I'd be glad to clarify and post additional code I'm using if need be.


回答1:


Here is the code:

onPlaylistItem: function(event){

                           var getMessage = jwplayer("container").getPlaylistItem().message;

                           if (getMessage.substr(0,1)=="R"){


                               $("#bottomtimer").hide();
                               $("#bottomRestTimer").show();
                               var restTime = getMessage.substr(1,2);
                               var minutes = 0;
                               var time = minutes*60 + restTime;


                               var interval = setInterval(function(){

                                   if (time == 0 ){

                                   clearInterval(interval);                                       
                                   $("#bottomRestTimer").hide("slow");
                                   //$("#bottomtimer").show("slow");
                                   $("#bottomtimer").fadeIn(5000);

                                   jwplayer().playlistNext();


                                   }
                                   var minutes = (Math.floor(time/60 ));
                                   //this code add a zero like 01:15 which I like but I need to add
                                   //the same logic to the routine countdown
                                   //if (minutes < 10) minutes = "0" + minutes;
                                   var seconds = time % 60;
                                   if (seconds < 10) seconds = "0" + seconds;
                                   var text = minutes + ":" + seconds;

                                  document.getElementById('resttimer').innerHTML = text;

                                  time--;

                               }, 1000);


                           } else {
                               document.getElementById('topstatus').innerHTML = getMessage; 

                           }


来源:https://stackoverflow.com/questions/11066251/jw-player-xml-playlist-and-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!