Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem mit Soundchannel in Air

New Here ,
May 14, 2013 May 14, 2013

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?

TOPICS
ActionScript
310
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 15, 2013 May 15, 2013
LATEST

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"

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines