jellyfin / jellyfin-android

Android Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
1.33k stars 223 forks source link

SAMI External subtitle does not show on Exoplayer and External Player #1383

Open gkswngh05 opened 1 month ago

gkswngh05 commented 1 month ago

Describe the bug

The subtitle does not show on Exoplayer and External Player when external subtitle format is SAMI(.smi, .sami).

https://github.com/jellyfin/jellyfin-android/blob/f1f789946968789897ab5e5941b94d5f03dcb373/app/src/main/java/org/jellyfin/mobile/player/source/JellyfinMediaSource.kt#L89-L92

When subtitle format is SAMI, mediaStream.codec returns "sami". But "sami" is not defined in CodecHelpers.getSubtitleMimeType, so that function returns null.

https://github.com/jellyfin/jellyfin-android/blob/f1f789946968789897ab5e5941b94d5f03dcb373/app/src/main/java/org/jellyfin/mobile/player/deviceprofile/CodecHelpers.kt#L243-L254

Since Jellyfin server is converting SAMI subtitle to Subrip format before sending to client, a quick and dirty solution would be defining "sami" as MimeTypes.APPLICATION_SUBRIP.

 fun getSubtitleMimeType(codec: String?): String? { 
     return when (codec) { 
         "srt", "subrip" -> MimeTypes.APPLICATION_SUBRIP 
         "ssa", "ass" -> MimeTypes.TEXT_SSA 
         "ttml" -> MimeTypes.APPLICATION_TTML 
         "vtt", "webvtt" -> MimeTypes.TEXT_VTT 
         "idx", "sub" -> MimeTypes.APPLICATION_VOBSUB 
         "pgs", "pgssub" -> MimeTypes.APPLICATION_PGS 
         "smi", "smil" -> "application/smil+xml"
         "sami" -> MimeTypes.APPLICATION_SUBRIP
         else -> null 
     } 
 } 

Logs

No response

Application version

2.6.1

Where did you install the app from?

Google Play

Device information

Galaxy S23 Ultra

Android version

Android 14, One UI 6.1

Jellyfin server version

10.9.0

Which video player implementations does this bug apply to?

gkswngh05 commented 1 month ago

Come to think about it, I think it might be the Jellyfin server's problem. I may have to investigate about it... Edit: Nevermind.