如何打开JW播放器6中的视频链接列表(mp4格式/灯箱)

时间:2013-09-27 14:54:15

标签: jwplayer6

我有一个网页,在灯箱中打开.flv视频文件(top_up-min.js / modal)。现在我试图在灯箱中使用JW播放器6打开相同视频文件的.mp4版本。

我试过的代码正在打开灯箱[jquery.jwbox.js]中的视频,建议代码打开一个隐藏的div作为灯箱。但我有以下问题

1.点击视频后,点击“关闭按钮”以外的任何其他地方,视频仍会关闭。 在IE 8或更高版本中,即使关闭视频,您也可以听到音频。它只在刷新页面时停止。

有没有人已经使用过这个吗?

2.还有其他jquery灯可以用于JW播放器(mp4格式)

由于

<head id="Head1" runat="server">

<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript" src="jwplayer/jwplayer.js" ></script>
<script type="text/javascript" src="/js/jquery.jwbox.js"></script>
<link rel="stylesheet" type="text/css" href="/css/jwbox.css" />
<script type="text/javascript">jwplayer.key = "key";</script>

<title></title>
<script type="text/javascript">
//this function i tried to close the video because the    existing jquery one 
closes  video even when u touch outside the box.but its throwing js error.

function fnClose() {       
       document.getElementById('jwbox_hidden').style.display = 'none';
       document.getElementById('jwbox_background').style.display = 'none';
       jwplayer().stop(true);
       return false;
   }
   function loadVideo(myFile,title) {
       document.getElementById("videoTitle").innerHTML = title;

       jwplayer("player").setup({              
           file: myFile,
           width: '640',
           height: '480',
           volume: 100,
           autostart: true,              
           primary: "flash"
       });
   }
    </script>   
 </head>
<body>
<p>
 Click the link to display a JW player with a video in the JW Box.


</p>
    <div class="jwbox">
         <ul> <li><a href="#" onclick="javascript:loadVideo('http://wpc.2A70.edgecastcdn.net/002A70/CareerVideos/45-2092.01.mp4','Nursery Workers');">Nursery Workers</a></li></ul>
         <ul> <li><a href="#" onclick="javascript:loadVideo('http://wpc.2A70.edgecastcdn.net/002A70/CareerVideos/15-1021.00.mp4','Computer Programmers');">Computer Programmers</a></li></ul>
         <ul> <li><a href="#" onclick="javascript:loadVideo('http://wpc.2A70.edgecastcdn.net/002A70/CareerVideos/39-9011.00.mp4','Child Care Workers');">Child Care Workers</a></li></ul>


  <div class="jwbox_hidden" id="jwbox_hidden">
     <div  class="jwbox_content">
     <label id="videoTitle" class="te_title">          </label>
      <a class="te_close_link" style="display: block;" onclick="fnClose();" ></a>
    <div id="player"></div>

    </div>
  </div>
  </div>
  <br />
  </body>

1 个答案:

答案 0 :(得分:2)

我知道这可能不是您正在寻找的答案,但在我测试时它起作用了。我还没有找到问题的确切原因。这是一个hacky解决方法。

如果查看jwbox.js,可以使用这样的try catch块:

            try {
            $.jwbox.player.sendEvent("STOP");
            $.jwbox.player = null;
        } catch (err) { }

我将你的fnClose()添加到catch块中:

            try {
            $.jwbox.player.sendEvent("STOP");
            $.jwbox.player = null;
        } catch (err) { fnClose() }

或者,这似乎表现得更快:

            try {
            fnClose();
            $.jwbox.player.sendEvent("STOP");
            $.jwbox.player = null;
        } catch (err) {  }

如果sendEvent(“STOP”)失败,至少会调用fnClose(),我相信这是问题的根源。

希望有帮助,对不起这是我的第一个StackOverflow答案:) -Pablo