Android Music App问题 [英] Android Music App problems
问题描述
你好,
我正在制作一个播放音乐的应用程序.我使用了媒体播放器类并使其正常运行.我还通过按下菜单按钮添加了额外的功能.
第一个问题:
我开始播放音乐...我有另一个屏幕,借助意图可以跳至该屏幕(按下菜单项时).问题是当我有意跳回mymedia播放器时,我可以重新开始播放音乐,它无法返回到我跳到另一个活动导致同时播放2个音乐文件的状态.
按下菜单按钮后如何返回离开应用程序的状态?
第二个问题:
我希望媒体播放器在按下后退"按钮时在后台播放,并且当我再次启动该应用程序时,保持在与我在按下后退"按钮时将其保留的状态相同.
Hello,
I am making an application which plays some music. I used the Media player class and got it working. I also added extra function via menu button pressed.
1st problem:
I start the music... I have another screen to which i jump with the help of an intent (when menu item pressed). The problem is when I jump back with an intent to mymedia player, i can start the music all over again, it doesn''t return to the state in which it was when I jumped to another activity resulting in 2 music files simultaneously playing.
How can I return to the state I left the application when I pressed the menu button?
2nd problem:
I want my media player playing in the background when I press the back button, and when I start the application again, to be in the same state I left it when I pressed the back button.
Thanks for your help in advance!
推荐答案
您必须保存按钮的状态.
为此设置立面(立面模式@ Wikipedia [秘密类或我如何停止计数并喜欢枚举器" [
You have to save the state of your buttons.
Set up a facade for this ( Facade Pattern @ wikipedia[^] ) and store the state of all buttons, menues, and what else needs to be remembered in there (also see the article from Nagy "The Secret Classes or How I Stopped Counting and Loved the Enumerator"[^]).
The facade has to be set up when the app starts and should be disposed when the app exits.
regards
Torsten
我在这里,但是请检查您是否在回叫时无意中创建了媒体播放器的新实例.
I am guessing here, but check that you are not inadvertently creating a new instance of the media player when you call back to it.
这篇关于Android Music App问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!