Example #1
0
 private void release(boolean all) {
   if (mPlayer != null) {
     if (mListener != null) mListener.onCloseStart();
     mPlayer.reset();
     mInitialized = false;
     mPrepared = false;
     mVideoSizeKnown = false;
     if (mListener != null) mListener.onCloseComplete();
   }
   if (all) {
     mListener = null;
     mUri = null;
   }
 }
Example #2
0
 public boolean initialize(
     Uri filePath,
     String displayName,
     boolean saveUri,
     float startPos,
     VPlayerListener listener,
     int parentId,
     boolean isHWCodec) {
   if (mPlayer == null) vplayerInit(isHWCodec);
   mTitle = displayName;
   mListener = listener;
   mOldUri = mUri;
   mUri = filePath;
   mSeekTo = startPos;
   mMediaId = -1;
   mLastAudioTrack = -1;
   mLastSubTrackId = -1;
   mLastSubTrack = "";
   setMediaTrack();
   Log.i("%s ==> %s, %s, %s, %s", mOldUri, mUri, mInitialized, mPrepared, mVideoSizeKnown);
   mFromNotification = mInitialized && mUri != null && mUri.equals(mOldUri);
   mListener.onOpenStart();
   if (!mFromNotification) openVideo();
   else openSuccess();
   return mInitialized;
 }
Example #3
0
 @Override
 public boolean onInfo(MediaPlayer arg0, int arg1, int arg2) {
   switch (arg1) {
     case MediaPlayer.MEDIA_INFO_BUFFERING_START:
       if (mListener != null) mListener.onBufferStart();
       else mPlayer.pause();
       break;
     case MediaPlayer.MEDIA_INFO_BUFFERING_END:
       if (mListener != null) mListener.onBufferComplete();
       else mPlayer.start();
       break;
     case MediaPlayer.MEDIA_INFO_DOWNLOAD_RATE_CHANGED:
       if (mListener != null) mListener.onDownloadRateChanged(arg2);
       break;
   }
   return true;
 }
Example #4
0
 @Override
 public void onCompletion(MediaPlayer arg0) {
   if (mListener != null) {
     mListener.onPlaybackComplete();
   } else {
     release(true);
   }
 }
Example #5
0
 private void openSuccess() {
   mInitialized = true;
   if (!mFromNotification && mSeekTo > 0 && mSeekTo < 1) seekTo(mSeekTo);
   mSeekTo = -1;
   mListener.onOpenSuccess();
   if (!mFromNotification) {
     setSubEncoding(VP.DEFAULT_SUB_ENCODING);
     if (mUri != null) mSubPaths = getSubFiles(mUri.getPath());
     if (mSubPaths != null) setSubPath(FileUtils.getCanonical(new File(mSubPaths[0])));
     setSubShown(VP.DEFAULT_SUB_SHOWN);
   }
 }
Example #6
0
 @Override
 public void onTimedTextUpdate(byte[] pixels, int width, int height) {
   if (mListener != null) mListener.onSubChanged(pixels, width, height);
 }
Example #7
0
 @Override
 public void onTimedText(String text) {
   if (mListener != null) mListener.onSubChanged(text);
 }
Example #8
0
 @Override
 public boolean onError(MediaPlayer arg0, int arg1, int arg2) {
   mListener.onOpenFailed();
   return true;
 }
Example #9
0
 @Override
 public void onVideoSizeChanged(MediaPlayer arg0, int arg1, int arg2) {
   mVideoSizeKnown = true;
   if (mListener != null) mListener.onVideoSizeChanged(arg1, arg2);
 }