JW Player XML播放列表和JavaScript [英] JW player xml playlist and javascript

查看:80
本文介绍了JW Player XML播放列表和JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用类似于此 http://jsfiddle.net/Apnu2/6/的javascript倒计时功能 当我的xml文件中的"title"元素的值为"R15","R30","R45"或"R60"时.字母"R"之后的数字值是我想通过javascript函数的倒计时时间.

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.

这是示例布局.第一个元素将播放视频.第二个元素应调用上述javascript函数,第三个元素是在倒数javascript函数达到零后应播放的另一个视频.

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>

现在,我的播放列表仅播放一个视频,接着播放一个视频,这很好;但是我在听上面提到的title值时遇到了麻烦,运行javascript代码,然后在javascript函数完成后返回播放列表中的下一个元素.

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.

推荐答案

代码如下:

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; 

                           }

这篇关于JW Player XML播放列表和JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆