I have a video element:
<video class="media video" src="http://localhost:3000/uploads/medias/2014/08/11/nahNYjjysJBuwSsxj_2" loop></video>
Using jQuery I move it around the DOM (attaching and detaching it).
Sometimes after a new attachemnt (using $.appendTo
) the video goes black with no possibility to programatically play it. Ie: I can do the following with no success:
var video = $('video')[0]; // using jQuery I get the reference to the DOM element
video.load(); // nothing happens
video.play(); // nothing happens
video.pause(); // nothing happens
I also have a listener on it
$('video').on('canplay', function () {/*...*/});
which never gets triggered.
I've tried changing the url to:
v.src = v.src + '?cache_bust=true';
// then
v.load(); v.play();
but nothing happens.
video
elements using $.appendTo
to a visible area and then try to play them Chrome shows pending
and the server never reports an incoming request. `
As I've been digging deeper. I've realized this might be a chrome/ium issue. Thus I've found the following pages:
Which all show bugs that have been open for 1.5 - 4 years. Which does not look too promising. Therefore I will dive into searching for alternatives, trying out:
video.src = null; video.load();
video.src = null; video.load();
on every video hide byte ranges
In which format are your videos? Many encoders, including FFmpeg and MEncoder, write the mp4 metadata very unclean. In most cases the index will be written at the end of the video file and not, as expected at beginning of the file. So the entire video must be downloaded before it can be played.
The correction can be done under Linux with a small but powerful tool called qt-fast start
. This small program is conveniently already by default in the tools subdirectory of the FFmpeg installation included.
If you're indeed using Chrome, this may be related to chrome's behaviour concerning videos, ie using byte serving to get the video stream, then mess up when receiving a 200 HTTP code, and not 206 which suits the byte serving thing better.
The problem seems to happen mainly when replaying the video. You'll find more info in this other thread: HTML5 video will not loop
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.