How to change youtube's automatically queued autoplay video? - javascript

I'm developing a chrome extension that sets a different video to autoplay other than the one youtube queues by default. I searched through the html and replaced all instances of the next queued video with another one, but it didn't work. So I'm stumped as to where else I can search for where this video url is set. Where is this url set?

Related

Cannot get HTML audio element to play on Chrome Android (no progress unless muted)

I'm posting this in case others have a similar problem.
I have a web app that uses the <audio> element. When the user clicks a button, I set the src attribute on the <audio> element to a URL of a mp3 file, then I call .load() and then .play(). The play() method's Promise resolves properly.
On the web, this works, I hear the music. On Android Chrome, the audio did not play:
The Play/Pause control showed the Pause icon (indicating the audio element thinks it's playing).
The progress on the track stayed frozen at the beginning 0:00.
If I muted the element, the track started playing.
If I just browsed to the URL of the mp3 file in Chrome, the audio loaded and I could play the song.
Anybody out there know why?
After a bunch of playing around and debugging, on a whim I finally removed some code I had planned to experiment with around audio context / graph:
const audioCtx = new AudioContext();
const sourceNode = audioCtx.createMediaElementSource(this.audioElem);
After remove these lines - the <audio> element played properly!

Why do Youtube and many other video pages play on page load?

There are a lot pages like Youtube starting their videos with sound on load:
https://www.arte.tv/de/videos/091148-000-A/forschung-fake-und-faule-tricks/
Sound should be only allowed after click, whitelisting or if multiple videos on the page have been viewed before. This is not needed here.
What is the difference between these pages and a simple HTML5 Video element using autoplay attribute or Javascript videoElement.play()?
In case you are using Chrome there is another thing which influences if a page can autoplay media or not. It's the Media Engagement Index. It's basically a number which is larger if you used to play media on that particular page before. If it's large enough the page is allowed to autoplay.

Allow Audio to Play on Page Load

I'm maintaining a legacy ASP/VBScript application for some warehouse scanners. They run Android 7 with Chrome 64. I can configure Chrome however I want so I'm not constrained like a normal website would be. Due to the nature of this web application, playing a sound on page load would improve usability (when the submitted action fails). Is there any way to allow an audio file to play on page load?
I can play sounds easily after a user interaction. However, I've tried multiple methods to play a sound on page load without success:
An <audio> tag with autoplay does not play (<audio autoplay="">).
Play the sound during the load event (Audio.play()). The returned Promise fails with the error:
NotAllowedError: play() can only be initiated by a user gesture.
Create an Audio with autoplay, and append it to body during the load event.
Create an Audio, append it to body, and .play() it during the load event. Yields the same "NotAllowedError".
Whitelisting the website for sounds in Chrome.
Ensuring the media autoplay setting is set to allowed in Chrome.
Both Chrome and Firefox, have dropped support for the autoplay attribute for both audio and video unless it's a video with the sound muted.
You can read more on that here: Autoplay Policy
However, recently I found a workaround using the Howler.js library, and it seems to work quite well in just these lines of code:
let timer, sound;
sound = new Howl({
src: ['<?= get_theme_file_uri() ?>/images/spotAudio.mp3']
});
sound.play();
You can download the library and read the docs here: https://howlerjs.com/

Autoplay video in the uiwebview

I have UIWebview contain video in the html ,I need to detect the first video in the html and play it.
Is there any trick in javascript or objective c to Autoplay the video when page finish loading ?
If the embedded video is not from Youtube, you must set your UIWebView to allow media playback without user action.
This can be done by setting the mediaPlaybackRequiresUserAction property of your UIWebView to false.
Example: self.webView.mediaPlaybackRequiresUserAction = NO;
If you've embedded a YouTube video, you can simply append &autoplay=1 to the end of the video url.
This will cause the video to autoplay on page load.
Click on inline Playback in storyboard

Disable youtube autoplay if video has been seen

Is it possible to disable 'autoplay' of an embedded YouTube video if the visitor's seen it already.
My idea is on front page I've got a video which is set to autoplay, but I don't want it to play every time a visitor returns.
Thanks!

Categories