javascript - SoundManager on 100% HTML5 mode stuck on "stalled" -
in smart-tv app, i'm using soundcloud api, through cross domain request - $.getjson()
etc.
app uses soundmanager2 api on 100% html5 mode (no flash) load tracks .stream_url
retrieved soundcloud. problem begins when trying play loaded tracks. app loaded 10 tracks, of them won't play.
noticed log stating:
0040 sound0: play(): loading - attempting play... 0041 sound0: abort 0042 sound0: waiting 0043 sound0: loadstart 0044 sound0: stalled
where stays forever. issue happens same tracks, while other tracks streamable, , playable, showing log:
0078 sound2: durationchange (191190) 0079 sound2: loadedmetadata 0080 sound2: stalled 0081 sound2: suspend 0082 sound2: loadeddata 0083 sound2: canplay 0084 sound2: onload() 0085 sound2: playing ♫
the code used create sound object, , play it:
soundobject = soundmanager.createsound({ // load current track url: "https://api.soundcloud.com/tracks/" + trackids[elements][index-1] + "/stream?client_id=f430822ab78177a5cfb94d572d9036a2", volume: 100, autoload: true, //autoplay: true, //stream: true, whileplaying:function(){currentposition=soundobject.position;barwhileplaying(elements, index, currentposition);}, onfinish: function(){baronfinish(elements, index);}, onstop: function(){baronstop(elements, index);}, }); soundobject.play();
(where whileplaying
, onfinish
, , onstop
parameters call function changes css and/or classes of elements within html document.)
my questions:
- is there way know beforehand smsound object won't play?
- say can't know before loading it "loadstart" , "stall" forever, there way of knowing after loaded?
i'm asking since of tracks load , play after long periods of time.
i can suggest work-around may help.
var mysound = soundmanager.createsound({..}); mysound.load(); settimeout(function() { if (mysound.readystate == 1) { // object stalled } },5500);
this works since in html5, unlike flash, readystate property jumps '0'(uninitialized - not yet loaded) '3'(loaded) instantanously, skipping '1'(initialized - started loading), cause if sound started buffering it's playable in html5, hence readystate returns 3...
on html5, permanently (or long duration) stalled sounds have readystate = 1 long after load() attempt.
after - can replace/remove/skip errouneous track or whatever.
- note - 5500 msec's should long enough, can play around , see best timeout platform.
hope you.
Comments
Post a Comment