public void setOnBufferingUpdateListener(OnBufferingUpdateListener l) { this.mOnBufferingUpdateListener = l; }
public void setOnBufferingUpdateListener(OnBufferingUpdateListener listener) { this.mOnBufferingUpdateListener = listener; }
public void setOnBufferingUpdateListener(OnBufferingUpdateListener l) { if (mediaPlayer != null) { this.bufferingUpdateListener = l; this.mediaPlayer.setOnBufferingUpdateListener(this); } else throw new RuntimeException("Media Player is not initialized"); }
public boolean setAudioItem(AudioItem item, OnPreparedListener onPreparedListener, OnSeekCompleteListener onSeekCompleteListener, OnErrorListener onErrorListener, final OnBufferingUpdateListener onBufferingUpdateListener, OnCompletionListener onCompletionListener) { if (onPreparedListener != null) mMediaPlayer.setOnPreparedListener(onPreparedListener); if (onErrorListener != null) mMediaPlayer.setOnErrorListener(onErrorListener); MediaPlayer.OnBufferingUpdateListener bufferListenerProxy = new MediaPlayer.OnBufferingUpdateListener() { public void onBufferingUpdate(MediaPlayer mp, int percent) { if(percent == 100) doneBuffering = true; if (onBufferingUpdateListener != null) onBufferingUpdateListener.onBufferingUpdate(mp, percent); } }; mMediaPlayer.setOnBufferingUpdateListener(bufferListenerProxy); if (onSeekCompleteListener != null) mMediaPlayer.setOnSeekCompleteListener(onSeekCompleteListener); if (onCompletionListener != null) mMediaPlayer.setOnCompletionListener(onCompletionListener); if (getNowPlayingId() != item.getFileId()) { mMediaPlayer.reset(); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mAudioItem = item; String URI = mAudioItem.getFileUrl(); doneBuffering = false; if (mAudioItem.getStatus() == Status.FINISHED) URI = new File(this.getFilesDir(), mAudioItem.getPath()).getAbsolutePath(); bufferListenerProxy.onBufferingUpdate(mMediaPlayer, 100); try { mMediaPlayer.setDataSource(URI); } catch (Exception e) { Log.d(TAG, "failed to load "+URI, e); doneBuffering = true; return false; } wifiLock(); mMediaPlayer.prepareAsync(); } else { if (onPreparedListener!=null) onPreparedListener.onPrepared(mMediaPlayer); } return true; }
void setOnBufferingUpdateListener(OnBufferingUpdateListener onBufferingUpdateListener);