Fix audio only streams with EXT-X-MEDIA tags (somewhat) #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses an issue that prevented the player from firing
ended
event for two different audio only stream scenarios. One when an audio only stream hasEXT-X-MEDIA
tags withtype=AUDIO
and theuri
attribute equal to theEXT-X-STREAM-INF
stream url. The other is multipleMEDIA
tags for alternate audio.This issue was happening because if an alternate audio track is active, the assumption that the
mainSegmentLoader
contains is fetching video and should continue to operate. Because of this assumption, audio only streams with alternate audio was not supported. The assumption was also made that if theuri
attribute was present on anEXT-X-MEDIA
tag, then that stream is an alternate stream.The spec mentions that the lack of a
uri
attribute means the audio is contained in theSTREAM-INF
uri, however, the spec makes no mention of allowing theuri
attribute to equal the uri of theSTREAM-INF
. This PR fixes that strange scenario by removing theuri
attribute from tags that have auri
attribute matching that of their correspondingSTREAM-INF
.To fix the issue with multiple alternate audio tracks, when deciding to call
endOfStream
, a check is made to see if themainSegmentLoader
has loaded any content with video, and if not, do not wait for it to beended
.NOTE: Audio only streams with multiple alternate audio tracks is only partially supported with this PR. You will be able to switch to alternate audio tracks, and switch between the alternate tracks, but returning to the
main
audio track will result in infinite rebuffering because themainSegmentLoader
gets into a bad state. A fix for this is out of scope for this PR because it will require some sweeping changes to the wayVirtualSourceBuffer
handles ownership of the native audio buffer.Note 2: I also included a bunch of useful logging statements for debugging in this PR. Its less than ideal to sneak these into this PR instead of their own, but I got distracted and forgot to checkout to a fresh branch before adding them while debugging an unrelated issue.