03-03-2010 11:21 PM
Hello,
I have a little confusing situation here. This is the general flow of my application:
1. Device loads app
2. App calls App() (constructor)
3. App calls new MyScreen()
4. App enters EventDispatcher
Now on MyScreen() I would like to play an mp3 as background music, but I cannot do so presumably because I have not entered the Event Dispatcher. I'm getting a Runtime Exception and some push Modal Screen error or something like that. I tried doing getApplication().invokeLater() in MyScreen() but getApplication() returns null, again presumably because I have not entered event dispatcher.
Quite confused on what I'm supposed to do here. There's nothing much in MyScreen(), just a label and a couple of buttons.
Suggestions? Advice?
Thanks a lot
03-03-2010 11:26 PM
code?
is the mp3 a local file or remote?
03-03-2010 11:28 PM
Do the playing on a separate thread.
03-03-2010 11:57 PM - edited 03-04-2010 12:00 AM
thanks for the quick reply. not much code here. UiApplication class: [code]
public static void main(String[] args) {
MyGame game = new MyGame();
game.enterEventDispatcher();
}
public MyGame() { pushScreen(new Menu()); }
[/code] Menu class: [code]
Menu() {
//add buttons etc etc
playMusic() //play music loads resources and calls Player.start()
}
[/code]
03-04-2010 12:01 AM
Aviator168 wrote:Do the playing on a separate thread.
I thought about this, but not really sure who should start the thread. If I start the thread in Menu() the app still hasn't entered event dispatcher, right?
03-04-2010 12:12 AM
Is your player logic working in other instances?
03-04-2010 12:16 AM
yes it is. i have used it in the next screen that is pushed after user presses on a button in the Menu class, and it works fine.
03-04-2010 08:13 AM
any ideas guys?