Change default media player volume

The default volume for the media player in wordpress is 0.8.

I want it to be 1.0, which is the maximum.

Here is the code to do that:

wp_localize_script( ‘wp-mediaelement’, ‘_wpmejsSettings’, array(
‘pluginPath’ => includes_url( ‘js/mediaelement/’, ‘relative’ ),
‘startVolume’ => 0.1
) );

From here: https://core.trac.wordpress.org/ticket/27384

I made a plugin using this code and it doesn’t work.

<?php
/*
Plugin Name: JD Change Default Volume
Plugin URI:
Description: Makes the default volume of the audio player max
Version: 1.0
Author:
Author URI:
License:
License URI:
*/

wp_localize_script( ‘wp-mediaelement’, ‘_wpmejsSettings’, array(
‘pluginPath’ => includes_url( ‘js/mediaelement/’, ‘relative’ ),
‘startVolume’ => 0.1
) );

The other solution is to use javascript as described here:

https://github.com/mediaelement/mediaelement/issues/2449

<script type=”text/javascript”>
jQuery(document).ready(function ($) {
if($.fn.mediaelementplayer) {
$(“audio”).mediaelementplayer({
startVolume: 1
});
}
});
</script>

but I don’t want to use javascript unless there is no other way.

My question:how exactly can I make my little plugin work, so that the volume of the media player is always set to max?

Read more here:: Change default media player volume

Leave a Reply

Your email address will not be published. Required fields are marked *