-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infer subtitle codec from delivery URL
- Loading branch information
1 parent
d349b79
commit df2aeea
Showing
6 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/jellyfin/androidtv/ui/playback/VideoManagerHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.jellyfin.androidtv.ui.playback | ||
|
||
import androidx.core.net.toUri | ||
import org.jellyfin.playback.media3.exoplayer.mapping.getFfmpegSubtitleMimeType | ||
import org.jellyfin.sdk.model.api.MediaStream | ||
|
||
/** | ||
* Return the media type for the codec found in this media stream. First tries to infer the media type from the streams delivery URL and | ||
* falls back to the original stream codec. | ||
*/ | ||
fun getSubtitleMediaStreamCodec(stream: MediaStream): String { | ||
val codec = requireNotNull(stream.codec) | ||
val codecMediaType = getFfmpegSubtitleMimeType(codec, "").ifBlank { null } | ||
|
||
val urlSubtitleExtension = stream.deliveryUrl?.toUri()?.lastPathSegment?.split('.')?.last() | ||
val urlExtensionMediaType = urlSubtitleExtension?.let { getFfmpegSubtitleMimeType(it, "") }?.ifBlank { null } | ||
|
||
return urlExtensionMediaType ?: codecMediaType ?: urlSubtitleExtension ?: codec | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters