1

我想使用各种流媒体协议设置 jwplayer,用于 flash/pc/mac 和用于 hls 功能设备的 html5 播放器,最后有一个用于旧 android 和 blackberyy 设备的后备链接。使用静态代码可以正常工作。但我想动态更改播放器 scr onclick 以获得不同的流媒体质量。

我有这个脚本(也在标题中)来动态更改播放器源 onclick:

<script type="text/javascript">
         function changeVideo(filename1,filename2,filename3) {
         jwplayer("myplayer").setup({
          autostart: true,
           autoplay: true,
           width: 640,
           height: 360,
           aspectratio: "16:9"
           playlist: [{
            image: "/images/poster.jpg",
            sources: [{
              file: filenam1
              },{
              file: filenam2
            },{
              file: filenam3,
            }]
          }],
           primary: "flash"
        });
        jwplayer('myplayer').load();
    }
         </script>

filaname1、filename2、filename3 是侦听 html/js onchange 函数的变量,该函数也有 3 个用 "," 分隔的链接。在我的身体里,我有这个:

<div id="myplayer">Loading the player...</div>
  //this is the default static player setup which is working fine
   <script>
    jwplayer("myplayer").setup({
    aboutlink: "http://mywebsite.com",
    autostart: true,
    width: 768,
    height: 432,
    aspectratio: "16:9",
      playlist: [{
        image: "/images/poster.jpg",
        sources: [{
          file: "rtmp://servername-or-ip:1935/appname/streamname"
          },{
          file: "http://servername-or-ip:1935/appname/streamname/playlist.m3u8"
        },{
          file: "rtsp://servername-or-ip:1935/appname/streamname"
        }]
      }],
      primary: "flash"
    });
</script>

// 这里是onlick动态改变的质量链接,有3个链接

<p><a class="button" href="javascript:void();" onclick="javascript:changeVideo('rtmp://servername-or-ip:1935/appname/streamname1,http://servername-or-ip:1935/appname/streamname1/playlist.m3u8,rtsp://servername-or-ip:1935/appname/streamname1');">Low Quality</a> 

<a class="button" href="javascript:void();" onclick="javascript:changeVideo('rtmp://servername-or-ip:1935/appname/streamname2,http://servername-or-ip:1935/appname/streamname2/playlist.m3u8,rtsp://servername-or-ip:1935/appname/streamname2');">SD Quality</a> 

<a class="button" href="javascript:void();" onclick="javascript:changeVideo('rtmp://servername-or-ip:1935/appname/streamname3,http://servername-or-ip:1935/appname/streamname3/playlist.m3u8,rtsp://servername-or-ip:1935/appname/streamname3');">HD Quality</a> 
</p>

如果有人帮忙?将不胜感激。

4

0 回答 0