Search code examples
javascriptaudiomedia-playermediaelement.jsmediaelement

mediaelement.js - How to change width


I have tried to find which of the plethora of tags controls the width of the mediaelement.js audio player but can't seem to work it out.

I'm assuming it's a combination of the tags that need to be edited?

I downloaded the player from the mediaelemenjs.com and the CSS for it is huge.

<div class="fluid player">
   <audio id="player2" src="http://www.newlifedeewhy.com/media/school/2014/20140526-School-EpiLimiñana.mp3" type="audio/mp3" controls></audio>
   <script>$('audio,video').mediaelementplayer();</script>
</div>

Here is JS Fiddle for demonstration.


Solution

  • you can find the option at the API list

    // if the <video width> is not specified, this is the default
    defaultVideoWidth: 480,
    // if the <video height> is not specified, this is the default
    defaultVideoHeight: 270,
    // if set, overrides <video width>
    videoWidth: -1,
    // if set, overrides <video height>
    videoHeight: -1,
    // width of audio player
    audioWidth: 400,
    // height of audio player
    audioHeight: 30,
    

    eg:

    $('audio,video').mediaelementplayer({audioWidth: 600});