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);
}
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.
*/

View file

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

View file

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