简体   繁体   English

适用于Android的音频播放器应用

[英]audio player app for android

hi i have created a new mp3 player app for my owm. 嗨,我为我的owm创建了一个新的mp3播放器应用。 In that i am playing songs from a folder where its been stored, the problem is when one song is in play and when i click the next song both gets played, i want the other one to be stopped. 因为我正在从存储它的文件夹中播放歌曲,所以问题是当播放一首歌曲时,当我单击下一首歌曲时都播放了,我希望停止播放另一首歌曲。 the following is my code 以下是我的代码

lv.setOnItemClickListener(new OnItemClickListener() 
    {
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) 
        {
            Log.e("", "aaaaa "+arg2);

            if(arg2==0)
            {
             mplayer = MediaPlayer.create(aply.this, R.raw.a);
             mplayer.start();
            }
            else
            {               
             mplayer = MediaPlayer.create(aply.this, R.raw.download);
             mplayer.start();
            }

            mplayer.start();
            }
        });

pls help me in this.... 请帮助我。

you can check the playing status, if it is playing you have to stop the player and reset the contents and issue the command Play. 您可以检查播放状态,如果正在播放,则必须停止播放器并重置内容并发出“播放”命令。

if (mplayer.isPlaying()) {
    mp.stop();
}
mplayer.reset();
mplayer.setDataSource(abs_filepath);//set the path
mplayer.prepare();
mplayer.start();

above a sample code 在示例代码之上

Don't you want a check like this: 您不需要这样的支票:

if (mplayer != null && mplayer.isPlaying()) {
    mplayer.stop();
}

at some point before you start your next song? 在开始下一首歌之前的某个时候?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM