From 02f4fa065c502cb3133931196bd4ffc137707102 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sun, 7 Apr 2024 08:20:07 -0400 Subject: [PATCH] refresh movie detail screen --- components/movies/MovieDetails.bs | 42 ++++++++++++++++++++++++++++++ components/movies/MovieDetails.xml | 9 +++++++ source/Main.bs | 15 +++++++++++ source/ShowScenes.bs | 1 + 4 files changed, 67 insertions(+) diff --git a/components/movies/MovieDetails.bs b/components/movies/MovieDetails.bs index 9cc79d802..ecd640987 100644 --- a/components/movies/MovieDetails.bs +++ b/components/movies/MovieDetails.bs @@ -21,9 +21,45 @@ 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 @@ -31,6 +67,12 @@ sub OnScreenShown() 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() diff --git a/components/movies/MovieDetails.xml b/components/movies/MovieDetails.xml index 2d642c155..f548c2a24 100644 --- a/components/movies/MovieDetails.xml +++ b/components/movies/MovieDetails.xml @@ -1,6 +1,8 @@ + + @@ -43,12 +45,19 @@ + + + + + + + \ No newline at end of file diff --git a/source/Main.bs b/source/Main.bs index ada4769c3..5f48b5af3 100644 --- a/source/Main.bs +++ b/source/Main.bs @@ -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() diff --git a/source/ShowScenes.bs b/source/ShowScenes.bs index fbf003d24..d59696eec 100644 --- a/source/ShowScenes.bs +++ b/source/ShowScenes.bs @@ -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