如何设置JW Player使用HTML5在iPhone上播放HLS

时间:2017-01-06 00:07:17

标签: iphone html5 jwplayer

我正在使用JW播放器7.8。我试图让玩家在JW播放器中播放我的直播流,它应该可以在iPhone上播放。

据我了解,我必须使用HTML5版本的JW Player。我有一个HLS来源:http://server-ip:1935/live/mystream/playlist.m3u8我的javascript代码看起来像这样:

jwplayer('my-stream').setup({
  width: '100%',
  height: '100%',
  stretching: 'uniform',
  playlist: [{
    sources: [{
      file: 'http://server-ip:1935/live/mystream/playlist.m3u8'
    }}]
  }],
  primary: 'html5',
  modes: [
    { type: "html5" },
    { type: "flash", src: "player.swf" }
  ]
});

我在iPhone上收到错误:

Error loading media: File could not be played

我已经找到了如何使用site http://demo.jwplayer.com/developer-tools/http-stream-tester/测试它,但在iPhone上播放m3u8文件仍然没有运气。 (我应该更改文件类型吗?)

我不确定我错过了什么?

1 个答案:

答案 0 :(得分:0)

<script src="CLOUD_HOSTED_PLAYER.js"></script> 
// It should be 7.8.7 at the time of writing
<div id="container">Loading Video...</div>
<script>
    var playerone = jwplayer("container");
    playerone.setup({
        file: "http://server-ip:1935/live/mystream/playlist.m3u8",
        width:"80%",
        aspectratio:"16:9"
    });
</script>