video tag error event on ipad standalone web app does not work

212 views Asked by At

First to say sorry if I am asking already answered question, but I can't find it nor solve this at the moment.

I am developing an web application that is runned on iPad in a standalone mode. There is an <video> tag and I am playing live stream videos with it, I think that this could be the problem since I did not tested error event on a static file. My problem is that I can not bind onerror or error event to tag so that if for some reason stream fail I can restart it.

My video tag looks like this:

<video id="video_tag" preload webkit-playsinline autoplay="autoplay" x-webkit-airplay="allow">
<source type="video/mp4" src="http_stream_url"></source>
</video>

I have tried to add onerror="alert('error')" on video tag directly, it did not worked.

I have tried to add an event listener to video tag directly document.getElementById("video_tag").addEventListener('error', function(event) { alert('error'); }, true); it did not worked.

I have tried to add event listener to source tag as somebody pointed that error event is triggered by source tag not video tag but it did not worked.

I also tried to put onerror="alert('error')" on source tag, did not worked.

Note that this is inside iPad > Safari > standalone mode > javascript web application > video tag > playing HLS (http live stream) stream

EDIT: It does detect loading video stream fail but I need to detect when stream stops during playing and restart stream in that case.

Thanks

1

There are 1 answers

0
vipw On

I think you should be listening for the onstalled event in the video element. A video element is a special kind of media element, and the list of events can be found at w3schools.

Keep in mind that the browser support is still fairly early, and not all the events are necessarily implemented. I would recommend creating a handler for all of the listed events and seeing if there is indeed an event being fired when the stream stops. I suspect that the onreadystatechange or onsuspend events could also help you.