Autoplay Demo 1
Another one ?
Yep !
Quite easy : autoplay, muted are set in the HTML code.
In javascript, we just set two parameters :
- volumeForced: true, so we're sure that volume will always be null on refresh;
- volumeGroup: 2, group whose members are this player and also the one that you can discover if you are curious enough to click on the button above.
The callback function is used to hide the controls when the player is ready and starts playing.
HTML
<div class="video-container"> <video src="assets/video/Greenpeace-2020_End_of_Year.mp4" muted autoplay></video> </div>
JAVASCRIPT
new AmstramgramMediaPlayer(document.querySelector('video'), { volumeGroup: 2, volumeForced: true, }, function () { //this = our player //Start listening to amst__play event this.on('amst__play', function hideControlsWhenPlayBegin() { //this = our player //Stop listening this.off('amst__play', hideControlsWhenPlayBegin) //Hide the controls this.hideControls() }) })