setSrc not working to fix broken audio player

I have an audio player that gets initialized on my WordPress page. Unfortunately, sometimes the audio url is not valid (maybe even blank). I tried fixing it by calling mejs.players[0].setSrc('working.mp3');
but it is throwing TypeError: this.media.setSrc is not a function

I tried setting the media.src then load(), but that didn’t work either. It has made a div with class ‘me-cannotplay’. Does this mean that this player cannot be used?

Read More

Any way to still use this player?

Related posts

Leave a Reply

2 comments

  1. Try

    <audio id="player" controls="controls">
        <source type="audio/mp3" src=""/>
    </audio>

    then

    player.setSrc([{ "type": "audio/mp3", "src": "some/url.mp3" }]);