MP4 doesn't play after initial load in Safari - html

I have embedded a mp4 file in my webpage, that gets loaded fine and is playable by every browser and on mobile too.
<video controls src="/mymovie.mp4">
<track kind="captions"></track>
</video>
However, when I open the webpage with Safari (macOS), the only thing I can see is a black box with the size of the video and a striked through (disabled) play button in front of it. The thing is, when I refresh the page again (even without clearing the cache) the video works fine.
When I write my markup to use the source element, the problem appears, but in a different way. Now I see no longer a black box, but a transparent one and I can press the play button, but the video won't start. I already tried to place a "not supported" text under the source list, but the text doesn't appear.
<video controls>
<track kind="captions"></track>
<source src="/mymovie.mp4" type="video/mp4"></source>
not supported
</video>
Notice that I already tried reordering the source element above the track element.
Is there any known problem of this kind and a way to solve it?
Here are some more informations about my setup:
HTTPS only (valid certificate)
video size is around 3,5MB
NGINX is configured to send this headers:
accept-ranges: bytes
Content-Range: bytes 262144-3411398/3411399
content-type: video/mp4
Something I notice in difference to Chrome is, that inside my devtools network tab the video source is loaded between 2 and 4 times, but just one time of it with the correct size. The other two entries are just some bytes. However, this happens in the same way, if I face the black box.

<video controls autoplay>
<source src="/mymovie.mp4" type="video/mp4">
<track kind="captions"></track>
</video>
Did you try using source tag instead? Autoplay attribute can also help, but some browsers do not allow videos to be autoplayed, or autoplay all videos as muted, if user didn't interract with document first. My best guess is that Safari doesn't allow to play a video without the prior interaction, and you refreshing the page do interact with the page. You can cheat it playing video after clicking on privacy policy accept button.
// jQuery
$('#button-id').click(function(){ $('#video-id').play(); });
// Javascript
var button = document.getElementById('button-id');
var video = document.getElementById('video-id');
button.addEventListener('click', function(){ video.play(); });

If your video is in the same folder you should use:
<video controls autoplay>
<source src="mymovie.mp4" type="video/mp4">
<track kind="captions"></track>
your browser doesn't support HTML5 video
</video>
or
<video controls autoplay>
<source src="./mymovie.mp4" type="video/mp4">
<track kind="captions"></track>
your browser doesn't support HTML5 video
</video>
You could also include your whole url:
<video controls autoplay>
<source src="http://url.to/mymovie.mp4" type="video/mp4">
<track kind="captions"></track>
your browser doesn't support HTML5 video
</video>

Related

video in html5 is not working in all browser

I tried this code but video is just continuing to load, not to playing.
I also tried video codec H-264 but that is not working.
Next I tried to convert mp4 video to webm but that did not help either
Can anyone tell me how to do this using jquery and ajax?
<video controls muted>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
Did you checked by drag and drop to open the movie.mp4 or the movie.ogg file?
If the file does not work by simply opening it using a browser, it might be the file's problem, not the code or the browser.
For the file type support per browsers please refer the "Can I use?" pages:
MPEG-4/H.264
Ogg/Theora

A video I have won't load load in chrome. How can I fix it?

I have a webpage that includes a video within it. However, even though all of the file types (.mp4, .ogg, .avi) are supported in chrome, the video will not show.
I've already tried adding "preload="Metadata"" as described in a similar post, but it just loaded the thumbnail. once. I have also used Chrome's [inspect element] and my coding software's error finder, none of them have found any relevant errors.
<video width="256px" preload="auto" controls preload="metadata">
<source src="Audio_Video/Video.mp4" type="video/mp4"
preload="metadata">
<source src="Audio_Video/Video.ogg" type="video/ogg"
preload="metadata">
<source src="Audio_Video/Video.avi" type="video/avi"
preload="metadata">
</video>
I expect the video to load and play as it does on other browsers, but it in fact does not. All that appears is this: A broken video that will not load

HTML Video plays double when autoplay is enabled

On my wordpress site, when adding a video via the standard HTML Video tag, and then adding autoplay to it - when i then reload the page it sure autoplays but after a few seconds another instance starts the audio and then the audios are overlapping each other. How can i prevent this? This is my simple code.
<video width="400" controls autoplay>
<source src="/uploads/2018/04/ML_video-converted-with-Clipchamp.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
Whats going on here?

HTML5 Simple Video Player. What did I miss?

First I made a screen recording as a video I would like to display.
Than I uploaded the video to VLC to convert the video.
I made one MP4 and a fallback for OGG.
I then moved the videos to my dropbox account so I can host them there.I right clicked and got the link to each video from dropbox. I am trying to use the links as the src in the video tags.
<video width="400" controls>
<source src="https://www.dropbox.com/s/m7emkfs994sgm5g/Untitled.m4v?dl=0" type="video/mp4">
<source src="https://www.dropbox.com/s/9owwdbm8p0nz1f0/oggguntitled.ogg?dl=0" type="video/ogg">
</video>
Even though I told VLC to convert it to MPV, the file extension is m4v.. Is that the same thing?
The video just shows blank. Not getting any errors either.Not sure what I missed.
The following Fixed it for me.
I made two changes:
change dl=0 at the end of your dropbox link to dl=1. I believe this makes it a download link instead of a page to view a download link.
Due to a bug in chrome on OSX certain mp4 files will fail to play correctly (some kind of graphics acceleration issue), but it won't fall back to the ogv. For this reason, i have placed the ogv as first since it will work on OSX-chrome, and platforms that don't support it should fall back to the mp4.
<video width="400" controls>
<source src="https://www.dropbox.com/s/9owwdbm8p0nz1f0/oggguntitled.ogg?dl=1" type="video/ogg">
<source src="https://www.dropbox.com/s/m7emkfs994sgm5g/Untitled.m4v?dl=1" type="video/mp4">
</video>

How can I link to an .mp4 video in my site?

I have a web site and I want to link a button to a video. So whenever someone clicks the "video" buttons let's say, I want to open the video.mp4 in a new browser. What I do is:
<div>...</div>
The video is quite big (190MB) so the code above is not working. I start listening to the sound but cannot see the image.
Does anyone know how to do it? Or any simple way to just open this video as a link?
You could use HTML5 tag don't forget that MP4 is only supported by IE 9+, Chrome 5+ and Safari 3+. You should at least convert your file to WebM or Ogg to make it compatible with all recent browsers.
To do so you would need a new page (where the link goes) and in this page have this code:
<video width="320" height="240" controls="controls">
<source src="movie.ogg" type="video/ogg" />
<source src="movie.mp4" type="video/mp4" />
<source src="movie.webm" type="video/webm" />
Your browser does not support the video tag.
/* instead of the last line you could also add the flash player*/
</video>
The browser will automatically select the first known format and play it. (source: w3Schools.com)
Hope this helps!