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

Refresh movie detail screen #1771

Merged
merged 1 commit into from
Apr 11, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions components/movies/MovieDetails.bs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,58 @@ sub init()
m.buttonGrp.setFocus(true)
m.top.lastFocus = m.buttonGrp

m.isFirstRun = true
m.top.observeField("itemContent", "itemContentChanged")

' Animation used to swap out posters on reloads
m.moviePosterSwapAnimation = m.top.findNode("moviePosterSwapAnimation")
m.moviePosterSwapAnimation.observeField("state", "onMoviePosterSwapAnimationStateChange")

m.top.observeField("newPosterImageURI", "onNewPosterImageURIChange")

m.moviePoster = m.top.findNode("moviePoster")
m.moviePosterSwap = m.top.findNode("moviePosterSwap")
m.moviePosterSwap.observeField("loadStatus", "onPosterLoadStatusChanged")
end sub

' onNewPosterImageURIChange: Handler for newPosterImageURI param change
'
sub onNewPosterImageURIChange()
m.moviePosterSwap.uri = m.top.newPosterImageURI
end sub

' onPosterLoadStatusChanged: Handler for changes to m.moviePosterSwap.loadStatus
'
sub onPosterLoadStatusChanged()
if LCase(m.moviePosterSwap.loadStatus) <> "ready" then return
m.moviePosterSwapAnimation.control = "start"
end sub

' onMoviePosterSwapAnimationStateChange: Handler for changes to m.moviePosterSwapAnimation.state
'
sub onMoviePosterSwapAnimationStateChange()
if LCase(m.moviePosterSwapAnimation.state) <> "stopped" then return
m.moviePoster.uri = m.moviePosterSwap.uri
m.moviePoster.opacity = 1
m.moviePosterSwap.opacity = 0
m.moviePosterSwap.uri = ""
end sub

' OnScreenShown: Callback function when view is presented on screen
'
sub OnScreenShown()
' set focus to button group
if m.extrasGrp.opacity = 1
m.top.lastFocus.setFocus(true)
else
m.buttonGrp.setFocus(true)
end if

if m.isFirstRun
m.isFirstRun = false
else
m.top.refreshMovieDetailsData = not m.top.refreshMovieDetailsData
end if
end sub

sub trailerAvailableChanged()
Expand Down
9 changes: 9 additions & 0 deletions components/movies/MovieDetails.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="MovieDetails" extends="JFScreen">
<children>
<Poster id="moviePosterSwap" translation="[96,175]" width="300" height="450" />

<LayoutGroup id="main_group" layoutDirection="horiz" itemSpacings="[30]">
<Poster id="moviePoster" translation="[250,150]" width="300" height="450" />
<LayoutGroup layoutDirection="vert" translation="[455, 150]" itemSpacings="[25]" id="details">
Expand Down Expand Up @@ -43,12 +45,19 @@

<!-- "Cast and Crew" row -->
<extrasSlider id="movieExtras" />

<Animation id="moviePosterSwapAnimation" duration="1" repeat="false" easeFunction="linear">
<FloatFieldInterpolator id="fadeinLoading" key="[0.0, 1.0]" keyValue="[ 0.00, 1.00 ]" fieldToInterp="moviePosterSwap.opacity" />
<FloatFieldInterpolator id="fadeoutLoaded" key="[0.0, 1.0]" keyValue="[ 1.00, 0.00 ]" fieldToInterp="moviePoster.opacity" />
</Animation>
</children>
<interface>
<field id="itemContent" type="node" />
<field id="trailerAvailable" type="bool" onChange="trailerAvailableChanged" value="false" />
<field id="selectedAudioStreamIndex" type="integer" />
<field id="selectedVideoStreamId" type="string" />
<field id="newPosterImageURI" type="string" />
<field id="quickPlayNode" type="node" alwaysNotify="true" />
<field id="refreshMovieDetailsData" type="bool" alwaysNotify="true" />
</interface>
</component>
15 changes: 15 additions & 0 deletions source/Main.bs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,22 @@ sub Main (args as dynamic) as void
currentScene.episodeObjects = currentScene.objects
currentScene.callFunc("updateSeason")
stopLoadingSpinner()
else if isNodeEvent(msg, "refreshMovieDetailsData")
startLoadingSpinner()

currentScene = m.global.sceneManager.callFunc("getActiveScene")

' Refresh movie detail data
currentScene.itemContent.json = api.users.GetItem(m.global.session.user.id, currentScene.itemContent.id)
movieMetaData = ItemMetaData(currentScene.itemContent.id)

' Redraw movie poster
currentScene.newPosterImageURI = movieMetaData.posterURL

' Set updated starting point for the queue item
m.global.queueManager.callFunc("setTopStartingPoint", currentScene.itemContent.json.UserData.PlaybackPositionTicks)

stopLoadingSpinner()
else if isNodeEvent(msg, "selectedItem")
' If you select a library from ANYWHERE, follow this flow
selectedItem = msg.getData()
Expand Down
1 change: 1 addition & 0 deletions source/ShowScenes.bs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ function CreateMovieDetailsGroup(movie as object) as dynamic
' start building MovieDetails view
group = CreateObject("roSGNode", "MovieDetails")
group.observeField("quickPlayNode", m.port)
group.observeField("refreshMovieDetailsData", m.port)
group.overhangTitle = movie.title
group.optionsAvailable = false
group.trailerAvailable = false
Expand Down
Loading