How to stop download video in HTML5 player - javascript

I have multiple HTML5 videos <video> on one page. When I play first, it starts downloading. But when I pause or stop it, download continues. When I play next video on the same page, there are two video downloads in the same time.

set the attribut preload="none" in the video tags or preload="metadata" if you want the length and other data upfront.

Question is similar as here. Try to use Media Source Extension.

Related

Hero HTML5 videos - can playback start before DOMcontentloaded?

Probably a silly question but are there any ways to force playback of a HTML5 <video> earlier than the DOMcontentloaded event?
The video is hardcoded in a liquid file with the following attributes:
<video
poster="./poster.webp"
src="./545645660.sd.mp4"
loop muted playsinline autoplay preload="auto" type="video/mp4" disableRemotePlayback>
</video>
Since it's a hero background video, it needs to start playback as fast as possible but there's about a 2 second delay which looks bad. I've found that disabling JavaScript in Dev Tools will make it load instantaneously so it appears the large amounts of scripts are causing the delay but not sure if there's a way to prioritize playing back the video.
Browsers tend to delay videos downloading u til after all the JS, CSS, HTML, images - since these are required to load the page. Perhaps you can defer some of the scripts to load later?
You could also remove the poster - since that downloads BEFORE the video, and is probably never seen - as the video autoplays.

Change video source with Javascript in html without refreshing the page just the video

My team and I are making a custom html video player and I'm working on a setting panel
And the first option we are mainly worried about so I'm adding first is the video quality option.
<video id="video" class="nm" poster="the poster url">
<source src="video source url of the video at 480p" type="video/mp4" size="480">
<source src="video source url of the video at 720p" type="video/mp4" size="720">
<source src="video source url of the video at 1080p" type="video/mp4" size="1080">
</video>
And now what we want to do is when the user toggles on an option it will change the video source to the source that has the quality specified by the size attribute
Image reference here
PS: We are making a video player from scratch as It is on its own built with no APIs (e.g. Video.js, JWPlayer, Plyr) We are making all the things needed from scratch with pure javascript and html... and as we're making a website for streaming, and my team and I want to make a video player made by us for the website, and "maybe" later for distribution but for now we want to make a brand new video player and were just been putting this part off as we aren't sure of the best way to do this!
Edit
Also, we want the video to pause and change the quality and pick up off where it was paused
Note that for the native video the browser will decide which <source> to show and choose the first element it supports/understands (e.g. the first supported video file format): https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#Usage_notes
To circumvent that and force the browser to show a certain video source url, put in only one <source> element and manipulate the source property with javascript.
To pause and play the video in the native HTML5 video player you may use the API of the HTMLMediaElement: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement
It has the play and pause functions you're looking for.

Custom scrub bar in video HTML5, set currentTime not working

I'm making a custom scrub bar in HTML video player. I'm creating a HTML5 video player and take a currentTime from video and it is working good, but seting currentTime after moving a scrub bar dose not working.
Firstly, I want write I've tried several possiblity to resolve this problem. I disable autoplay in video and other things, what can be.
But, one thing puzzles me. I can not have a directly URL to the video, I have a URL to JSP code on the server, and this code return to me this file. What can be a problem with it? Because, if I downloaded this movie file and set URL to directly to this movie file - with extension .mp4 - all starts working good.
Maybe it's problem with it I can not have a directly url to movie file?
I don't have any ideas to resolve this porblem. I'm counting on your help
if the video stored as an .mp4 or .ogg or .webm video file format, It would play. Here is how your html may look like.
<video controls preload="metadata">
<source src="http://www.example.com/waterfall-video.mp4" type="video/mp4"/>
<source src="http://www.example.com/waterfall-video.ogg" type="video/ogg">
Video not supported.
</video>

Stop playing parent frame HTML5 audio from an iframe?

Quick question: I have an HTML document playing HTML5 Audio. Nothing fancy. Textbook really.
<audio id="audioclip" preload="auto" loop >
<source src="audio/music01.ogg" type="audio/ogg">
</audio>
The same HTML document features an iframe containing a few Images. Clicking on one of these images browses to a page containing an autostart HTML5 video clip.
Of course now the audio from the parent AND the audio from the iframe video play at the same time.
Is there an EASY way to stop the parent audio playback from inside the iframe automatically when the autoplay video triggers?
I found some pretty complicated stuff for parent/child communication. Far to sophisticated for me. But I also found this little snippet:
jQuery(function($) {
parent.$("#parent_element").trigger(event);
} (window.jQuery));
Could I put that to use in my case?
Or are there alternatives?
Just getting into JavaScript a little more, atm I'd consider myself a newbie. :-\
Many Thanks!
PS: On video end the iframe page automatically browses back to the previous page. It would be super-nifty if the audio would resume playing at the Point IF it was playing before. If not then...well...not. But I reckon that would be much more complex?

How to reloading Video in html5

I making Streaming video with webRTC.
I want to reload video without stopping on HTML5.Src file is my filesystem.it's appending chunk while video playing.
Please tell me ‎(´・ω・`)
Did you try to add the loop parameter to your video tag?

Categories

Resources