我在媒体播放器上流式传输 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();}}