Merge pull request #1902 from FireMasterK/otf-videos-fix

Implement proper handling of OTF videos.
This commit is contained in:
Kavin 2022-11-18 18:17:31 +00:00 committed by GitHub
commit 1d08e30065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -1193,13 +1193,18 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
if (!PreferenceHelper.getBoolean(PreferenceKeys.USE_HLS_OVER_DASH, false) && if (!PreferenceHelper.getBoolean(PreferenceKeys.USE_HLS_OVER_DASH, false) &&
streams.videoStreams.orEmpty().isNotEmpty() streams.videoStreams.orEmpty().isNotEmpty()
) { ) {
val uri = let {
streams.dash?.toUri()
val manifest = DashHelper.createManifest(streams) val manifest = DashHelper.createManifest(streams)
// encode to base64 // encode to base64
val encoded = Base64.encodeToString(manifest.toByteArray(), Base64.DEFAULT) val encoded = Base64.encodeToString(manifest.toByteArray(), Base64.DEFAULT)
val mediaItem = "data:application/dash+xml;charset=utf-8;base64,$encoded"
this.setMediaSource(mediaItem.toUri(), MimeTypes.APPLICATION_MPD) "data:application/dash+xml;charset=utf-8;base64,$encoded".toUri()
}
this.setMediaSource(uri, MimeTypes.APPLICATION_MPD)
} else if (streams.hls != null) { } else if (streams.hls != null) {
setMediaSource(streams.hls.toUri(), MimeTypes.APPLICATION_M3U8) setMediaSource(streams.hls.toUri(), MimeTypes.APPLICATION_M3U8)
} else { } else {

View File

@ -45,6 +45,11 @@ object DashHelper {
continue continue
} }
// ignore streams which might be OTF
if (stream.indexEnd!! <= 0) {
continue
}
val adapSetInfo = adapSetInfos.find { it.mimeType == stream.mimeType } val adapSetInfo = adapSetInfos.find { it.mimeType == stream.mimeType }
if (adapSetInfo != null) { if (adapSetInfo != null) {
adapSetInfo.formats.add(stream) adapSetInfo.formats.add(stream)