Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript how to make a video autoplay from javascript in chrome, with volume?

Chrome wont autoplay a video embedded with javascript, unless its muted. But i cant figure out how to use code to unmute it.

problem is that i am repurposing code [listed below, and in link]. it embeds video in an iframe. there is no variable to access the mute of that i can see. thus the vid variable below doesn work.

The whole code is at https://codepen.io/richardengle/pen/poNjvpY

Line 33 of the area of JS code is where i would change. you can see the vid muted/unmuted part, but it wont unmute the video. Any advice is welcomed
----- part of code----
$('button#play20s').click( function() {
$('body').removeClass().addClass('on playing20s');
$("#knob").trigger('play');
$("#tune").trigger('play');
$('.video-embed').remove();
$('body').append('<iframe id="decade-20" class="video-embed" width="560" height="315" src="
To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
" frameborder="0" allowfullscreen ></iframe>');
var vid = document.getElementById("decade-20");
vid.muted =false;
//https://www.youtube.com/embed/gTevoUhDeoM?&theme=dark&autoplay=1&keyboard=1&autohide=2&start=10&mute=1


});
,
 
Hello,

I do not have much experience with Javascript, but can't you simply start the video yourself by writing the following?:
JavaScript:
var video = document.getElementById("video");

video.play();
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom