com.google.android.exoplayer2.util.MediaClock Java Examples

The following examples show how to use com.google.android.exoplayer2.util.MediaClock. 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: DefaultMediaClock.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Notifies the media clock that a renderer has been enabled. Starts using the media clock of the
 * provided renderer if available.
 *
 * @param renderer The renderer which has been enabled.
 * @throws ExoPlaybackException If the renderer provides a media clock and another renderer media
 *     clock is already provided.
 */
public void onRendererEnabled(Renderer renderer) throws ExoPlaybackException {
  MediaClock rendererMediaClock = renderer.getMediaClock();
  if (rendererMediaClock != null && rendererMediaClock != rendererClock) {
    if (rendererClock != null) {
      throw ExoPlaybackException.createForUnexpected(
          new IllegalStateException("Multiple renderer media clocks enabled."));
    }
    this.rendererClock = rendererMediaClock;
    this.rendererClockSource = renderer;
    rendererClock.setPlaybackParameters(standaloneClock.getPlaybackParameters());
  }
}
 
Example #2
Source File: DefaultMediaClock.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Notifies the media clock that a renderer has been enabled. Starts using the media clock of the
 * provided renderer if available.
 *
 * @param renderer The renderer which has been enabled.
 * @throws ExoPlaybackException If the renderer provides a media clock and another renderer media
 *     clock is already provided.
 */
public void onRendererEnabled(Renderer renderer) throws ExoPlaybackException {
  MediaClock rendererMediaClock = renderer.getMediaClock();
  if (rendererMediaClock != null && rendererMediaClock != rendererClock) {
    if (rendererClock != null) {
      throw ExoPlaybackException.createForUnexpected(
          new IllegalStateException("Multiple renderer media clocks enabled."));
    }
    this.rendererClock = rendererMediaClock;
    this.rendererClockSource = renderer;
    rendererClock.setPlaybackParameters(standaloneMediaClock.getPlaybackParameters());
    ensureSynced();
  }
}
 
Example #3
Source File: DefaultMediaClock.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Notifies the media clock that a renderer has been enabled. Starts using the media clock of the
 * provided renderer if available.
 *
 * @param renderer The renderer which has been enabled.
 * @throws ExoPlaybackException If the renderer provides a media clock and another renderer media
 *     clock is already provided.
 */
public void onRendererEnabled(Renderer renderer) throws ExoPlaybackException {
  MediaClock rendererMediaClock = renderer.getMediaClock();
  if (rendererMediaClock != null && rendererMediaClock != rendererClock) {
    if (rendererClock != null) {
      throw ExoPlaybackException.createForUnexpected(
          new IllegalStateException("Multiple renderer media clocks enabled."));
    }
    this.rendererClock = rendererMediaClock;
    this.rendererClockSource = renderer;
    rendererClock.setPlaybackParameters(standaloneMediaClock.getPlaybackParameters());
    ensureSynced();
  }
}
 
Example #4
Source File: DefaultMediaClock.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Notifies the media clock that a renderer has been enabled. Starts using the media clock of the
 * provided renderer if available.
 *
 * @param renderer The renderer which has been enabled.
 * @throws ExoPlaybackException If the renderer provides a media clock and another renderer media
 *     clock is already provided.
 */
public void onRendererEnabled(Renderer renderer) throws ExoPlaybackException {
  MediaClock rendererMediaClock = renderer.getMediaClock();
  if (rendererMediaClock != null && rendererMediaClock != rendererClock) {
    if (rendererClock != null) {
      throw ExoPlaybackException.createForUnexpected(
          new IllegalStateException("Multiple renderer media clocks enabled."));
    }
    this.rendererClock = rendererMediaClock;
    this.rendererClockSource = renderer;
    rendererClock.setPlaybackParameters(standaloneMediaClock.getPlaybackParameters());
    ensureSynced();
  }
}
 
Example #5
Source File: DefaultMediaClock.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Notifies the media clock that a renderer has been enabled. Starts using the media clock of the
 * provided renderer if available.
 *
 * @param renderer The renderer which has been enabled.
 * @throws ExoPlaybackException If the renderer provides a media clock and another renderer media
 *     clock is already provided.
 */
public void onRendererEnabled(Renderer renderer) throws ExoPlaybackException {
  MediaClock rendererMediaClock = renderer.getMediaClock();
  if (rendererMediaClock != null && rendererMediaClock != rendererClock) {
    if (rendererClock != null) {
      throw ExoPlaybackException.createForUnexpected(
          new IllegalStateException("Multiple renderer media clocks enabled."));
    }
    this.rendererClock = rendererMediaClock;
    this.rendererClockSource = renderer;
    rendererClock.setPlaybackParameters(standaloneMediaClock.getPlaybackParameters());
    ensureSynced();
  }
}
 
Example #6
Source File: BaseRenderer.java    From K-Sonic with MIT License 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #7
Source File: MediaCodecAudioRenderer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #8
Source File: ExoPlayerImplInternal.java    From K-Sonic with MIT License 4 votes vote down vote up
private void enableRenderers(boolean[] rendererWasEnabledFlags, int enabledRendererCount)
    throws ExoPlaybackException {
  enabledRenderers = new Renderer[enabledRendererCount];
  enabledRendererCount = 0;
  for (int i = 0; i < renderers.length; i++) {
    Renderer renderer = renderers[i];
    TrackSelection newSelection = playingPeriodHolder.trackSelectorResult.selections.get(i);
    if (newSelection != null) {
      enabledRenderers[enabledRendererCount++] = renderer;
      if (renderer.getState() == Renderer.STATE_DISABLED) {
        RendererConfiguration rendererConfiguration =
            playingPeriodHolder.trackSelectorResult.rendererConfigurations[i];
        // The renderer needs enabling with its new track selection.
        boolean playing = playWhenReady && state == ExoPlayer.STATE_READY;
        // Consider as joining only if the renderer was previously disabled.
        boolean joining = !rendererWasEnabledFlags[i] && playing;
        // Build an array of formats contained by the selection.
        Format[] formats = new Format[newSelection.length()];
        for (int j = 0; j < formats.length; j++) {
          formats[j] = newSelection.getFormat(j);
        }
        // Enable the renderer.
        renderer.enable(rendererConfiguration, formats, playingPeriodHolder.sampleStreams[i],
            rendererPositionUs, joining, playingPeriodHolder.getRendererOffset());
        MediaClock mediaClock = renderer.getMediaClock();
        if (mediaClock != null) {
          if (rendererMediaClock != null) {
            throw ExoPlaybackException.createForUnexpected(
                new IllegalStateException("Multiple renderer media clocks enabled."));
          }
          rendererMediaClock = mediaClock;
          rendererMediaClockSource = renderer;
        }
        // Start the renderer if playing.
        if (playing) {
          renderer.start();
        }
      }
    }
  }
}
 
Example #9
Source File: SimpleDecoderAudioRenderer.java    From K-Sonic with MIT License 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #10
Source File: MediaCodecAudioRenderer.java    From K-Sonic with MIT License 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #11
Source File: BaseRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #12
Source File: NoSampleRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #13
Source File: SimpleDecoderAudioRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #14
Source File: MediaCodecAudioRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #15
Source File: BaseRenderer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #16
Source File: NoSampleRenderer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #17
Source File: SimpleDecoderAudioRenderer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #18
Source File: MediaCodecAudioRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #19
Source File: SimpleDecoderAudioRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #20
Source File: NoSampleRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #21
Source File: BaseRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #22
Source File: BaseRenderer.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public MediaClock getMediaClock() {
  return null;
}
 
Example #23
Source File: NoSampleRenderer.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public MediaClock getMediaClock() {
  return null;
}
 
Example #24
Source File: MediaCodecAudioRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #25
Source File: SimpleDecoderAudioRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return this;
}
 
Example #26
Source File: NoSampleRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #27
Source File: BaseRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MediaClock getMediaClock() {
  return null;
}
 
Example #28
Source File: SimpleDecoderAudioRenderer.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public MediaClock getMediaClock() {
  return this;
}
 
Example #29
Source File: MediaCodecAudioRenderer.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public MediaClock getMediaClock() {
  return this;
}
 
Example #30
Source File: Renderer.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * If the renderer advances its own playback position then this method returns a corresponding
 * {@link MediaClock}. If provided, the player will use the returned {@link MediaClock} as its
 * source of time during playback. A player may have at most one renderer that returns a {@link
 * MediaClock} from this method.
 *
 * @return The {@link MediaClock} tracking the playback position of the renderer, or null.
 */
@Nullable
MediaClock getMediaClock();