Search code examples
blackberryaudio-player

how to play audio as background in blackberry


I have created Player object as

player = Manager.createPlayer(inputStream,"audio/mpeg");

and plays the audio as

player.realize(); player.prefetch(); player.start(); 

It starts playing the stream. Here the inputstream refers live streaming url. Now my question is when i click on the back button the application will be closed so that player also will stop the playing. but I need to play the audio in background even the application is closed and after launching the app i dont want to initialize the Player object again,for this i have to maintain the Player object as singleton. I am using 4.7 blackberry api.Can someone please tell me how all these will possible?

thanks
venu


Solution

  • Override the "onClose()" method in your Screen class to catch the close event and put your app in the background:

    public boolean onClose() {
        Application.getApplication().requestBackground();
        return false;
    }