Skip to main content
Known Participant
June 20, 2013
Answered

AIR 3.7.0.2090 SOUND Issue ONLY at 1st Launch

  • June 20, 2013
  • 1 reply
  • 811 views

Dear developers, I am hoping you can assist me with this.

The app I have been developing is close to launch date.  However, the first time launching the app after installing, the game theme song cuts out after about 0.5 to 1 second.  If I close the app and reopen it, the theme song plays normally. 

This seems like a small issue but first impressions for an app are important and I need this song to play at launch after the app has been installed for the first time.

This problem is occuring on a Samsung 10.1 tablet running Android 4.0.4.

I can make a work around that would not play the song at all on first launch after installation, but would rather not do this.

Any ideas?

Thank you,

Justin

This topic has been closed for replies.
Correct answer Mark.fromOP

Justin does the storedata as you call it pertain to the sound in the way? Are you storing the a user preference for music on or off option?

I have a feeling you have a variable that is stored to sharedObjects but when you launch the app the option to play the music is controlled by a variable that is not loaded yet so it returns a null somewhere and does not know how to handle the sounds.

As a general tip I would leave a few blank frames in front of your main app frames this way you can load some one time data / variables out front and never return to that frame until the app is relaunched from a complete close.It's just easier to track, also if you are bad with Classes like myself and do a lot of timeline code you can create class like functions on the first frame that you can use later in your app such as sound controls or advertisement functions.

Try this on the first frame and see if it plays

var musicChannel1:SoundChannel = new SoundChannel();

var Main_theme_song:theme_song = new theme_song();

musicChannel1 = Main_theme_song.play();

or if you want the music to loop

musicChannel1 = Main_theme_song.play(0,9999);

to stop the music run this function

musicChannel1.stop();

1 reply

Mark.fromOP
Inspiring
June 21, 2013

Seems like a code issue, please post the function you are using to load/play the sound.

Known Participant
June 21, 2013

Dear Mark, thank you for your response.  I do not program all my code on a single frame, so maybe this is the reason why.  Rather, I have split up the code in a few frames.

Because I bounce back in the game to the first frame (which contains all the info for the start of the program), I start off with the code

SoundMixer.stopall() // to stop any sounds that were playing previous to go back into the first frame

var Main_theme_song:Sound=new theme_song;
Main_theme_song.play();

So it only ever fails right at first launch.....if I go to the next part of the game and then go back to the opening frame.....it plays.  If I close the game completely and relaunch it.....it plays.....it only doesn't play during the very first launch.

I never have had this problem on the desktop.  When I first came across this problem on the tablet, I did not really care about it.  But the closer I get to launch, the more it is bothering me.  I want everything to be as perfect as possible. 

During this first frame, I also check to see if a there is any storeddata...if not create a file with some initial values.  At this point if need be, I could trigger a variable to not play the music at all if it is the first time executing the program and then play on following executions.

Thanks Mark for replying,

Justin

Mark.fromOP
Mark.fromOPCorrect answer
Inspiring
June 21, 2013

Justin does the storedata as you call it pertain to the sound in the way? Are you storing the a user preference for music on or off option?

I have a feeling you have a variable that is stored to sharedObjects but when you launch the app the option to play the music is controlled by a variable that is not loaded yet so it returns a null somewhere and does not know how to handle the sounds.

As a general tip I would leave a few blank frames in front of your main app frames this way you can load some one time data / variables out front and never return to that frame until the app is relaunched from a complete close.It's just easier to track, also if you are bad with Classes like myself and do a lot of timeline code you can create class like functions on the first frame that you can use later in your app such as sound controls or advertisement functions.

Try this on the first frame and see if it plays

var musicChannel1:SoundChannel = new SoundChannel();

var Main_theme_song:theme_song = new theme_song();

musicChannel1 = Main_theme_song.play();

or if you want the music to loop

musicChannel1 = Main_theme_song.play(0,9999);

to stop the music run this function

musicChannel1.stop();