如何在黑莓手机中播放音频作为背景
我创建了 Player 对象,
player = Manager.createPlayer(inputStream,"audio/mpeg");
时播放音频
player.realize(); player.prefetch(); player.start();
并在开始播放流 。这里的inputstream
指的是直播地址。现在我的问题是,当我单击后退按钮时,应用程序将关闭,以便播放器也将停止播放。但即使应用程序关闭,我也需要在后台播放音频,并且启动应用程序后我不想再次初始化 Player
对象,为此我必须维护 Player
作为单例对象。我正在使用 4.7 黑莓 api。有人可以告诉我这一切是如何实现的吗?
谢谢
维努
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
重写 Screen 类中的“onClose()”方法以捕获关闭事件并将您的应用程序置于后台:
Override the "onClose()" method in your Screen class to catch the close event and put your app in the background:
查看 RIM 的 Tim Windsor 撰写的有关在后台运行应用程序的多部分博客文章。
Take a look at the multi-part blog post by Tim Windsor from RIM on running applications in the background.
基本上,您需要覆盖后退按钮的行为,并将您的应用程序发送到后台而不关闭它。然后播放器将继续播放。有很多关于这方面的资源和教程。也许 @Ted Hopp 发布的链接中的某些内容可能对您有帮助。
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.