Fix single sample loading + seeking in HLS.

Issue #587
This commit is contained in:
Oliver Woodman 2015-08-13 20:32:09 +01:00
parent 87457d5042
commit 6b44c6e6b1
3 changed files with 9 additions and 2 deletions

View file

@ -138,6 +138,12 @@ public final class MediaFormat {
maxHeight); maxHeight);
} }
public MediaFormat copyWithDurationUs(long durationUs) {
return new MediaFormat(mimeType, maxInputSize, durationUs, width, height, rotationDegrees,
pixelWidthHeightRatio, channelCount, sampleRate, language, initializationData, maxWidth,
maxHeight);
}
/** /**
* @return A {@link MediaFormat} representation of this format. * @return A {@link MediaFormat} representation of this format.
*/ */

View file

@ -176,7 +176,7 @@ public final class SingleSampleSource implements SampleSource, SampleSourceReade
// Private methods. // Private methods.
private void maybeStartLoading() { private void maybeStartLoading() {
if (loadingFinished || state != STATE_END_OF_STREAM || loader.isLoading()) { if (loadingFinished || state == STATE_END_OF_STREAM || loader.isLoading()) {
return; return;
} }
if (currentLoadableException != null) { if (currentLoadableException != null) {

View file

@ -136,7 +136,8 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
downstreamMediaFormats = new MediaFormat[trackCount]; downstreamMediaFormats = new MediaFormat[trackCount];
mediaFormats = new MediaFormat[trackCount]; mediaFormats = new MediaFormat[trackCount];
for (int i = 0; i < trackCount; i++) { for (int i = 0; i < trackCount; i++) {
mediaFormats[i] = extractor.getMediaFormat(i); mediaFormats[i] = extractor.getMediaFormat(i).copyWithDurationUs(
chunkSource.getDurationUs());
} }
prepared = true; prepared = true;
return true; return true;