javascriptjquerymediaelement.js

mediaelement.js setSrc method not working


I try using mediaelement.js..

var player = new MediaElementPlayer('#player',{
 startVolume:0.5,
 alwaysShowControls:true
});

it's nice working when "src" is static. but with dynamic src

player.setSrc('link_to_audio');

browser returns error - TypeError: Object # has no method 'setSrc'

browsers - Chromium 23.0.1300.0 (170000) and FF 19.0.2


Solution

  • The documentation says that you should initialize it like this :

    var player = new MediaElementPlayer('player',{
    

    rather than like this

    var player = new MediaElementPlayer('#player',{
    

    or using jQuery :

    $('#player").mediaelementplayer({