Hello @donsenilo1968
I would be happy to assist you. I am not familiar with the script that you are using. However, the script below will set the active video volume to 0.5 (Half volume). Please let us know if this works for you.
<script>
var video = document.currentScript.parentElement;
vid.volume = 0.5;
</script)
Thanks for your help. I corrected your Script but it does not work.
<script>
var vid = document.currentScript.parentElement;
vid.volume = 0.5;
</script>
I have uploaded an example here:
https://joecoyle.w3spaces.com/video-volume.html
How and where on wp are you adding the script for the volume?
Here is another example using my test wp site. I thought a block would work but it only works using custom html.
https://test.coyle.us/video_volume
Does this solution work for you?
-
This reply was modified 2 years, 7 months ago by
joecoyle.
-
This reply was modified 2 years, 7 months ago by
joecoyle.
-
This reply was modified 2 years, 7 months ago by
joecoyle.
Hi
Sadly it does not work. When I use this, I get an Error “vid is not defined”.
<script>
var video = document.currentScript.parentElement;
vid.volume = 0.5;
</script>
Weirdly in your Examples I get no Error. I changed video to vid, the Error is gone but still does not work. Maybe because the Video has no id ?
I added this Script at the End of the footer.php:
<?php wp_footer(); ?>
<script>
var vid = document.currentScript.parentElement;
vid.volume = 0.5;
</script>
</body>
</html>
Btw.: This is the Website https://aihaunted.com/k-i-videoclips/
UPDATE !
I found a working Solution:
<script>
const vids = document.getElementsByTagName("video").length;
for (let i = 0; i < vids; i++) {
document.getElementsByTagName('video')[i].volume = 0.4;
}
</script>
And thank you for your help.
@donsenilo1968
Nice job figuring out how to loop through all the videos on the page. Please mark your post resolved to help keep the site tidy