我在媒体播放器上播放mp3,它在你的屏幕打开时播放连续播放或者你正在进行多任务处理但是当你关闭屏幕时它不会连续播放音频,它会停留很多次。我得到了这个“信息/警告(702,0)“登录日志猫
我尝试了mp.setWakeMode(getBaseContext(),PowerManager.FULL_WAKE_LOCK);
我正在使用服务播放音频流,但仍然卡住了。
public class myPlayService extends Service{
MediaPlayer mp;
String link ="http://85.23.194.72:70/mp3/str";
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
mp = new MediaPlayer();
try {
mp.setDataSource(link);
mp.setWakeMode(getBaseContext(),PowerManager.FULL_WAKE_LOCK);
mp.prepareAsync();
mp.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.start();
}
});
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}@Override public void onDestroy() { mp.stop();mp.release();}}