Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix External Player missing external subtitles #1263

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/assets/native/ExternalPlayerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class ExternalPlayerPlugin {
MaxStaticBitrate: 1_000_000_000,
DirectPlayProfiles: [{Type: 'Video'}, {Type: 'Audio'}],
CodecProfiles: [],
SubtitleProfiles: [{Method: 'Embed'}, {Method: 'Drop'}],
SubtitleProfiles: [{Method: 'Embed'}, {Method: 'External'}, {Method: 'Drop'}],
TranscodingProfiles: []
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import kotlinx.coroutines.launch
import org.jellyfin.mobile.R
import org.jellyfin.mobile.app.AppPreferences
import org.jellyfin.mobile.player.PlayerException
import org.jellyfin.mobile.player.deviceprofile.DeviceProfileBuilder
import org.jellyfin.mobile.player.interaction.PlayOptions
import org.jellyfin.mobile.player.source.ExternalSubtitleStream
import org.jellyfin.mobile.player.source.JellyfinMediaSource
Expand All @@ -29,6 +30,7 @@ import org.jellyfin.mobile.webapp.WebappFunctionChannel
import org.jellyfin.sdk.api.client.ApiClient
import org.jellyfin.sdk.api.client.extensions.videosApi
import org.jellyfin.sdk.api.operations.VideosApi
import org.jellyfin.sdk.model.api.DeviceProfile
import org.jellyfin.sdk.model.serializer.toUUIDOrNull
import org.json.JSONObject
import org.koin.core.component.KoinComponent
Expand All @@ -46,6 +48,8 @@ class ExternalPlayer(
private val appPreferences: AppPreferences by inject()
private val webappFunctionChannel: WebappFunctionChannel by inject()
private val mediaSourceResolver: MediaSourceResolver by inject()
private val deviceProfileBuilder: DeviceProfileBuilder by inject()
private val externalPlayerProfile: DeviceProfile = deviceProfileBuilder.getExternalPlayerProfile()
private val apiClient: ApiClient = get()
private val videosApi: VideosApi = apiClient.videosApi

Expand Down Expand Up @@ -93,6 +97,7 @@ class ExternalPlayer(
mediaSourceResolver.resolveMediaSource(
itemId = itemId,
mediaSourceId = playOptions.mediaSourceId,
deviceProfile = externalPlayerProfile,
startTimeTicks = playOptions.startPositionTicks,
audioStreamIndex = playOptions.audioStreamIndex,
subtitleStreamIndex = playOptions.subtitleStreamIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,36 @@ class DeviceProfileBuilder(
}
}

fun getExternalPlayerProfile(): DeviceProfile = DeviceProfile(
name = EXTERNAL_PLAYER_PROFILE_NAME,
directPlayProfiles = listOf(
DirectPlayProfile(type = DlnaProfileType.VIDEO),
DirectPlayProfile(type = DlnaProfileType.AUDIO),
),
transcodingProfiles = emptyList(),
containerProfiles = emptyList(),
codecProfiles = emptyList(),
subtitleProfiles = buildList {
EXTERNAL_PLAYER_SUBTITLES.mapTo(this) { format ->
SubtitleProfile(format = format, method = SubtitleDeliveryMethod.EMBED)
}
EXTERNAL_PLAYER_SUBTITLES.mapTo(this) { format ->
SubtitleProfile(format = format, method = SubtitleDeliveryMethod.EXTERNAL)
}
},
maxStreamingBitrate = Int.MAX_VALUE,
maxStaticBitrate = Int.MAX_VALUE,
musicStreamingTranscodingBitrate = Int.MAX_VALUE,

// TODO: remove redundant defaults after API/SDK is fixed
supportedMediaTypes = "",
xmlRootAttributes = emptyList(),
responseProfiles = emptyList(),
)

companion object {
private const val EXTERNAL_PLAYER_PROFILE_NAME = Constants.APP_INFO_NAME + " External Player"

/**
* List of container formats supported by ExoPlayer
*
Expand Down Expand Up @@ -253,6 +282,7 @@ class DeviceProfileBuilder(
private val EXO_EMBEDDED_SUBTITLES = arrayOf("dvbsub", "pgssub", "srt", "subrip", "ttml")
private val EXO_EXTERNAL_SUBTITLES = arrayOf("srt", "subrip", "ttml", "vtt", "webvtt")
private val SUBTITLES_SSA = arrayOf("ssa", "ass")
private val EXTERNAL_PLAYER_SUBTITLES = arrayOf("ass", "dvbsub", "pgssub", "srt", "srt", "ssa", "subrip", "subrip", "ttml", "ttml", "vtt", "webvtt")

/**
* Taken from Jellyfin Web:
Expand Down