JWPLAYER custom error message

久未见 提交于 2019-12-22 07:49:09

问题


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.

<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>

回答1:


See here

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"});

you need to create a error video for this and change your code

<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.



来源:https://stackoverflow.com/questions/28823487/jwplayer-custom-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!