Tabnine Logo
C.msToUs
Code IndexAdd Tabnine to your IDE (free)

How to use
msToUs
method
in
com.google.android.exoplayer2.C

Best Java code snippets using com.google.android.exoplayer2.C.msToUs (Showing top 20 results out of 315)

origin: google/ExoPlayer

private MlltSeeker(long[] referencePositions, long[] referenceTimesMs) {
 this.referencePositions = referencePositions;
 this.referenceTimesMs = referenceTimesMs;
 // Use the last reference point as the duration, as extrapolating variable bitrate at the end of
 // the stream may give a large error.
 durationUs = C.msToUs(referenceTimesMs[referenceTimesMs.length - 1]);
}
origin: google/ExoPlayer

private long getNowUnixTimeUs() {
 if (elapsedRealtimeOffsetMs != 0) {
  return C.msToUs(SystemClock.elapsedRealtime() + elapsedRealtimeOffsetMs);
 } else {
  return C.msToUs(System.currentTimeMillis());
 }
}
origin: google/ExoPlayer

/**
 * Returns the duration in microseconds advertised by a media info, or {@link C#TIME_UNSET} if
 * unknown or not applicable.
 *
 * @param mediaInfo The media info to get the duration from.
 * @return The duration in microseconds.
 */
public static long getStreamDurationUs(MediaInfo mediaInfo) {
 long durationMs =
   mediaInfo != null ? mediaInfo.getStreamDuration() : MediaInfo.UNKNOWN_DURATION;
 return durationMs != MediaInfo.UNKNOWN_DURATION ? C.msToUs(durationMs) : C.TIME_UNSET;
}
origin: google/ExoPlayer

@Override
public long getTimeUs(long position) {
 Pair<Long, Long> positionAndTimeMs =
   linearlyInterpolate(position, referencePositions, referenceTimesMs);
 return C.msToUs(positionAndTimeMs.second);
}
origin: google/ExoPlayer

public final long getPeriodDurationUs(int index) {
 return C.msToUs(getPeriodDurationMs(index));
}
origin: google/ExoPlayer

public long getFirstAvailableSegmentNum(
  DashManifest manifest, int periodIndex, long nowUnixTimeUs) {
 if (getSegmentCount() == DashSegmentIndex.INDEX_UNBOUNDED
   && manifest.timeShiftBufferDepthMs != C.TIME_UNSET) {
  // The index is itself unbounded. We need to use the current time to calculate the range of
  // available segments.
  long liveEdgeTimeUs = nowUnixTimeUs - C.msToUs(manifest.availabilityStartTimeMs);
  long periodStartUs = C.msToUs(manifest.getPeriod(periodIndex).startMs);
  long liveEdgeTimeInPeriodUs = liveEdgeTimeUs - periodStartUs;
  long bufferDepthUs = C.msToUs(manifest.timeShiftBufferDepthMs);
  return Math.max(
    getFirstSegmentNum(), getSegmentNum(liveEdgeTimeInPeriodUs - bufferDepthUs));
 }
 return getFirstSegmentNum();
}
origin: google/ExoPlayer

@Override
public long getPositionUs() {
 long positionUs = baseUs;
 if (started) {
  long elapsedSinceBaseMs = clock.elapsedRealtime() - baseElapsedMs;
  if (playbackParameters.speed == 1f) {
   positionUs += C.msToUs(elapsedSinceBaseMs);
  } else {
   positionUs += playbackParameters.getMediaTimeUsForPlayoutTimeMs(elapsedSinceBaseMs);
  }
 }
 return positionUs;
}
origin: google/ExoPlayer

public long getLastAvailableSegmentNum(
  DashManifest manifest, int periodIndex, long nowUnixTimeUs) {
 int availableSegmentCount = getSegmentCount();
 if (availableSegmentCount == DashSegmentIndex.INDEX_UNBOUNDED) {
  // The index is itself unbounded. We need to use the current time to calculate the range of
  // available segments.
  long liveEdgeTimeUs = nowUnixTimeUs - C.msToUs(manifest.availabilityStartTimeMs);
  long periodStartUs = C.msToUs(manifest.getPeriod(periodIndex).startMs);
  long liveEdgeTimeInPeriodUs = liveEdgeTimeUs - periodStartUs;
  // getSegmentNum(liveEdgeTimeInPeriodUs) will not be completed yet, so subtract one to get
  // the index of the last completed segment.
  return getSegmentNum(liveEdgeTimeInPeriodUs) - 1;
 }
 return getFirstSegmentNum() + availableSegmentCount - 1;
}
origin: google/ExoPlayer

@Override
protected List<Segment> getSegments(
  DataSource dataSource, DashManifest manifest, boolean allowIncompleteList)
  throws InterruptedException, IOException {
 ArrayList<Segment> segments = new ArrayList<>();
 for (int i = 0; i < manifest.getPeriodCount(); i++) {
  Period period = manifest.getPeriod(i);
  long periodStartUs = C.msToUs(period.startMs);
  long periodDurationUs = manifest.getPeriodDurationUs(i);
  List<AdaptationSet> adaptationSets = period.adaptationSets;
  for (int j = 0; j < adaptationSets.size(); j++) {
   addSegmentsForAdaptationSet(
     dataSource,
     adaptationSets.get(j),
     periodStartUs,
     periodDurationUs,
     allowIncompleteList,
     segments);
  }
 }
 return segments;
}
origin: google/ExoPlayer

private void checkForContentComplete() {
 if (contentDurationMs != C.TIME_UNSET && pendingContentPositionMs == C.TIME_UNSET
   && player.getContentPosition() + END_OF_CONTENT_POSITION_THRESHOLD_MS >= contentDurationMs
   && !sentContentComplete) {
  adsLoader.contentComplete();
  if (DEBUG) {
   Log.d(TAG, "adsLoader.contentComplete");
  }
  sentContentComplete = true;
  // After sending content complete IMA will not poll the content position, so set the expected
  // ad group index.
  expectedAdGroupIndex =
    adPlaybackState.getAdGroupIndexForPositionUs(C.msToUs(contentDurationMs));
 }
}
origin: google/ExoPlayer

@Test
public void testEventTimeWithinClippedRange() throws IOException {
 MediaLoadData mediaLoadData =
   getClippingMediaSourceMediaLoadData(
     /* clippingStartUs= */ TEST_CLIP_AMOUNT_US,
     /* clippingEndUs= */ TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US,
     /* eventStartUs= */ TEST_CLIP_AMOUNT_US + 1000,
     /* eventEndUs= */ TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US - 1000);
 assertThat(C.msToUs(mediaLoadData.mediaStartTimeMs)).isEqualTo(1000);
 assertThat(C.msToUs(mediaLoadData.mediaEndTimeMs))
   .isEqualTo(TEST_PERIOD_DURATION_US - 2 * TEST_CLIP_AMOUNT_US - 1000);
}
origin: google/ExoPlayer

@Test
public void testEventTimeOutsideClippedRange() throws IOException {
 MediaLoadData mediaLoadData =
   getClippingMediaSourceMediaLoadData(
     /* clippingStartUs= */ TEST_CLIP_AMOUNT_US,
     /* clippingEndUs= */ TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US,
     /* eventStartUs= */ TEST_CLIP_AMOUNT_US - 1000,
     /* eventEndUs= */ TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US + 1000);
 assertThat(C.msToUs(mediaLoadData.mediaStartTimeMs)).isEqualTo(0);
 assertThat(C.msToUs(mediaLoadData.mediaEndTimeMs))
   .isEqualTo(TEST_PERIOD_DURATION_US - 2 * TEST_CLIP_AMOUNT_US);
}
origin: google/ExoPlayer

@Test
public void testUnsetEventTime() throws IOException {
 MediaLoadData mediaLoadData =
   getClippingMediaSourceMediaLoadData(
     /* clippingStartUs= */ TEST_CLIP_AMOUNT_US,
     /* clippingEndUs= */ TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US,
     /* eventStartUs= */ C.TIME_UNSET,
     /* eventEndUs= */ C.TIME_UNSET);
 assertThat(C.msToUs(mediaLoadData.mediaStartTimeMs)).isEqualTo(C.TIME_UNSET);
 assertThat(C.msToUs(mediaLoadData.mediaEndTimeMs)).isEqualTo(C.TIME_UNSET);
}
origin: google/ExoPlayer

@Override
public SeekPoints getSeekPoints(long timeUs) {
 timeUs = Util.constrainValue(timeUs, 0, durationUs);
 Pair<Long, Long> timeMsAndPosition =
   linearlyInterpolate(C.usToMs(timeUs), referenceTimesMs, referencePositions);
 timeUs = C.msToUs(timeMsAndPosition.first);
 long position = timeMsAndPosition.second;
 return new SeekPoints(new SeekPoint(timeUs, position));
}
origin: google/ExoPlayer

@Override
public Period getPeriod(int periodIndex, Period period, boolean setIdentifiers) {
 Assertions.checkIndex(periodIndex, 0, getPeriodCount());
 Object id = setIdentifiers ? manifest.getPeriod(periodIndex).id : null;
 Object uid = setIdentifiers ? (firstPeriodId + periodIndex) : null;
 return period.set(id, uid, 0, manifest.getPeriodDurationUs(periodIndex),
   C.msToUs(manifest.getPeriod(periodIndex).startMs - manifest.getPeriod(0).startMs)
     - offsetInFirstPeriodUs);
}
origin: google/ExoPlayer

@Override
public void detachPlayer() {
 if (adsManager != null && imaPausedContent) {
  adPlaybackState =
    adPlaybackState.withAdResumePositionUs(
      playingAd ? C.msToUs(player.getCurrentPosition()) : 0);
  adsManager.pause();
 }
 lastVolumePercentage = getVolume();
 lastAdProgress = getAdProgress();
 lastContentProgress = getContentProgress();
 player.removeListener(this);
 player = null;
 eventListener = null;
}
origin: google/ExoPlayer

@Test
public void staleDisableRendererClock_shouldNotThrow()
  throws ExoPlaybackException {
 MediaClockRenderer mediaClockRenderer = new MediaClockRenderer();
 mediaClockRenderer.positionUs = TEST_POSITION_US;
 mediaClock.onRendererDisabled(mediaClockRenderer);
 assertThat(mediaClock.syncAndGetPositionUs()).isEqualTo(C.msToUs(fakeClock.elapsedRealtime()));
}
origin: google/ExoPlayer

private boolean resolvePendingMessagePosition(PendingMessageInfo pendingMessageInfo) {
 if (pendingMessageInfo.resolvedPeriodUid == null) {
  // Position is still unresolved. Try to find window in current timeline.
  Pair<Object, Long> periodPosition =
    resolveSeekPosition(
      new SeekPosition(
        pendingMessageInfo.message.getTimeline(),
        pendingMessageInfo.message.getWindowIndex(),
        C.msToUs(pendingMessageInfo.message.getPositionMs())),
      /* trySubsequentPeriods= */ false);
  if (periodPosition == null) {
   return false;
  }
  pendingMessageInfo.setResolvedPosition(
    playbackInfo.timeline.getIndexOfPeriod(periodPosition.first),
    periodPosition.second,
    periodPosition.first);
 } else {
  // Position has been resolved for a previous timeline. Try to find the updated period index.
  int index = playbackInfo.timeline.getIndexOfPeriod(pendingMessageInfo.resolvedPeriodUid);
  if (index == C.INDEX_UNSET) {
   return false;
  }
  pendingMessageInfo.resolvedPeriodIndex = index;
 }
 return true;
}
origin: google/ExoPlayer

@Override
public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
 if (adsManager == null) {
  return;
 }
 if (!playingAd && !player.isPlayingAd()) {
  checkForContentComplete();
  if (sentContentComplete) {
   for (int i = 0; i < adPlaybackState.adGroupCount; i++) {
    if (adPlaybackState.adGroupTimesUs[i] != C.TIME_END_OF_SOURCE) {
     adPlaybackState = adPlaybackState.withSkippedAdGroup(i);
    }
   }
   updateAdPlaybackState();
  } else {
   long positionMs = player.getCurrentPosition();
   timeline.getPeriod(0, period);
   int newAdGroupIndex = period.getAdGroupIndexForPositionUs(C.msToUs(positionMs));
   if (newAdGroupIndex != C.INDEX_UNSET) {
    sentPendingContentPositionMs = false;
    pendingContentPositionMs = positionMs;
    if (newAdGroupIndex != adGroupIndex) {
     shouldNotifyAdPrepareError = false;
    }
   }
  }
 } else {
  updateImaStateForPlayerState();
 }
}
origin: google/ExoPlayer

@Test
public void disableRendererMediaClock_standaloneShouldBeSynced() throws ExoPlaybackException {
 MediaClockRenderer mediaClockRenderer = new MediaClockRenderer();
 mediaClock.start();
 mediaClock.onRendererEnabled(mediaClockRenderer);
 mediaClockRenderer.positionUs = TEST_POSITION_US;
 mediaClock.syncAndGetPositionUs();
 mediaClock.onRendererDisabled(mediaClockRenderer);
 fakeClock.advanceTime(SLEEP_TIME_MS);
 assertThat(mediaClock.syncAndGetPositionUs())
   .isEqualTo(TEST_POSITION_US + C.msToUs(SLEEP_TIME_MS));
 assertClockIsRunning();
}
com.google.android.exoplayer2CmsToUs

Javadoc

Converts a time in milliseconds to the corresponding time in microseconds, preserving #TIME_UNSET values and #TIME_END_OF_SOURCE values.

Popular methods of C

  • usToMs
    Converts a time in microseconds to the corresponding time in milliseconds, preserving #TIME_UNSET an
  • generateAudioSessionIdV21
    Returns a newly generated audio session identifier, or AudioManager#ERROR if an error occurred in wh

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • runOnUiThread (Activity)
  • getExternalFilesDir (Context)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JOptionPane (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now