diff --git a/source/Main.brs b/source/Main.brs index 088f1401..351ba36b 100644 --- a/source/Main.brs +++ b/source/Main.brs @@ -380,6 +380,16 @@ sub Main (args as dynamic) as void SignOut() wipe_groups() goto app_start + else if button.id = "play_mpeg2" + playMpeg2 = get_setting("playback.mpeg2") + if playMpeg2 = "true" + playMpeg2 = "false" + button.title = tr("MPEG2 Support: Off") + else + playMpeg2 = "true" + button.title = tr("MPEG2 Support: On") + end if + set_setting("playback.mpeg2", playMpeg2) end if else if isNodeEvent(msg, "selectSubtitlePressed") node = m.scene.focusedChild diff --git a/source/ShowScenes.brs b/source/ShowScenes.brs index 7f04259a..f7aa91af 100644 --- a/source/ShowScenes.brs +++ b/source/ShowScenes.brs @@ -194,6 +194,22 @@ function CreateHomeGroup() new_options.push(o) end for + ' Add option for mpeg-2 playback + playMpeg2 = get_setting("playback.mpeg2") + if playMpeg2 = invalid + playMpeg2 = "true" + set_setting("playback.mpeg2", playMpeg2) + end if + o = CreateObject("roSGNode", "OptionsButton") + if playMpeg2 = "true" + o.title = tr("MPEG2 Support: On") + else + o.title = tr("MPEG2 Support: Off") + end if + o.id = "play_mpeg2" + o.observeField("optionSelected", m.port) + new_options.push(o) + ' And a profile button user_node = CreateObject("roSGNode", "OptionsData") user_node.id = "active_user" diff --git a/source/utils/deviceCapabilities.brs b/source/utils/deviceCapabilities.brs index 7be1dc2e..055a55d3 100644 --- a/source/utils/deviceCapabilities.brs +++ b/source/utils/deviceCapabilities.brs @@ -17,6 +17,7 @@ end function function getDeviceProfile() as object + playMpeg2 = get_setting("playback.mpeg2") = "true" 'Check if 5.1 Audio Output connected maxAudioChannels = 2 @@ -25,6 +26,19 @@ function getDeviceProfile() as object maxAudioChannels = 6 end if + if playMpeg2 and di.CanDecodeVideo({ Codec: "mpeg2" }).Result = true + tsVideoCodecs = "h264,mpeg2video" + else + tsVideoCodecs = "h264" + end if + + if di.CanDecodeAudio({ Codec: "ac3" }).result + tsAudioCodecs = "aac,ac3" + else + tsAudioCodecs = "aac" + end if + + return { "MaxStreamingBitrate": 120000000, "MaxStaticBitrate": 100000000, @@ -66,8 +80,8 @@ function getDeviceProfile() as object { "Container": "ts", "Type": "Video", - "AudioCodec": "aac", - "VideoCodec": "h264", + "AudioCodec": tsAudioCodecs, + "VideoCodec": tsVideoCodecs, "Context": "Streaming", "Protocol": "hls", "MaxAudioChannels": StrI(maxAudioChannels) ' Currently Jellyfin server expects this as a string @@ -142,6 +156,8 @@ function GetDirectPlayProfiles() as object mkvAudio = "mp3,pcm,lpcm,wav" audio = "mp3,pcm,lpcm,wav" + playMpeg2 = get_setting("playback.mpeg2") = "true" + di = CreateObject("roDeviceInfo") 'Check for Supported Video Codecs @@ -154,6 +170,11 @@ function GetDirectPlayProfiles() as object mkvVideo = mkvVideo + ",vp9" end if + if playMpeg2 and di.CanDecodeVideo({ Codec: "mpeg2" }).Result = true + mp4Video = mp4Video + ",mpeg2video" + mkvVideo = mkvVideo + ",mpeg2video" + end if + ' Check for supported Audio if di.CanDecodeAudio({ Codec: "ac3" }).result mkvAudio = mkvAudio + ",ac3"