• Resolved donsenilo1968

    (@donsenilo1968)


    Hi

    I found this and put it into my footer.php:

    <script type="text/javascript">
    jQuery(document).ready(function ($) {
        if($.fn.mediaelementplayer) {
            $("video").mediaelementplayer({
                startVolume: 0.5
            });
        }
    });
    </script>

    But it does not work. Can someone help please ?

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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)
    
    Thread Starter donsenilo1968

    (@donsenilo1968)

    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 1 year, 4 months ago by joecoyle.
    • This reply was modified 1 year, 4 months ago by joecoyle.
    • This reply was modified 1 year, 4 months ago by joecoyle.
    Thread Starter donsenilo1968

    (@donsenilo1968)

    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/

    Thread Starter donsenilo1968

    (@donsenilo1968)

    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

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Audio/Video default Volume’ is closed to new replies.