[英]JWPLAYER custom error message
I embedded JWPlayer on my page with custom error message that display different image when stream is not online but error image is not loading. 我在我的页面上嵌入了JWPlayer,其中包含自定义错误消息,当流不在线但错误图像未加载时,该错误消息显示不同的图像。
<script type='text/javascript'>
jwplayer('player').setup({
file: 'http://blog.com/stream.m3u8',
image: 'http://blog.com/streamimage.png',
title: 'STREAMING TITLE',
width: '100%',
height: "100%",
aspectratio: '16:9',
skin: 'glow',
mute: 'true',
ga: '{}'
});
jwplayer().onError(function(){
jwplayer().load({image:"http://blog.com/streamimage-error.png"});
jwplayer().play();
});
</script>
You need to add file attribute as mentioned in the document jwplayer().load({file:"http://jwplayer.com/errorfile.mp4",image:"http://jwplayer.com/errorfile.jpg"});
您需要添加文件
jwplayer().load({file:"http://jwplayer.com/errorfile.mp4",image:"http://jwplayer.com/errorfile.jpg"});
提到的文件属性jwplayer().load({file:"http://jwplayer.com/errorfile.mp4",image:"http://jwplayer.com/errorfile.jpg"});
you need to create a error video
for this and change your code 您需要为此创建
error video
并更改您的代码
<script type='text/javascript'>
jwplayer('player').setup({
file: 'http://blog.com/stream.m3u8',
image: 'http://blog.com/streamimage.png',
title: 'STREAMING TITLE',
width: '100%',
height: "100%",
aspectratio: '16:9',
skin: 'glow',
mute: 'true',
ga: '{}'
});
jwplayer().onError(function(){
jwplayer().load({file:"http://jwplayer.com/errorfile.mp4", image:"http://blog.com/streamimage-error.png"});
// jwplayer().play();// i dont think you need to play video if it throws error
});
</script>
I would recommend creating error video and error image and use it when error occurs. 我建议创建错误视频和错误图像,并在发生错误时使用它。
Below code will be much helpful for constant stream monitoring. 下面的代码对于恒定流监控非常有帮助。
jwplayer().onBuffer(function(){
theTimeout = setTimeout(function(){
jwplayer().load({file:"http://jwplayer.com/errorfile.mp4",image:"http://jwplayer.com/errorfile.jpg"});
jwplayer().play();
},5000);
});
I hope it helps. 我希望它有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.