开发者

how to play audio as background in blackberry

开发者 https://www.devze.com 2023-02-15 23:45 出处:网络
I have created Player object as player = Manager.createPlayer(inputStream,\"audio/mpeg\"); and plays the audio as

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 obj开发者_运维技巧ect as singleton. I am using 4.7 blackberry api.Can someone please tell me how all these will possible?

thanks

venu


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;
}


Take a look at the multi-part blog post by Tim Windsor from RIM on running applications in the background.

  • Part 1
  • Part 2
  • Part 3
  • Part 4


Basically you need to override the behaviour of the back button and just send your app to background without closing it.Then the player will continue to play. There are many resources and tutorials on this. Maybe something from the links @Ted Hopp posted might help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消