コード例 #1
0
  /**
   * Sets if the audio position should be overridden, allowing the time to be restarted at will.
   * This is useful for streaming audio where the audio doesn't have breaks between songs.
   *
   * @param override True if the position should be overridden
   */
  public void overridePosition(boolean override) {
    if (override) {
      overriddenPositionStopWatch.start();
    } else {
      overriddenPositionStopWatch.stop();
    }

    overridePosition = override;
  }
コード例 #2
0
ファイル: EMVideoView.java プロジェクト: eygraber/ExoMedia
  /**
   * Retrieves the current position of the audio playback. If an audio item is not currently in
   * playback then the value will be 0. This should only be called after the item is prepared (see
   * {@link #setOnPreparedListener(OnPreparedListener)})
   *
   * @return The millisecond value for the current position
   */
  public int getCurrentPosition() {
    if (overridePosition) {
      return positionOffset + overriddenPositionStopWatch.getTimeInt();
    }

    return positionOffset + videoViewImpl.getCurrentPosition();
  }
コード例 #3
0
ファイル: EMVideoView.java プロジェクト: eygraber/ExoMedia
  /**
   * Stops the playback and releases all resources attached to this EMVideoView. This should not be
   * called manually unless {@link #setReleaseOnDetachFromWindow(boolean)} has been set.
   */
  public void release() {
    videoControls = null;
    stopPlayback();
    overriddenPositionStopWatch.stop();

    videoViewImpl.release();
  }
コード例 #4
0
  /**
   * Retrieves the current position of the audio playback. If an audio item is not currently in
   * playback then the value will be 0. This should only be called after the item is prepared (see
   * {@link #setOnPreparedListener(android.media.MediaPlayer.OnPreparedListener)})
   *
   * @return The millisecond value for the current position
   */
  public long getCurrentPosition() {
    if (overridePosition) {
      return positionOffset + overriddenPositionStopWatch.getTime();
    }

    if (!listenerMux.isPrepared()) {
      return 0;
    }

    if (!useExo) {
      return positionOffset + videoView.getCurrentPosition();
    }

    return positionOffset + emExoPlayer.getCurrentPosition();
  }
コード例 #5
0
  @Override
  protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();

    defaultControls = null;
    stopPlayback();
    overriddenPositionStopWatch.stop();

    if (emExoPlayer != null) {
      emExoPlayer.release();
    }

    if (audioCapabilitiesReceiver != null) {
      audioCapabilitiesReceiver.unregister();
      audioCapabilitiesReceiver = null;
    }
  }
コード例 #6
0
 /**
  * Restarts the audio position to the start if the position is being overridden (see {@link
  * #overridePosition(boolean)}). This will be the value specified with {@link
  * #setPositionOffset(int)} or 0 if it hasn't been set.
  */
 public void restartOverridePosition() {
   overriddenPositionStopWatch.reset();
 }