Sound in HTML5: this.jeashAudio.load() - Uncaught TypeError: Cannot call method 'load' of null

Hello, When I try to play a sound for the second time, altought it does sound, I get this error in the Javascript console (Chrome): sound stalled SoundHTML5.js:3947 Uncaught TypeError: Cannot call method 'load' of null SoundHTML5.js:3948 jeash.med…

  • Forums
  • »
  • Bugs
  • »
  • Sound in HTML5: this.jeashAudio.load() - Uncaught TypeError: Cannot call method 'load' of null
Viewing 1 to 3 (3 Total)
Sound in HTML5: this.jeashAudio.load() - Uncaught TypeError: Cannot call method 'load' of null

jfroco

jfroco
Total Posts: 10
Joined: April 14, 2012

Hello,

When I try to play a sound for the second time, altought it does sound, I get this error in the Javascript console (Chrome):

sound stalled SoundHTML5.js:3947
Uncaught TypeError: Cannot call method 'load' of null SoundHTML5.js:3948
jeash.media.SoundChannel.$extend.__onStalled SoundHTML5.js:3948
f

The javascript code is:
,__onStalled: function(evt) {
console.log("sound stalled");
this.jeashAudio.load(); //line 3948

My class is (I've got the same error with new Sound(request) and Assets.getSound() ):

public function new() {
super();
trace("Starting..");

#if js
trace("html5");
var request:URLRequest = new URLRequest("http://192.168.1.100:8080/assets/Sound/click.mp3");
this.sound = new Sound(request);
#else
this.sound = Assets.getSound("click");
#end
Lib.current.stage.addEventListener(MouseEvent.CLICK, this.play);
}

private function play(event:MouseEvent) {
trace("play");
this.channel = this.sound.play();
}


You can try it here:http://dl.dropbox.com/u/4281970/nme/index.html...

Is this a bug or am I doing something wrong?

Tags:
Posted on July 29, 2012 at 2:59 AM

crayfellow

crayfellow
Total Posts: 204
Joined: November 28, 2011

Re: Sound in HTML5: this.jeashAudio.load() - Uncaught TypeError: Cannot call method 'load' of null

The first thing (which you probably already know) is that sound in HTML5 is still pretty wonky across browsers. Getting it to work is a bit of a trick unfortunately, and some mobile browsers (such as iOS) refuse to play media unless the play command is in synchrony with user action such as a click handler. This makes programmatic audio difficult for advanced applications.

It looks like what you are encountering is a bug in the stalled handler in SoundChannel. The reason it is working anyway is that the HTML5 audio doesn't necessarily have to be retold to load when it stalls, it may and usually does continue loading and playing.

For what it's worth, I ran your example in Chrome and saw no such error/warning because it did not happen to stall during load/play.

Regardless, I'm going to fix the issue.

Cheers,
Patrick

Posted on July 30, 2012 at 9:21 AM

jfroco

jfroco
Total Posts: 10
Joined: April 14, 2012

Re: Sound in HTML5: this.jeashAudio.load() - Uncaught TypeError: Cannot call method 'load' of null

Thank you!!!

(You have to press a couple of times to get the error)

Posted on July 31, 2012 at 9:43 PM