[英]How to continuously play music
I want a simple app that when launched starts playing a music and continiously runs a gif animation, how can I do it, I can't get the mediaplayer to start.. This is what I have so far 我想要一个简单的应用程序,当启动时开始播放音乐并连续运行gif动画,我怎么能这样做,我无法让媒体播放器启动..这就是我到目前为止所拥有的
public class Main extends Activity {
MediaPlayer music;
AnimationDrawable background;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
music = MediaPlayer.create(Main.this, R.raw.thesong);
}
}
You're missing 2 lines below your new MediaPlayer instance: 您在新的MediaPlayer实例下面缺少2行:
music = MediaPlayer.create(Main.this, R.raw.thesong);
music.setLooping(true);
music.start();
Not that this matter much, you should really be staying off the main UI thread to play your music, which you're not. 这不重要,你应该真的远离主UI线程播放你的音乐,你不是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.