현재 사용자가 종료 할 때까지 URL을 스트리밍하는 간단한 오디오 플레이어를 작성하려고합니다. 멋진 것은 없지만 MediaPlayer의 onInfo 메서드를 사용하여 메타 데이터 업데이트 플래그를 기다리고 있습니다. 미디어 플레이어 개체를 만드는 데 다음 코드가 있습니다.OnInfoListener가 실행되지 않습니다. Ever
/**
* Creates a new media player and attempts to prepare it.
*/
private void createPlayer(){
Log.v(TAG, "Now in createPlayer()");
if(mPlayer==null){
Log.i(TAG, "No existing media player found, creating.");
mPlayer=new MediaPlayer();
mPlayer.setOnErrorListener(this);
mPlayer.setOnInfoListener(new OnInfoListener() {
public boolean onInfo(MediaPlayer mp, int what, int extra) {
Log.w(TAG,"---Got some info!---");
return false;
}
});
mPlayer.setOnPreparedListener(this);
mPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
} else {
Log.i(TAG, "Found an existing media player. Doing nothing.");
}
try{
mPlayer.setDataSource(mStreamUri);
mPlayer.prepareAsync();
Log.i(TAG, "Just sent the media player a prepareAsync()");
}catch(Exception e){
Log.e(TAG,"Caught exception while trying to set up media player.");
}
}
나는의 OnError 불을 참조 아직, 그러나 나는 또한 사실 때문에 내 응용 프로그램의 단순성의 오류를 얻기 위해 아직 가지고 있지만, 물론 잘 작동 OnPrepare입니다. 위의 코드와 같은 인라인 메서드는 물론 클래스와 함께 구현하려고 시도했지만 아무 일도 일어나지 않습니다.
나는 그것이 사실 이었으면 좋겠다. 설명서에 나온 내용을 알고 있지만 안드로이드입니다. 소스 코드를 살펴보십시오. if (mOnInfoListener! = null) { mOnInfoListener.onInfo (mMediaPlayer, msg.arg1, msg.arg2); }'. 당신이 무엇을 돌려 주든 상관하지 않습니다. 그것을 확인하거나 어디서나 저장하지 않습니다. – ajacian81