javascript - Controlling an embeded player -


i've got embedded sc player on page , want user able jump specific timecodes within sound file links on page. i've got working first click. if user clicks on link segment, sc player ignores it. keeps playing along , ignores input.

here's relevant code:

function playsc(seekto){ seekto = hmstoms(seekto); var container = document.getelementbyid("scplayer");  var iframe = container.getelementsbytagname("iframe");  var widgetiframe = iframe[0], widget = sc.widget(widgetiframe);        widget.bind(sc.widget.events.ready, function() {     widget.play(); }); widget.bind(sc.widget.events.play, function() {     widget.seekto(seekto);  }); widget.bind(sc.widget.events.seek, function() {     widget.unbind(sc.widget.events.play); }); widget.bind(sc.widget.events.pause, function() {     widget.unbind(sc.widget.events.play);  });  widget.bind(sc.widget.events.play, function() {     widget.unbind(sc.widget.events.play);  });   } var container = document.getelementbyid("scplayer");  var iframe = container.getelementsbytagname("iframe");  var widgetiframe = iframe[0], widget = sc.widget(widgetiframe);  seekto = getparameterbyname('t'); if (seekto){       (function(){     playsc(seekto);    }()); } 

the sc player embedded via wordpress plugin , getting through dom little tricky because can't assign unique id.

the href user clicks looks this: javascript:playsc("00:01:21");

what missing here? on second (or third or fourth) click why doesn't player stop, seek new time , start playing again?

i think may have answered own question. here's i've got , seems working.

function playsc(seekto){     seekto = hmstoms(seekto);     var container = document.getelementbyid("scplayer");      var iframe = container.getelementsbytagname("iframe");      var widgetiframe = iframe[0],     widget = sc.widget(widgetiframe);                widget.bind(sc.widget.events.ready, function() {         widget.play();     });     widget.bind(sc.widget.events.play, function() {         widget.seekto(seekto);      });     widget.bind(sc.widget.events.play_progress, function() {         widget.getposition(function(pos) {         seekto = pos;       });      });  } 

thoughts or advice? seems working, i'm not experienced coder. welcome input.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -