HTML Video auto play, mute and unmute button, If you are using video tags in HTML with support mobile, desktop and tablet
STEP 1. Create Index.php video html tag create and add code
<video id="vfigger" poster="img/01.jpg" width="100%" height="100%" autoplay muted loop>
<source src="451783260figger.mp4" type="video/mp4">
<source src="451783260figger.mp4" type="video/ogg">
</video>
<source src="451783260figger.mp4" type="video/mp4">
<source src="451783260figger.mp4" type="video/ogg">
</video>
STEP 2. create a buttons to enable or disable video voice
<button class="btn-view-more" onclick="enableMute()" type="button">OFF</button>
STEP 3. Create a javascript to perform action of audio voice
<script>
var vid = document.getElementById("vfigger");
function enableMute() {
vid.muted = true;
}
function disbleMute() {
vid.muted = false;
}
</script>
Whole Code in index.php
<video id="vfigger" poster="img/01.jpg" width="100%" height="100%" autoplay muted loop>
<source src="451783260figger.mp4" type="video/mp4">
<source src="451783260figger.mp4" type="video/ogg">
</video>
<source src="451783260figger.mp4" type="video/mp4">
<source src="451783260figger.mp4" type="video/ogg">
</video>
<button class="btn-view-more" onclick="disbleMute()" type="button">ON</button>
<button class="btn-view-more" onclick="enableMute()" type="button">OFF</button>
<button class="btn-view-more" onclick="enableMute()" type="button">OFF</button>
<script>
var vid = document.getElementById("vfigger");
function enableMute() {
vid.muted = true;
}
function disbleMute() {
vid.muted = false;
}
</script>
var vid = document.getElementById("vfigger");
function enableMute() {
vid.muted = true;
}
function disbleMute() {
vid.muted = false;
}
</script>
Work Perfextly Thanks
ReplyDelete