Ejemplo n.º 1
0
        public void onPrepared(IMediaPlayer mp) {
          DebugLog.d(TAG, "onPrepared");
          mCurrentState = STATE_PREPARED;
          mTargetState = STATE_PLAYING;

          if (mOnPreparedListener != null) mOnPreparedListener.onPrepared(mMediaPlayer);
          if (mMediaController != null) mMediaController.setEnabled(true);
          mVideoWidth = mp.getVideoWidth();
          mVideoHeight = mp.getVideoHeight();

          long seekToPosition = mSeekWhenPrepared;

          if (seekToPosition != 0) seekTo(seekToPosition);
          if (mVideoWidth != 0 && mVideoHeight != 0) {
            setVideoLayout(mVideoLayout);
            if (mSurfaceWidth == mVideoWidth && mSurfaceHeight == mVideoHeight) {
              if (mTargetState == STATE_PLAYING) {
                start();
                if (mMediaController != null) mMediaController.show();
              } else if (!isPlaying() && (seekToPosition != 0 || getCurrentPosition() > 0)) {
                if (mMediaController != null) mMediaController.show(0);
              }
            }
          } else if (mTargetState == STATE_PLAYING) {
            start();
          }
        }
Ejemplo n.º 2
0
        public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
          mSurfaceHolder = holder;
          if (mMediaPlayer != null) {
            mMediaPlayer.setDisplay(mSurfaceHolder);
          }

          mSurfaceWidth = w;
          mSurfaceHeight = h;
          boolean isValidState = (mTargetState == STATE_PLAYING);
          boolean hasValidSize = (mVideoWidth == w && mVideoHeight == h);
          if (mMediaPlayer != null && isValidState && hasValidSize) {
            if (mSeekWhenPrepared != 0) seekTo(mSeekWhenPrepared);
            start();
            if (mMediaController != null) {
              if (mMediaController.isShowing()) mMediaController.hide();
              mMediaController.show();
            }
          }
        }