I've run into a strange problem with video playback on mobile - in general, the videos playback fine on phones, but if the same phone has visited the site more than a few times (say 4 or 5), the video will no longer play and instead display a still image. Here is the format of the HTML for the videos:
<video playsinline autoplay muted loop id="waterBackground" src="../assets/water1-forwards_compressed.mp4"></video>
There is one line of JS changing the video playback rate, but that's it:
$("#waterBackground")[0].playbackRate = 0.8;
All of the HTML videos use this exact format, and every phone I have tested this on (except iphone < 5) has no trouble playing the first the first few times. But things stop working after that. When I clear the browser history and close and reopen the app, the video is working again. Any ideas why this might be happening and how I can fix it?
I have a webpage that plays continuous random videos (pulled from an external list), and it works great on mobile or desktop. But, when you try to chromecast the videos, the first one will successfully play on chromecast, but if my embedded player changes videos, it seems like the playVideo() function does not update what video is playing on the chromecast.
In the process of writing the question I figured out I wasn't actually calling player.playVideo(), and was relying on the autoplay behavior of player.loadVideoById() in all other contexts. Adding a player.playVideo() call immediately after play.loadVideoById() fixed the issue!
I am embedding a html5 video. It works perfectly fine in chrome and firefox, however in safari, there seems to be this weird delay, where the video just hangs in there, and won't play until 1-2 minutes after. It however plays immediately, if I switch tabs. I am hosting my video on an Amazon S3, I set it to autoplay, muted and loop. I have tried using jquery to force play the video but it doesn't work. I have tried also changing the metadata to video/mp4 on aws control panel, also doesn't work. Also tried doing some window focusing, also doesn't work. Any tips would be appreciated. Here is the site http://xxvii27.github.io/web-oconnect/
Solved, by converting the .mp4 video to web optimized version using handbrake.
Is it possible to fully buffer HTML5 video in Chrome (and Opera)?
I host the movie in .mp4 and .webm on amazon S3. In HTML I use standard <video> tag. The server responds with status 206 Partial Content. It is great, as it allows the browser to download any part of the video but I need to be able to seek instantly to any part of the file.
I tried:
.PROGRESS event. When Chrome stops buffering the first part, the connection is killed. The next parts are downloaded in new connection, so JavaScript isn't able to continue checking total downloaded data. Even if it could, the old data isn't stored in cache. This method works in Firefox and Safari. Heck, even in IE10!
XHRS. I am able to fully download the movie, but when the video starts playing, Chrome tries to download the movie from the server again. I even tried to pass the movie into HTML in base64, but that's to much data
FileAPI. Chrome isn't able to create BLOB big enough and crashes.
Any help is welcome!
ps. I am aware of od and similar questions, but I hope something changed since they were asked.
Because S3 supports partial downloads, Chrome initially buffers "only what's needed" in front of the playhead and then stops buffering. It will continue buffering "only what's needed" when the video starts playing. This means that depending on the user's download speed it will stop buffering now and then, just because it has enough buffer to play continuously.
But if you pause the video after having played some, Chrome will not stop buffering and go through all the way to the end.
This example exploits that technique to entirely buffer the video off screen before showing it on the page.
Tested on Chrome 32
// Create video in background and start playing
var video = document.createElement('video');
video.src = 'video.mp4';
video.controls = true;
video.muted = true;
video.play();
// Pause immediately after it starts playing.
video.addEventListener("timeupdate", function() {
if (this.currentTime > 0) {
this.pause();
video.muted = false;
video.currentTime = 0
this.removeEventListener("timeupdate", arguments.callee, false);
// When whole video is buffered, show video on page
video.addEventListener("progress", function() {
if (Math.round(video.buffered.end(0)) / Math.round(video.seekable.end(0)) == 1) {
document.body.appendChild(video);
this.removeEventListener("progress", arguments.callee, false);
}
}, false);
}
}, false);
Have you tried the canplaythrough event?
Not in the traditional sense, I mean. Rather in a 'hacky' way. canplaythrough is triggered when the browser detects that it has enough video buffered to play continuously without pausing. I am guessing that this event triggers about the same time as chrome pauses buffering. If that's the case, it could be use to trigger a request for rest of the video.
I have not tried it, but the HTML5 video object contains a buffered property
var video = document.createElement('video');
video.buffered.start(0);
video.buffered.end(0);
Could you try monitoring the buffered (Such as with this thread chrome html5 video buffered.end event)
Then continually change the current time to right before the buffered time using
video.currentTime = video.buffered.end(0) - 1;
There are several ways to load a video all the way then play it:
1. There is the goody goody browser developer would be proud way:
var video = document.createElement('video');
video.src='myvideo.mp4';
document.appendChild(video);
video.load();
video.addEventListener('loadedmeta',function(){
video.play()
});
2. And there is the lazy "But, I'll get carpel tunnel!" developer way:
<video src='myvideo.mp4' onloadedmeta='this.play()' preload></video>
Sources:
http://www.w3schools.com/tags/tag_video.asp
how to run js code when video is fully buffered/loaded
How do I add new Video entirely from JavaScript?
javascript with html <video> load() & play() function not firing
http://www.w3.org/wiki/HTML/Elements/video
Be careful using video.buffered.end(0). According to my experience, it works with Chrome but it fails with IE9.
I don't know what happens, IE9 seems to forget to do the last update to video.buffered.end() at the end of the buffering process and the video.buffered.end(0) is a little bit smaller than video.duration.
So, if you think your page could be used with another browser than Chrome, don't use video.buffered.end(0).
I'm using mediaelement.js to load videos with subtitle tracks.
All was working well until I updated my Chrome browser to 27.x. Now if a subtitle track is included, the video will load but not play. The video buffers fine (I can manually scrub through it), but neither the play button or javascript play() will play the video. The loading gif just sits there, and I don't see any errors in the console.
It works in all other browsers I've tested, including Chrome 26.x.
If I remove the subtitle source element, the videos load and play correctly in Chrome.
(This is my first SO question so any tips would be appreciated, thanks)
I'm on day four of trying to solve this same issue and came across this question. It's happening on Mac and Windows. Troubleshooting is aggravated by what appears to be local caching -- if I comment out the <track> the video plays; When I re-enable it and reload, it also plays, but then if I close out of the browser it will no longer work until I comment the <track> out again.
If I disable mediaelement and test with native HTML5 video, the problem does not manifest itself.