Java Code Examples for android.media.MediaPlayer#setOnSeekCompleteListener()
The following examples show how to use
android.media.MediaPlayer#setOnSeekCompleteListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaPlayerImpl.java From MediaSDK with Apache License 2.0 | 6 votes |
public MediaPlayerImpl(Context context, PlayerAttributes attributes) { super(context, attributes); synchronized (LOCK) { mPlayer = new MediaPlayer(); } mContext = context.getApplicationContext(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mPlayer.setOnCompletionListener(this); mPlayer.setOnErrorListener(this); mPlayer.setOnInfoListener(this); mPlayer.setOnPreparedListener(this); mPlayer.setOnSeekCompleteListener(this); mPlayer.setOnVideoSizeChangedListener(this); mPlayer.setOnBufferingUpdateListener(this); }
Example 2
Source File: OBAudioPlayer.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
public void startPlayingAtTimeVolume(AssetFileDescriptor afd, long fr,float vol) { if (isPlaying()) stopPlaying(); volume = vol; fromTime = fr; player = new MediaPlayer(); player.setOnPreparedListener(this); player.setOnSeekCompleteListener(this); player.setOnCompletionListener(this); try { state = OBAP_PREPARING; player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); player.prepareAsync(); } catch (Exception e) { e.printStackTrace(); setState(OBAP_IDLE); return; } }
Example 3
Source File: MediaPlayerImpl.java From dcs-sdk-java with Apache License 2.0 | 6 votes |
public MediaPlayerImpl() { mMediaPlayer = new MediaPlayer(); // set audio stream type mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setOnBufferingUpdateListener(bufferingUpdateListener); mMediaPlayer.setOnErrorListener(errorListener); mMediaPlayer.setOnPreparedListener(preparedListener); mMediaPlayer.setOnCompletionListener(completionListener); mMediaPlayer.setOnSeekCompleteListener(seekCompleteListener); // 不同的音频源,此回调有的不回调!!! // mMediaPlayer.setOnInfoListener(infoListener); // 读取音量和静音的数据 currentVolume = (float) MediaPlayerPreferenceUtil.get(context, KEY_SP_VOLUME, 0.8f); isMute = (boolean) MediaPlayerPreferenceUtil.get(context, KEY_SP_MUTE, false); // LinkedList mediaPlayerListeners = Collections.synchronizedList(new LinkedList<IMediaPlayer.IMediaPlayerListener>()); posHandler = new PosHandler(Looper.getMainLooper()); // 来电监听 telephonyManager = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE); telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); }
Example 4
Source File: AndroidAudioPlayer.java From AntennaPod-AudioPlayer with Apache License 2.0 | 6 votes |
public AndroidAudioPlayer(org.antennapod.audio.MediaPlayer owningMediaPlayer, Context context) { super(owningMediaPlayer, context); mp = new MediaPlayer(); if (mp == null) { throw new IllegalStateException("Did not instantiate MediaPlayer successfully"); } mp.setOnBufferingUpdateListener(this.onBufferingUpdateListener); mp.setOnCompletionListener(this.onCompletionListener); mp.setOnErrorListener(this.onErrorListener); mp.setOnInfoListener(this.onInfoListener); Log.d(AMP_TAG, "Setting prepared listener to this.onPreparedListener"); mp.setOnPreparedListener(this.onPreparedListener); mp.setOnSeekCompleteListener(this.onSeekCompleteListener); }
Example 5
Source File: JZMediaSystem.java From JZVideoDemo with MIT License | 5 votes |
@Override public void prepare() { try { mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); if (dataSourceObjects.length > 1) { mediaPlayer.setLooping((boolean) dataSourceObjects[1]); } mediaPlayer.setOnPreparedListener(JZMediaSystem.this); mediaPlayer.setOnCompletionListener(JZMediaSystem.this); mediaPlayer.setOnBufferingUpdateListener(JZMediaSystem.this); mediaPlayer.setScreenOnWhilePlaying(true); mediaPlayer.setOnSeekCompleteListener(JZMediaSystem.this); mediaPlayer.setOnErrorListener(JZMediaSystem.this); mediaPlayer.setOnInfoListener(JZMediaSystem.this); mediaPlayer.setOnVideoSizeChangedListener(JZMediaSystem.this); mediaPlayer.setVolume(0f, 0f); Class<MediaPlayer> clazz = MediaPlayer.class; Method method = clazz.getDeclaredMethod("setDataSource", String.class, Map.class); if (dataSourceObjects.length > 2) { method.invoke(mediaPlayer, currentDataSource.toString(), dataSourceObjects[2]); } else { method.invoke(mediaPlayer, currentDataSource.toString(), null); } mediaPlayer.prepareAsync(); } catch (Exception e) { e.printStackTrace(); } }
Example 6
Source File: OBVideoPlayer.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
public void startPlayingAtTime(AssetFileDescriptor afd, long fr, MediaPlayer.OnPreparedListener preparedListener, MediaPlayer.OnCompletionListener completionListener) { if(afd == null || activityPaused ) return; condition = playerLock.newCondition(); fromTime = fr; player = new MediaPlayer(); player.setSurface(surface); //surface.release(); player.setOnPreparedListener(preparedListener); player.setOnCompletionListener(completionListener); player.setOnSeekCompleteListener(this); player.setOnErrorListener(this); player.setOnVideoSizeChangedListener(this); try { player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); player.prepareAsync(); } catch (Exception e) { e.printStackTrace(); return; } }
Example 7
Source File: OBVideoPlayer.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
public void prepareForPlaying(AssetFileDescriptor afd, long atTime, OBUtils.RunLambda seekCompletion) { if(afd == null || activityPaused ) return; playAfterPrepare = false; condition = playerLock.newCondition(); fromTime = atTime; if(seekCompletion != null) this.seekCompletionBlock = seekCompletion; player = new MediaPlayer(); player.setSurface(surface); //surface.release(); player.setOnPreparedListener(this); player.setOnCompletionListener(this); player.setOnSeekCompleteListener(this); player.setOnErrorListener(this); player.setOnVideoSizeChangedListener(this); try { player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); player.prepareAsync(); } catch (Exception e) { e.printStackTrace(); return; } }
Example 8
Source File: VideoViewTV.java From letv with Apache License 2.0 | 5 votes |
private void deadListener(MediaPlayer mMediaPlayer) { if (mMediaPlayer != null) { mMediaPlayer.setOnSeekCompleteListener(null); mMediaPlayer.setOnInfoListener(null); mMediaPlayer.setOnPreparedListener(null); mMediaPlayer.setOnVideoSizeChangedListener(null); mMediaPlayer.setOnCompletionListener(null); mMediaPlayer.setOnErrorListener(null); mMediaPlayer.setOnBufferingUpdateListener(null); } }
Example 9
Source File: AudioActivity.java From allenglish with Apache License 2.0 | 5 votes |
private void initMediaPlayer() { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnBufferingUpdateListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnSeekCompleteListener(this); }
Example 10
Source File: VideoView.java From Spectaculum with Apache License 2.0 | 5 votes |
private void openVideo() { if (mUri == null || mInputSurfaceHolder == null) { // not ready for playback yet, will be called again later return; } release(); try { mPlayer = new MediaPlayer(); mPlayer.setSurface(getInputHolder().getSurface()); mPlayer.setOnPreparedListener(mPreparedListener); mPlayer.setOnVideoSizeChangedListener(mSizeChangedListener); mPlayer.setOnSeekCompleteListener(mSeekCompleteListener); mPlayer.setOnCompletionListener(mCompletionListener); mPlayer.setOnErrorListener(mErrorListener); mPlayer.setOnInfoListener(mInfoListener); mPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener); mCurrentBufferPercentage = 0; mPlayer.setDataSource(getContext(), mUri, mHeaders); mCurrentState = STATE_PREPARING; mPlayer.prepareAsync(); } catch (Exception e) { Log.e(TAG, "video open failed", e); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; mErrorListener.onError(mPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); } }
Example 11
Source File: SystemImplMediaPlayer.java From android-jungle-mediaplayer with Apache License 2.0 | 5 votes |
private void init() { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setOnErrorListener(mOnErrorListener); mMediaPlayer.setOnPreparedListener(mOnPreparedListener); mMediaPlayer.setOnCompletionListener(mOnCompletionListener); mMediaPlayer.setOnSeekCompleteListener(mOnSeekCompletionListener); mMediaPlayer.setOnBufferingUpdateListener(mOnBufferingUpdateListener); mMediaPlayer.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener); }
Example 12
Source File: NativeVideoDelegate.java From ExoMedia with Apache License 2.0 | 5 votes |
protected void initMediaPlayer() { mediaPlayer = new MediaPlayer(); mediaPlayer.setOnInfoListener(internalListeners); mediaPlayer.setOnErrorListener(internalListeners); mediaPlayer.setOnPreparedListener(internalListeners); mediaPlayer.setOnCompletionListener(internalListeners); mediaPlayer.setOnSeekCompleteListener(internalListeners); mediaPlayer.setOnBufferingUpdateListener(internalListeners); mediaPlayer.setOnVideoSizeChangedListener(internalListeners); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setScreenOnWhilePlaying(true); }
Example 13
Source File: GPlayer.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gplayer); mAudioManager = (AudioManager) getSystemService(Service.AUDIO_SERVICE); surfaceView = (SurfaceView) findViewById(R.id.gplayer_surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mMediaPlayer = new MediaPlayer(); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnInfoListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnSeekCompleteListener(this); mMediaPlayer.setOnVideoSizeChangedListener(this); initControl(); Intent intent = getIntent(); playURI = intent.getStringExtra("playURI"); if (!TextUtils.isEmpty(playURI)) { setUri(playURI); } setTitle(intent); currentDisplay = getWindowManager().getDefaultDisplay(); registerBrocast(); }
Example 14
Source File: StandardMediaPlayer.java From android-openslmediaplayer with Apache License 2.0 | 5 votes |
public StandardMediaPlayer() { try { mNextMediaPlayerRef = new WeakReference<StandardMediaPlayer>(null); mUsingNuPlayer = NuPlayerDetector.isUsingNuPlayer(); mHandler = new InternalHandler(this); mState = new MediaPlayerStateManager(); mPlayer = new MediaPlayer(); mSuperEventHandler = new WeakReference<Handler>(obtainSuperMediaPlayerInternalEventHandler(mPlayer)); if (LOCAL_LOGD) { Log.d(TAG, "[" + System.identityHashCode(mPlayer) + "] Create MediaPlayer instance"); } mPlayer.setOnCompletionListener(mHookOnCompletionListener); mPlayer.setOnPreparedListener(mHookOnPreparedListener); mPlayer.setOnSeekCompleteListener(mHookOnSeekCompleteListener); mPlayer.setOnBufferingUpdateListener(mHookOnBufferingUpdateListener); mPlayer.setOnInfoListener(mHookOnInfoListener); mPlayer.setOnErrorListener(mHookOnErrorListener); } catch (Exception e) { Log.e(TAG, makeUnexpectedExceptionCaughtMessage("StandardMediaPlayer()"), e); // call release() method to transit to END state releaseInternal(); } }
Example 15
Source File: StdVideoView.java From jellyfin-androidtv with GNU General Public License v2.0 | 4 votes |
@Override public void setOnSeekCompleteListener(MediaPlayer mp, MediaPlayer.OnSeekCompleteListener listener) { mp.setOnSeekCompleteListener(listener); }
Example 16
Source File: AndroidMediaPlayer.java From K-Sonic with MIT License | 4 votes |
public AndroidMediaPlayer(com.aocate.media.MediaPlayer owningMediaPlayer, Context context) { super(owningMediaPlayer, context); mp = new MediaPlayer(); // final ReentrantLock lock = new ReentrantLock(); // Handler handler = new Handler(Looper.getMainLooper()) { // @Override // public void handleMessage(Message msg) { // Log.d(AMP_TAG, "Instantiating new AndroidMediaPlayer from Handler"); // lock.lock(); // if (mp == null) { // mp = new MediaPlayer(); // } // lock.unlock(); // } // }; // // long endTime = System.currentTimeMillis() + TIMEOUT_DURATION_MS; // // while (true) { // // Retry messages until mp isn't null or it's time to give up // handler.sendMessage(handler.obtainMessage()); // if ((mp != null) // || (endTime < System.currentTimeMillis())) { // break; // } // try { // Thread.sleep(50); // } catch (InterruptedException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // } if (mp == null) { throw new IllegalStateException("Did not instantiate android.media.MediaPlayer successfully"); } mp.setOnBufferingUpdateListener(this.onBufferingUpdateListener); mp.setOnCompletionListener(this.onCompletionListener); mp.setOnErrorListener(this.onErrorListener); mp.setOnInfoListener(this.onInfoListener); Log.d(AMP_TAG, " ++++++++++++++++++++++++++++++++ Setting prepared listener to this.onPreparedListener"); mp.setOnPreparedListener(this.onPreparedListener); mp.setOnSeekCompleteListener(this.onSeekCompleteListener); }