Sto provando ad ascoltare OnInfoListener di un mediaplayer che ho creato per ottenere quando il buffering inizia e finisce.OnInfoListener non viene mai chiamato
Per qualche motivo l'evento non si accende mai.
Questa è la mia fase di inizializzazione codice
private void initPlayer(Surface s){
mPlayer = new MediaPlayer();
mPlayer.setSurface(s);
mPlayer.setOnCompletionListener(this);
mPlayer.setOnErrorListener(this);
mPlayer.setOnInfoListener(this);
mPlayer.setOnPreparedListener(this);
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mPlayer.setDataSource(file_url);
mPlayer.prepare();
} catch (IllegalArgumentException e) {
OnError(PLAYER_ERRORS.player_not_loaded, e.getMessage() + "");
} catch (SecurityException e) {
OnError(PLAYER_ERRORS.player_not_loaded, e.getMessage() + "");
} catch (IllegalStateException e) {
OnError(PLAYER_ERRORS.player_not_loaded, e.getMessage() + "");
} catch (IOException e) {
OnError(PLAYER_ERRORS.no_connection, e.getMessage() + "");
}
}
E questo è il mio ascoltatore
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
if(what == MediaPlayer.MEDIA_INFO_BUFFERING_START)
{
OnEvent(PLAYER_EVENT.buffering_start);
}
else if(what == MediaPlayer.MEDIA_INFO_BUFFERING_END)
{
OnEvent(PLAYER_EVENT.buffering_end);
OnGotDuration(getDuration());
}
return what == MediaPlayer.MEDIA_INFO_BUFFERING_START || what == MediaPlayer.MEDIA_INFO_BUFFERING_END;
}
Per favore qualcuno può aiutarmi a capire perché sta succedendo questo? Grazie
Stesso issu per me = ( –
è il file che si sta tentando di riprodurre è locale? – Desert
No, si tratta di un flusso di file HLS da un server di terze parti – orelzion