Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

JWPlayer Show image on error


I am using player.onError event handling (JWPlayer 6) to load a error.mp4 video when our livestream is offline or not available.
Problem with this is that the error video is reloaded once it ends which creates 1-2 seconds of loading time and doesn't look good.

I read in few posts in JWPlayer forum that its possible to show a image aswell or even replace the player itself with a custom image in event handling, but none of the posts in forum actually provided the way to do so.

My current code is as follows:


<div id="myElement">Loading the player...</div>
<script type="text/javascript">
var playerInstance = jwplayer("myElement");
playerInstance.setup({
file: "rtmp://62.210.247.57:1935/live/live",
title: 'OneStream',
});
console.log('Error1');
playerInstance.onError(function(){
console.log('onError');
playerInstance.load({file:"streamError.mp4",image:"http://content.jwplatform.com/thumbs/7RtXk3vl-480.jpg"});
});
playerInstance.onComplete(function(){
console.log('onComplete');
playerInstance.load({file:"rtmp://62.210.247.57:1935/live/live",image:"http: //content.jwplatform.com/thumbs/7RtXk3vl-480.jpg"});
});
</script>



I want to use a static error.png image so I can use the onBuffer event or such to check the RTMP livestream in realtime and when its online, load it instead.

4 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi, there.

Can you please give me a link to a page where you have the affected player installed?

shubhank008pp

User  
0 rated :

@Alex here
http://onestream.in/channel/animatsuri

Is there a way to get notified on replies or so ? I did not get any notification of your reply or can see anything in account dashboard to even find this question link, had to look up in my browser history

Alex

JW Player Support Agent  
0 rated :

Hi, there.

When you have our player load a stream, whether or not its the same stream, when onComplete is fired, there will be the 1-2 seconds of loading time and there is no way around this. However, under normal circumstances, the player should show the poster image when the stream has finished playing. What happens if you don’t have the player load the stream onComplete?

Also, regarding notifications, I do not know of a way to be notified on a response in the support forums. However, in the future, you can contact us via email at support@jwplayer.com and you will be notified of replies.

Thank you!

shubhank008pp

User  
0 rated :

The reason for reloading the file in oncomplete is so that jwplayer can recheck if the livestream is now online or not, if its online, it would start playing the livestream else go to the onerror part to show the message, till the stream is online again

This is needed so user dont manually have to keep reloading the page to check if livestream is online or not

This question has received the maximum number of answers.