Title: Video block initial volume
Last modified: January 14, 2023

---

# Video block initial volume

 *  [dhartmusic](https://wordpress.org/support/users/dhartmusic/)
 * (@dhartmusic)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/video-block-initial-volume/)
 * I would like to add code to each video block to set an initial playback volume.
   This is a voiceover reel and the video volumes are inconsistent. Since some of
   them are playing via Vimeo etc., the only way I can match them is to tweak their
   playback levels. Can someone shoot me a way to add to the code to set each video
   with it’s own volume? Thank You!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fvideo-block-initial-volume%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/video-block-initial-volume/#post-16375174)
 * The HTML5 video player element has[ a .volume property](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/volume)
   you can set (as a decimal fraction between 0 and 1) with JavaScript, but embedded
   players from streaming services typically have their own players within iframes
   which your JS cannot access. In some cases such players might accept an attribute
   value in the iframe tag to set a volume level. Availability of such an option
   will vary by provider.
 *  Thread Starter [dhartmusic](https://wordpress.org/support/users/dhartmusic/)
 * (@dhartmusic)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/video-block-initial-volume/#post-16375228)
 * Thanks bcworkz,
    Even if I can only set the volumes for the uploaded files it
   will help as generally they are louder than the streamed files. Not quite sure
   how to add the JS. This is the html for the video block:
 * <figure class=”wp-block-video”><video controls src=”[http://www.mellodeevo.com/wp-content/uploads/2023/01/You-and-Us_v16.movSmall.mov”></video></figure&gt](http://www.mellodeevo.com/wp-content/uploads/2023/01/You-and-Us_v16.movSmall.mov”></video></figure&gt);
 * Here is the script from the page you linked:
 * const obj = document.createElement(‘audio’);
    console.log(obj.volume); // 1 obj.
   volume = 0.75;
 * Not sure how to implement.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/video-block-initial-volume/#post-16378761)
 * Sorry, that example isn’t very useful. The link was merely to document that a
   video player has a volume property that we can manipulate. This sets the volume
   of the first video player found to 70% (untested):
 *     ```
       <script>
       var vids = document.getElementsByTagName('video');
       if ( 0 < vids.length ) { vids.item(0).volume = 0.7; }
       </script>
       ```
   
 * You cannot place this code through the post editor, it’ll get corrupted. Probably
   the simplest way to place it is to put it on the relevant post template. If your
   theme is subject to periodic updates, you should keep the modified template in
   a child theme. As a test it’s OK to modify the template where it sits, but it’s
   not a good long term solution.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Video block initial volume’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/video-block-initial-volume/#post-16378761)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
