How to change mediaelementjs audio player container height?

2k views Asked by At

I'm using WordPress to output a mediaelementjs audio player. The audio player's mejs-container is given an inline style of height 30px. The code that does this is located in file wp-includes/js/mediaelement/mediaelement-and-player.min.js. For example:

ioHeight:30

I tried overriding the height in my style sheet but that doesn't work because the inline style takes precedence.

How can I change this height?

enter image description here

1

There are 1 answers

1
nunopolonia On BEST ANSWER

When creating the mediaelement you can use the option audioHeight

  $('audio').mediaelementplayer({
    audioWidth: '100%',
    audioHeight: 30
  });

Afterwards, you can access the player using the following JS:

$('audio')[0].player

That will allow you to change the size of the player using the function

$('audio')[0].player.setPlayerSize(width,height);

This function will change the size of the player but leave the controls as they were so you'll need to adjust their size as well using the function:

$('audio')[0].player.setControlsSize();