Ejemplo n.º 1
0
  public long getCurrentPosition() {
    if (nativeMode) return mVideoView.getCurrentPosition();

    long time = mVlcPlayer.getTime();
    if (mForcedTime != -1 && mLastTime != -1) {
      /* XXX: After a seek, mLibVLC.getTime can return the position before or after
       * the seek position. Therefore we return mForcedTime in order to avoid the seekBar
       * to move between seek position and the actual position.
       * We have to wait for a valid position (that is after the seek position).
       * to re-init mLastTime and mForcedTime to -1 and return the actual position.
       */
      if (mLastTime > mForcedTime) {
        if (time <= mLastTime && time > mForcedTime) mLastTime = mForcedTime = -1;
      } else {
        if (time > mForcedTime) mLastTime = mForcedTime = -1;
      }
    }
    return mForcedTime == -1 ? time : mForcedTime;
  }
Ejemplo n.º 2
0
  public long seekTo(long pos) {
    if (nativeMode) {
      Long intPos = pos;
      mVideoView.seekTo(intPos.intValue());
      return pos;
    } else {
      if (mVlcPlayer == null || !mVlcPlayer.isSeekable()) return -1;
      mForcedTime = pos;
      mLastTime = mVlcPlayer.getTime();
      TvApp.getApplication().getLogger().Info("VLC length in seek is: " + mVlcPlayer.getLength());
      try {
        if (getDuration() > 0) mVlcPlayer.setPosition((float) pos / getDuration());
        else mVlcPlayer.setTime(pos);

        return pos;

      } catch (Exception e) {
        TvApp.getApplication().getLogger().ErrorException("Error seeking in VLC", e);
        Utils.showToast(mActivity, "Unable to seek");
        return -1;
      }
    }
  }