Skip to main content
Participant
May 14, 2013
Question

Problem mit Soundchannel in Air

  • May 14, 2013
  • 1 reply
  • 325 views

Hallo, vieleicht kann mir jemand weiterhelfen:

also ich krieg einen NullPointer-Fehler wenn ich diesen Code ausführe, und zwar ist musicChannel NULL.

Dieser Fehler passiert nur, wenn am PC keine Boxen oder Headphones angeschlossen sind.

Sind boxen dran funktioniert es einwandfrei.

var musicObject:Sound = event.target.content;

if(musicObject != null){

                trace("play sound with id "+musicID);

                musicChannel = musicObject.play();

                musicChannel.addEventListener(Event.SOUND_COMPLETE, loopSound);

}

Jetzt ist das Problem, das mein Programm in Air auch auf PCs ohne Boxen laufen muss.

Kann ich da irgendwie nen failsave für den Fall einbauen?

This topic has been closed for replies.

1 reply

Inspiring
May 15, 2013

how about youi catch the error and alert the user with a message?

if(musicObject != null){

                 //do regular stuff

}

else{

     //show a text like "Please connect a Headphone to proceed"

}