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: '.m3u8',
image: '.png',
title: 'STREAMING TITLE',
width: '100%',
height: "100%",
aspectratio: '16:9',
skin: 'glow',
mute: 'true',
ga: '{}'
});
jwplayer().onError(function(){
jwplayer().load({image:".png"});
jwplayer().play();
});
</script>
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./stream.m3u8',
image: 'http://blog./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./streamimage-error.png"});
jwplayer().play();
});
</script>
Share
Improve this question
asked Mar 3, 2015 at 3:17
MacaMaca
1,6893 gold badges18 silver badges43 bronze badges
3
-
Looking at the API docs, it seems you need to load a video file with the image value.
file:"http://blog./error.mp4"
for example. – Papa Commented Mar 3, 2015 at 3:26 - according to this doc. support.jwplayer./customer/portal/articles/… you can include image – Maca Commented Mar 3, 2015 at 3:34
- Yeah, but you also need to include a link using the file attribute, if that is mandatory. – Papa Commented Mar 3, 2015 at 4:07
1 Answer
Reset to default 7See here
You need to add file attribute as mentioned in the document jwplayer().load({file:"http://jwplayer./errorfile.mp4",image:"http://jwplayer./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./stream.m3u8',
image: 'http://blog./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./errorfile.mp4", image:"http://blog./streamimage-error.png"});
// jwplayer().play();// i dont think you need to play video if it throws error
});
</script>
I would remend 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./errorfile.mp4",image:"http://jwplayer./errorfile.jpg"});
jwplayer().play();
},5000);
});
I hope it helps.