有人可以帮我将这个JWPlayer 5代码转换成JWPlayer 6代码吗? 该脚本实质上为桌面创建了RTMP流,为非闪存设备创建了HLS流 如果流媒体源不可用,将播放.mp4文件。在mp4文件结束后,脚本会重新加载页面以检查流式传输是否可用。如果出现否定回复,脚本将重复之前的步骤。
<script type="text/javascript">
var timeout = null;
jwplayer(document.getElementById("JWPLAYER_1080")).setup({
'flashplayer': 'http://xxxxxx.embed.scaleengine.net/latest/jwplayer.swf',
'autostart': 'true',
'provider': 'rtmp',
'streamer': 'rtmp://xxxxxx.videocdn.scaleengine.net/xxxxxx-live/play/',
'file': 'xxxxxx.stream',
'modes': [
{
'type': 'flash',
'src': 'http://xxxxxx.embed.scaleengine.net/latest/jwplayer.swf'
},
{
'type': 'html5',
'config': {
'file': 'http://xxxxxx.videocdn.scaleengine.net/xxxxxxxxx/play/xxxxxxxx.stream/playlist.m3u8',
'provider': 'video'
}
}],
'bufferlength': '5',
'width': '720',
'height': '405',
events:{
onBuffer: function(){
if(timeout == null) {
timeout = setTimeout(function() {
var time = new Date();
var currentTimeMillis = time.getTime();
jwplayer().load({'file':"http://xxxxxx.tv/style/video/streaming.mp4?" + currentTimeMillis});
},5000);
}
},
onPlay: function() {
clearTimeout(timeout);
timeout = null;
},
onComplete: function() {
window.location="http://www.xxxxxx.net/streaming.php?quality=1080";
},
onIdle: function() {
jwplayer().play();
},
},
});
</script>
答案 0 :(得分:1)
在这里,我无法真正测试它,因为一切都是占位符。我确实把自己的一些文件放在那里进行测试,似乎有效。
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<script src="http://p.jwpcdn.com/6/10/jwplayer.js" type="text/javascript"></script>
<div id="JWPLAYER_1080"></div>
<script type="text/javascript">
var timeout = null;
jwplayer(document.getElementById("JWPLAYER_1080")).setup({
'autostart': 'true',
playlist: [{
sources: [{
'file': 'rtmp://xxxxxx.videocdn.scaleengine.net/xxxxxx-live/play/xxxxxx.stream'
},{
'file': 'http://xxxxxx.videocdn.scaleengine.net/xxxxxxxxx/play/xxxxxxxx.stream/playlist.m3u8'
}]
}],
rtmp: {
'bufferlength': '5'
},
'width': '720',
'height': '405',
events:{
onBuffer: function(){
if(timeout == null) {
timeout = setTimeout(function() {
var time = new Date();
var currentTimeMillis = time.getTime();
jwplayer().load({'file':"http://xxxxxx.tv/style/video/streaming.mp4?" + currentTimeMillis});
},5000);
}
},
onPlay: function() {
clearTimeout(timeout);
timeout = null;
},
onComplete: function() {
window.location="http://www.xxxxxx.net/streaming.php?quality=1080";
},
onIdle: function() {
jwplayer().play();
},
}
});
</script>
</body>
</html>