Skip to content

Commit

Permalink
Merge pull request #1771 from cewert/refreshMovieDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert authored Apr 11, 2024
2 parents bdb88d7 + 02f4fa0 commit bedfb56
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
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

0 comments on commit bedfb56

Please sign in to comment.