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) &&
streams.videoStreams.orEmpty().isNotEmpty()
) {
val manifest = DashHelper.createManifest(streams)
val uri = let {
streams.dash?.toUri()
// encode to base64
val encoded = Base64.encodeToString(manifest.toByteArray(), Base64.DEFAULT)
val mediaItem = "data:application/dash+xml;charset=utf-8;base64,$encoded"
val manifest = DashHelper.createManifest(streams)
this.setMediaSource(mediaItem.toUri(), MimeTypes.APPLICATION_MPD)
// encode to base64
val encoded = Base64.encodeToString(manifest.toByteArray(), Base64.DEFAULT)
"data:application/dash+xml;charset=utf-8;base64,$encoded".toUri()
}
this.setMediaSource(uri, MimeTypes.APPLICATION_MPD)
} else if (streams.hls != null) {
setMediaSource(streams.hls.toUri(), MimeTypes.APPLICATION_M3U8)
} else {

View File

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