Java Code Examples for com.google.android.exoplayer2.util.Util#resolveSeekPositionUs()

The following examples show how to use com.google.android.exoplayer2.util.Util#resolveSeekPositionUs() . 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: DefaultDashChunkSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example 2
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example 3
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example 4
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example 5
Source File: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example 6
Source File: ProgressiveMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  SeekMap seekMap = getPreparedState().seekMap;
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example 7
Source File: DefaultSsChunkSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  StreamElement streamElement = manifest.streamElements[streamElementIndex];
  int chunkIndex = streamElement.getChunkIndex(positionUs);
  long firstSyncUs = streamElement.getStartTimeUs(chunkIndex);
  long secondSyncUs =
      firstSyncUs < positionUs && chunkIndex < streamElement.chunkCount - 1
          ? streamElement.getStartTimeUs(chunkIndex + 1)
          : firstSyncUs;
  return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
}
 
Example 8
Source File: ExtractorMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example 9
Source File: DefaultSsChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  StreamElement streamElement = manifest.streamElements[streamElementIndex];
  int chunkIndex = streamElement.getChunkIndex(positionUs);
  long firstSyncUs = streamElement.getStartTimeUs(chunkIndex);
  long secondSyncUs =
      firstSyncUs < positionUs && chunkIndex < streamElement.chunkCount - 1
          ? streamElement.getStartTimeUs(chunkIndex + 1)
          : firstSyncUs;
  return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
}
 
Example 10
Source File: ExtractorMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example 11
Source File: DefaultSsChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  StreamElement streamElement = manifest.streamElements[streamElementIndex];
  int chunkIndex = streamElement.getChunkIndex(positionUs);
  long firstSyncUs = streamElement.getStartTimeUs(chunkIndex);
  long secondSyncUs =
      firstSyncUs < positionUs && chunkIndex < streamElement.chunkCount - 1
          ? streamElement.getStartTimeUs(chunkIndex + 1)
          : firstSyncUs;
  return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
}
 
Example 12
Source File: ProgressiveMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  SeekMap seekMap = getPreparedState().seekMap;
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example 13
Source File: DefaultSsChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  StreamElement streamElement = manifest.streamElements[streamElementIndex];
  int chunkIndex = streamElement.getChunkIndex(positionUs);
  long firstSyncUs = streamElement.getStartTimeUs(chunkIndex);
  long secondSyncUs =
      firstSyncUs < positionUs && chunkIndex < streamElement.chunkCount - 1
          ? streamElement.getStartTimeUs(chunkIndex + 1)
          : firstSyncUs;
  return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
}
 
Example 14
Source File: ProgressiveMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  SeekMap seekMap = getPreparedState().seekMap;
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example 15
Source File: DefaultSsChunkSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  StreamElement streamElement = manifest.streamElements[streamElementIndex];
  int chunkIndex = streamElement.getChunkIndex(positionUs);
  long firstSyncUs = streamElement.getStartTimeUs(chunkIndex);
  long secondSyncUs =
      firstSyncUs < positionUs && chunkIndex < streamElement.chunkCount - 1
          ? streamElement.getStartTimeUs(chunkIndex + 1)
          : firstSyncUs;
  return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
}