Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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"
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now