Prevent autoplay of <video> elements - html

does someone know how to prevent Chrome and Safari from autoplaying videos? I am looking for an attribute or style I can incorporate into our website, not a browser extension! We have a few videos on the same page and in Chrome they just all start auto playing for some users while in Safari they kind of autoplay, but they don't start at the same time. They all have sound, so I had expected none of them to autoplay, but apparently that is not the case (at least not for all users).
Thanks!

Use autostart=0 and autostart=1
HTML embed autoplay="false", but still plays automatically
https://support.google.com/chrome/forum/AAAAP1KN0B0LkA8FoBoleU/?hl=en&gpf=%23!topic%2Fchrome%2FLkA8FoBoleU

Make sure you use the video or audio HTML5 elements, and NOT object or embed. I also had this problem using the latter HTML elements and the ONLY way to stop them from autoplaying was to change the browser settings. The reason is, because object and embed use a 3rd party plugin or player when playing your media, while video and audio are native to the browser.
If you want to stop them from playing anyway on just your box, below are the settings for Firefox:
Open up your Firefox Browser, click the menu button, and select "Options"
Select the "Privacy & Security" panel and scroll down to the "Permissions" section
Find "Autoplay" and click the "Settings" button. In the dropdown change it to block audio and video. The default is just
audio.

Related

HTML iframe allow autoplay of audio file not working safari

This works perfect with other browsers but safari automatically downloads file.
<iframe src="lib/audio/voice.mp3" allow="autoplay" class="audio-main" id="iframeAudio">
</iframe>
I need play background audio in a website. Opera and Chrome are working fine unfortunatelly Safari Browser open website automatically audio download.What exactly is the problem, Thanks for advance
No Auto-Play by default says the man
According to Safari / WebKit Auto-Play policy it gives users the ability to browse the web with fewer distractions, particularly in the form of relief from websites that auto-play with sound. They instruct websites to assume that any use of video or audio will require a user gesture or click to play.
Policy configuration
Users can enable auto play functionality on a per website bases.
Safari >> Preferences >> Websites >> Auto-Play
Options are:
Allow All Auto-Play
Stop Media with Sound (default)
Never Auto-Play
Functionality iframe allow autoplay works in Safari
When the user has allowed auto play from a specific website the iframe tag works as expected.
<iframe allow="autoplay" src="happy.mp3"></iframe>
Not surprising though so too does the <audio> element load and play on its own.
<audio autoplay loop src="happy.mp3"></audio>
Detect auto play is disabled and display player
However it should be expected that this functionality will not be enabled, since the ability exists for users to disable it, so it’s important to detect if auto play was denied and proactively react accordingly.
var promise = $('video')[0].play();
if (promise) promise.catch(error => {
// Auto-play disabled show controls
$('audio').attr('controls', '');
});
For this option we do not need auto play at all since we are manually calling play. This will not work of course if a user action is required so all we are left to do is to add the controls and display the player.
Audio with controls
For the sake of completion, there's always the other option; avoid auto play all together... but what's the fun in that.
<audio controls src="happy.mp3"></audio>
nJoy!

Swipebox - Issue when playing a youtube video and navigating to another video in Chrome

The following only occurs in a newly release Chrome browser (meaning it was working on a previous Chrome browser version) while using the JQuery plugin Swipebox. Firefox, IE and Edge all work as expected.
Issue (swipebox 1.4.1 latest):
While playing a Youtube Video, click swipebox's Next or Prev navigation arrows.
The next video will be showed, however, trying to play this video will result in the next video to appear on top of the current video, which is actually playing (you can hear the sound, but can not see it).
The close "X" and navigation arrows are no longer visible.
You are now stuck. Must refresh page or press "ESC".
Again, in IE, Firefox and Edge, the video navigation all behave properly.
This only seems to occur on the Chrome browser.
How to replicate:
Example video page: http://donsfootwear.com/production-videos
Click a thumbnail - The Swipebox plugin will initiate and show the video preview fullscreen.
Play video by clicking on it - The video will start playing.
Whist the video plays, click the "Next" arrow - The next video preview will be showed.
Play video by clicking on it.
You are now stuck - The video you just clicked play will disappear. The next video preview will be shown (unresponsive). Swipebox "X" close and "Next"/"Prev" navigation buttons will disappear. Only way to escape is pressing "ESC" or refresh page.
Anyone can verify/experienced this with their own site, and most importantly have a workaround?
Thank you.
This has been fixed via a google chrome update recently.

YouTube iframe player won't play when tab/window doesn't have focus

When I attempt to create a YouTube iframe player with autoplay in a Google Chrome tab that doesn't have focus the video won't start until the tab gains focus. Even manually calling playVideo won't get the video to play. At first I thought this was part of the new feature that prevents YouTube videos from playing in newly opened tabs, but this only seems to effect Google Chrome.
You can replicate the issue in the wild by doing the following:
Go to http://www.tandem.io and create a room
Go to your newly created room in Chrome AND firefox (or Opera)
Mute the player in Opera
Make sure the Chrome tab does not have focus
Add a YouTube video to the playlist in Opera
The video won't play in Chrome until the tab/window is active
I believe this is a Chrome browser feature in that it prevents JS from firing if the tab is blurred.
You can recreate this by visiting youtube.com and opening a number of videos in new tabs but not visit those tabs, the blurred tabs will not begin autoplaying the video until it has been focused at least once.
You can Disable this in chrome://flags
In Chrome - chrome://flags/#disable-gesture-requirement-for-media-playback

video pop-up WITHOUT Flash

I'm trying to create a video pop-up that works on Apple devices and I've been playing around with fancyBox & some YouTube videos. Because YT uses Flash, this isn't going to work (which I am just now realizing)
Is there a way to open up an html5 video inside of this pop-up?
I already set that part up:
Here's the page where I'm already using fancyBox: http://legal-replay.com/video-test/
Please help!
<a class="iframe" src="http://www.youtube.com/embed/dP15zlyra3c?html5=1">Open HTML5 Video</a>
I don't know much about fancybox but it looks like you can just have it open any iframe you want, which will work with YoutTube's default embed method. Just pass html5=1 to the iframe.
From what I can tell scouting around stackoverflow, this is only supported for single videos, I don't know if you can force an entire playlist to use HTML5, that might still be a client-preference.
Source
Fancybox Howtwo

iOS HTML5 video player next/prev buttons

Is there a way to access/listen to the previous/next buttons in the iOS HTML5 video player? Ideally I would listen to some sort of a prev and next event and swap out the videos accordingly without the user having to close the video and click my prev/next buttons.
(source: iphonefaq.org)
I am currently using jwplayer to generate the html5 video and listening to their playlist next/prev listeners don't seem to do the trick. I can always find and attach listeners to the actual <video> tag pretty easily though.
If you attach listeners to the video tag itself then when the user hits next and previous then the listeners in the code will put up on those buttons. I am doing something similar with youTube videos. If you hit next it goes to the end of the youtube video and fires a video complete event tag and then I load the next video when that is called, so that the video will one loop without the next button and two the users can hit the buttons. I have not found a way to monitor the buttons in the player on the iphone side, but if I find it I will post that as well since it is important to know both angels if possible.
Funny thing I think I am looking to try and do the same exact thing. I know how to transition the videos to the next without having to leave the fullscreen mode because of using youTube api in the js but I am not able to observe the quicktime player itself and need to for another feature that I would like to work on.
That's the native iOS player which is a thin version of Quicktime. You'll know if it's an HTML5 player when it doesn't transition from the Quicktime player and your page in Safari. How is your movie being embedded?
I recently had a similar problem and was unable to find a solution using the HTML player. I ended up implementing the video player using MPVideoPlayer Framework and launching it from my web view with a custom URL scheme (AppName:Commnad:Asset). I was then able to use the delegate methods to monitor user interactions. If you would like to see basic implementation, let me know and I can add some code.