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

Merge video and audio options #535

Merged
merged 12 commits into from
Apr 7, 2022
110 changes: 0 additions & 110 deletions components/movies/MovieAudioOptions.brs

This file was deleted.

37 changes: 0 additions & 37 deletions components/movies/MovieAudioOptions.xml

This file was deleted.

51 changes: 27 additions & 24 deletions components/movies/MovieDetails.brs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ sub init()
m.extrasGrid = m.top.findNode("extrasGrid")
m.top.optionsAvailable = false

m.audioOptions = m.top.findNode("audioOptions")
m.videoOptions = m.top.findNode("videoOptions")
m.options = m.top.findNode("movieOptions")

m.main_group = m.top.findNode("main_group")

Expand Down Expand Up @@ -106,15 +105,18 @@ sub SetUpVideoOptions(streams)
end if
end for

if streams.count() > 1
m.top.findnode("video_codec_count").text = "+" + stri(streams.Count() - 1).trim()
end if

options = {}
options.views = videos
m.videoOptions.options = options
options.videos = videos
m.options.options = options

end sub


sub SetUpAudioOptions(streams)

tracks = []

for i = 0 to streams.Count() - 1
Expand All @@ -123,9 +125,16 @@ sub SetUpAudioOptions(streams)
end if
end for

if tracks.count() > 1
m.top.findnode("audio_codec_count").text = "+" + stri(tracks.Count() - 1).trim()
end if

options = {}
options.views = tracks
m.audioOptions.options = options
if m.options.options.videos <> invalid
options.videos = m.options.options.videos
end if
options.audios = tracks
m.options.options = options

end sub

Expand Down Expand Up @@ -217,8 +226,8 @@ end function
'
'Check if options updated and any reloading required
sub audioOptionsClosed()
if m.audioOptions.audioStreamIndex <> m.top.selectedAudioStreamIndex
m.top.selectedAudioStreamIndex = m.audioOptions.audioStreamIndex
if m.options.audioStreamIndex <> m.top.selectedAudioStreamIndex
m.top.selectedAudioStreamIndex = m.options.audioStreamIndex
setFieldText("audio_codec", tr("Audio") + ": " + m.top.itemContent.json.mediaStreams[m.top.selectedAudioStreamIndex].displayTitle)
end if
m.top.findNode("buttons").setFocus(true)
Expand All @@ -227,9 +236,9 @@ end sub
'
' Check if options were updated and if any reloding is needed...
sub videoOptionsClosed()
if m.videoOptions.videoStreamId <> m.top.selectedVideoStreamId
m.top.selectedVideoStreamId = m.videoOptions.videoStreamId
setFieldText("video_codec", tr("Video") + ": " + m.videoOptions.video_codec)
if m.options.videoStreamId <> m.top.selectedVideoStreamId
m.top.selectedVideoStreamId = m.options.videoStreamId
setFieldText("video_codec", tr("Video") + ": " + m.options.video_codec)
' Because the video stream has changed (i.e. the actual video)... we need to reload the audio stream choices for that video
m.top.unobservefield("itemContent")
itemData = m.top.itemContent.json
Expand All @@ -254,12 +263,9 @@ function onKeyEvent(key as string, press as boolean) as boolean

' Due to the way the button pressed event works, need to catch the release for the button as the press is being sent
' directly to the main loop. Will get this sorted in the layout update for Movie Details
if key = "OK" and m.top.findNode("video-button").isInFocusChain()
m.videoOptions.visible = true
m.videoOptions.setFocus(true)
else if key = "OK" and m.top.findNode("audio-button").isInFocusChain()
m.audioOptions.visible = true
m.audioOptions.setFocus(true)
if key = "OK" and m.top.findNode("options-button").isInFocusChain()
m.options.visible = true
m.options.setFocus(true)
end if

if key = "down" and m.buttonGrp.isInFocusChain()
Expand All @@ -283,13 +289,10 @@ function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false

if key = "back"
if m.audioOptions.visible = true
m.audioOptions.visible = false
audioOptionsClosed()
return true
else if m.videoOptions.visible = true
m.videoOptions.visible = false
if m.options.visible = true
m.options.visible = false
videoOptionsClosed()
audioOptionsClosed()
return true
end if
end if
Expand Down
16 changes: 10 additions & 6 deletions components/movies/MovieDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@
</LayoutGroup>
<Label id="genres" />
<Label id="director" />
<Label id="video_codec" />
<Label id="audio_codec" />
<LayoutGroup layoutDirection="horiz" >
<Label id="video_codec" vertAlign="bottom" height="39" />
<label id="video_codec_count" font="font:smallestSystemFont" vertAlign="top" color="#ceffff" />
</LayoutGroup>
<LayoutGroup layoutDirection="horiz" >
<Label id="audio_codec" vertAlign="bottom" height="39" />
<label id="audio_codec_count" font="font:smallestSystemFont" vertAlign="top" color="#ceffff" />
</LayoutGroup>
<ButtonGroupHoriz id="buttons" itemSpacings="[10]">
<Button text="Play" id="play-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
<Button text="Version" id="video-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
<Button text="Audio" id="audio-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
<Button text="Options" id="options-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
<Button text="Watched" id="watched-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
<Button text="Favorite" id="favorite-button" iconUri="" focusedIconUri="" maxWidth="300" minWidth="300" />
</ButtonGroupHoriz>
<Label id="tagline" />
<Label id="overview" wrap="true" maxLines="8" />
</LayoutGroup>
</LayoutGroup>
<MovieVideoOptions id="videoOptions" visible="false" />
<MovieAudioOptions id="audioOptions" visible="false" />
<MovieOptions id="movieOptions" visible="false" />
<!-- "Cast and Crew" row -->
<extrasSlider id="movieExtras" />
</children>
Expand Down
Loading