如何在黑莓手机中播放音频作为背景

发布于 2024-10-21 13:02:48 字数 441 浏览 2 评论 0原文

我创建了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

美人如玉 2024-10-28 13:02:48

重写 Screen 类中的“onClose()”方法以捕获关闭事件并将您的应用程序置于后台:

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

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;
}
oО清风挽发oО 2024-10-28 13:02:48

查看 RIM 的 Tim Windsor 撰写的有关在后台运行应用程序的多部分博客文章。

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

勿挽旧人 2024-10-28 13:02:48

基本上,您需要覆盖后退按钮的行为,并将您的应用程序发送到后台而不关闭它。然后播放器将继续播放。有很多关于这方面的资源和教程。也许 @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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文