From 605f34a1a39d45e1ddaab10e010ef5f7ce6cdd27 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 18 Nov 2023 17:54:25 -0500 Subject: [PATCH 01/10] use loading spinners for selectedItem in main loop --- components/JFScene.xml | 1 + source/Main.bs | 32 +++++++++++++++++++++---- source/ShowScenes.bs | 10 ++++---- source/utils/misc.bs | 53 +++++++++++++++++++++++++++++++----------- 4 files changed, 74 insertions(+), 22 deletions(-) diff --git a/components/JFScene.xml b/components/JFScene.xml index 4bed5a46..56416c06 100644 --- a/components/JFScene.xml +++ b/components/JFScene.xml @@ -5,6 +5,7 @@ + \ No newline at end of file diff --git a/source/Main.bs b/source/Main.bs index e805176a..b2e75043 100644 --- a/source/Main.bs +++ b/source/Main.bs @@ -129,8 +129,6 @@ sub Main (args as dynamic) as void ' measure processing time timeSpan = CreateObject("roTimespan") - startMediaLoadingSpinner() - group = sceneManager.callFunc("getActiveScene") reportingNode = msg.getRoSGNode() itemNode = invalid @@ -162,6 +160,10 @@ sub Main (args as dynamic) as void ' can't play the item without knowing what type it is if isValid(itemType) + if not isValid(m.scene) + m.scene = m.top.getScene() + end if + startMediaLoadingSpinner() m.global.queueManager.callFunc("clear") ' empty queue/playlist m.global.queueManager.callFunc("resetShuffle") ' turn shuffle off @@ -206,7 +208,7 @@ sub Main (args as dynamic) as void else if itemType = "photoalbum" quickplay.photoAlbum(itemNode) end if - + stopLoadingSpinner() m.global.queueManager.callFunc("playQueue") end if end if @@ -217,6 +219,10 @@ sub Main (args as dynamic) as void ' If you select a library from ANYWHERE, follow this flow selectedItem = msg.getData() if isValid(selectedItem) + if not isValid(m.scene) + m.scene = m.top.getScene() + end if + startMediaLoadingSpinner() selectedItemType = selectedItem.type @@ -228,6 +234,7 @@ sub Main (args as dynamic) as void else group = CreateItemGrid(selectedItem) end if + stopLoadingSpinner() sceneManager.callFunc("pushScene", group) else if selectedItemType = "Folder" and selectedItem.json.type = "Genre" ' User clicked on a genre folder @@ -236,12 +243,15 @@ sub Main (args as dynamic) as void else group = CreateItemGrid(selectedItem) end if + stopLoadingSpinner() sceneManager.callFunc("pushScene", group) else if selectedItemType = "Folder" and selectedItem.json.type = "MusicGenre" group = CreateMusicLibraryView(selectedItem) + stopLoadingSpinner() sceneManager.callFunc("pushScene", group) else if selectedItemType = "UserView" or selectedItemType = "Folder" or selectedItemType = "Channel" or selectedItemType = "Boxset" group = CreateItemGrid(selectedItem) + stopLoadingSpinner() sceneManager.callFunc("pushScene", group) else if selectedItemType = "Episode" ' User has selected a TV episode they want us to play @@ -251,7 +261,7 @@ sub Main (args as dynamic) as void end if selectedItem.selectedAudioStreamIndex = audio_stream_idx - + stopLoadingSpinner() ' Display playback options dialog if selectedItem.json.userdata.PlaybackPositionTicks > 0 m.global.queueManager.callFunc("hold", selectedItem) @@ -264,16 +274,20 @@ sub Main (args as dynamic) as void else if selectedItemType = "Series" group = CreateSeriesDetailsGroup(selectedItem.json.id) + stopLoadingSpinner() else if selectedItemType = "Season" group = CreateSeasonDetailsGroupByID(selectedItem.json.SeriesId, selectedItem.id) + stopLoadingSpinner() else if selectedItemType = "Movie" ' open movie detail page group = CreateMovieDetailsGroup(selectedItem) + stopLoadingSpinner() else if selectedItemType = "Person" CreatePersonView(selectedItem) + stopLoadingSpinner() else if selectedItemType = "TvChannel" or selectedItemType = "Video" or selectedItemType = "Program" ' User selected a Live TV channel / program - + stopLoadingSpinner() ' Show Channel Loading spinner dialog = createObject("roSGNode", "ProgressDialog") dialog.title = tr("Loading Channel Data") @@ -304,6 +318,7 @@ sub Main (args as dynamic) as void quickplay.photo(selectedItem) end if + stopLoadingSpinner() else if selectedItemType = "PhotoAlbum" print "a photo album was selected" print "selectedItem=", selectedItem @@ -322,24 +337,31 @@ sub Main (args as dynamic) as void photoPlayer.itemIndex = 0 m.global.sceneManager.callfunc("pushScene", photoPlayer) end if + stopLoadingSpinner() else if selectedItemType = "MusicArtist" group = CreateArtistView(selectedItem.json) + stopLoadingSpinner() if not isValid(group) message_dialog(tr("Unable to find any albums or songs belonging to this artist")) end if else if selectedItemType = "MusicAlbum" group = CreateAlbumView(selectedItem.json) + stopLoadingSpinner() else if selectedItemType = "MusicVideo" group = CreateMovieDetailsGroup(selectedItem) + stopLoadingSpinner() else if selectedItemType = "Playlist" group = CreatePlaylistView(selectedItem.json) + stopLoadingSpinner() else if selectedItemType = "Audio" m.global.queueManager.callFunc("clear") m.global.queueManager.callFunc("resetShuffle") m.global.queueManager.callFunc("push", selectedItem.json) + stopLoadingSpinner() m.global.queueManager.callFunc("playQueue") else ' TODO - switch on more node types + stopLoadingSpinner() message_dialog("This type is not yet supported: " + selectedItemType + ".") end if end if diff --git a/source/ShowScenes.bs b/source/ShowScenes.bs index dca7b2b2..ab9348ab 100644 --- a/source/ShowScenes.bs +++ b/source/ShowScenes.bs @@ -813,17 +813,19 @@ function CreateSeasonDetailsGroupByID(seriesID as string, seasonID as string) as group = CreateObject("roSGNode", "TVEpisodes") group.optionsAvailable = false ' push scene asap (to prevent extra button presses when retriving series/movie info) - m.global.sceneManager.callFunc("pushScene", group) group.seasonData = seasonMetaData.json group.objects = TVEpisodes(seriesID, seasonID) group.episodeObjects = group.objects - group.extrasObjects = TVSeasonExtras(seasonID) - ' watch for button presses group.observeField("episodeSelected", m.port) group.observeField("quickPlayNode", m.port) - ' finished building SeasonDetails view + ' don't wait for the extras button stopLoadingSpinner() + m.global.sceneManager.callFunc("pushScene", group) + ' check for specials/extras for this season + group.extrasObjects = TVSeasonExtras(seasonID) + + ' finished building SeasonDetails view return group end function diff --git a/source/utils/misc.bs b/source/utils/misc.bs index 3cb48ed9..66ec3d27 100644 --- a/source/utils/misc.bs +++ b/source/utils/misc.bs @@ -452,26 +452,53 @@ function toString(input) as string end function sub startLoadingSpinner() - m.spinner = createObject("roSGNode", "Spinner") - m.spinner.translation = "[900, 450]" - m.spinner.visible = true - m.scene.appendChild(m.spinner) + if not isValid(m.scene) + m.scene = m.top.getScene() + end if + + if not m.scene.isLoading + m.scene.isLoading = true + + m.spinner = createObject("roSGNode", "Spinner") + m.spinner.translation = "[900, 450]" + m.spinner.visible = true + + m.scene.appendChild(m.spinner) + end if end sub sub startMediaLoadingSpinner() - dialog = createObject("roSGNode", "ProgressDialog") - dialog.id = "invisibiledialog" - dialog.visible = false - m.scene.dialog = dialog - startLoadingSpinner() + if not isValid(m.scene) + m.scene = m.top.getScene() + end if + + if not m.scene.isLoading + dialog = createObject("roSGNode", "ProgressDialog") + dialog.id = "invisibiledialog" + dialog.visible = false + m.scene.dialog = dialog + + startLoadingSpinner() + end if end sub sub stopLoadingSpinner() - if isValid(m.spinner) - m.spinner.visible = false + if not isValid(m.scene) + m.scene = m.top.getScene() end if - if isValid(m.scene) and isValid(m.scene.dialog) - m.scene.dialog.close = true + + if m.scene.isLoading + m.scene.isLoading = false + if isValid(m.spinner) + m.spinner.visible = false + end if + if isValid(m.scene) and isValid(m.scene.dialog) + if m.scene.dialog.isSubType("ProgressDialog") + m.scene.dialog.close = true + else if m.scene.dialog.isSubType("Spinner") + m.scene.dialog.close = true + end if + end if end if end sub From 26cf3517f853a089cafaca945d449a3ee84aa7bf Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 18 Nov 2023 17:59:22 -0500 Subject: [PATCH 02/10] remove duplicate code --- source/Main.bs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/Main.bs b/source/Main.bs index b2e75043..957259ef 100644 --- a/source/Main.bs +++ b/source/Main.bs @@ -160,9 +160,6 @@ sub Main (args as dynamic) as void ' can't play the item without knowing what type it is if isValid(itemType) - if not isValid(m.scene) - m.scene = m.top.getScene() - end if startMediaLoadingSpinner() m.global.queueManager.callFunc("clear") ' empty queue/playlist m.global.queueManager.callFunc("resetShuffle") ' turn shuffle off @@ -219,9 +216,6 @@ sub Main (args as dynamic) as void ' If you select a library from ANYWHERE, follow this flow selectedItem = msg.getData() if isValid(selectedItem) - if not isValid(m.scene) - m.scene = m.top.getScene() - end if startMediaLoadingSpinner() selectedItemType = selectedItem.type From d2fcc932b2aca7a9daf8dd58b158aa6f1398d73b Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 21 Nov 2023 21:14:40 -0500 Subject: [PATCH 03/10] move spinner to JFScene and migrate all other screnes to use it + use booleans on JFScene to control spinner + resize spinner to be similar size as video player spinner --- components/ItemGrid/ItemGrid.bs | 19 +++++------ components/ItemGrid/ItemGrid.xml | 1 - components/ItemGrid/MovieLibraryView.bs | 15 +++------ components/ItemGrid/MovieLibraryView.xml | 1 - components/ItemGrid/MusicLibraryView.bs | 13 ++------ components/ItemGrid/MusicLibraryView.xml | 1 - components/JFScene.bs | 25 ++++++++++++++ components/JFScene.xml | 4 ++- components/Spinner.bs | 2 +- components/config/SetServerScreen.bs | 5 ++- components/config/SetServerScreen.xml | 1 - components/liveTv/schedule.bs | 10 +++--- components/liveTv/schedule.xml | 1 - components/mediaPlayers/AudioPlayer.bs | 1 + components/movies/MovieDetails.bs | 4 +-- components/movies/MovieDetails.xml | 1 - components/music/AlbumView.bs | 10 +----- components/music/AlbumView.xml | 1 - components/music/ArtistView.bs | 1 + components/music/PlaylistView.bs | 10 +----- components/music/PlaylistView.xml | 1 - components/photos/PhotoDetails.bs | 2 ++ components/search/SearchResults.bs | 7 ++-- components/search/SearchResults.xml | 1 - components/video/VideoPlayerView.bs | 2 ++ images/spinner.png | Bin 7212 -> 7744 bytes source/Main.bs | 32 ++++-------------- source/ShowScenes.bs | 8 ++--- source/VideoPlayer.bs | 2 +- source/utils/misc.bs | 40 +++++------------------ source/utils/quickplay.bs | 2 ++ 31 files changed, 84 insertions(+), 139 deletions(-) diff --git a/components/ItemGrid/ItemGrid.bs b/components/ItemGrid/ItemGrid.bs index ea3299b0..c1455861 100644 --- a/components/ItemGrid/ItemGrid.bs +++ b/components/ItemGrid/ItemGrid.bs @@ -64,9 +64,6 @@ sub init() 'set inital counts for overhang before content is loaded. m.loadItemsTask.totalRecordCount = 0 - m.spinner = m.top.findNode("spinner") - m.spinner.visible = true - m.Alpha = m.top.findNode("AlphaMenu") m.AlphaSelected = m.top.findNode("AlphaSelected") @@ -92,7 +89,7 @@ end sub 'Load initial set of Data sub loadInitialItems() m.loadItemsTask.control = "stop" - m.spinner.visible = true + startLoadingSpinner() if m.top.parentItem.json.Type = "CollectionFolder" 'or m.top.parentItem.json.Type = "Folder" m.top.HomeLibraryItem = m.top.parentItem.Id @@ -238,7 +235,7 @@ sub loadInitialItems() end if m.loadItemsTask.observeField("content", "ItemDataLoaded") - m.spinner.visible = true + startLoadingSpinner(false) m.loadItemsTask.control = "RUN" SetUpOptions() end sub @@ -450,6 +447,7 @@ end sub ' 'Handle loaded data, and add to Grid sub ItemDataLoaded(msg) + stopLoadingSpinner() m.top.alphaActive = false itemData = msg.GetData() m.loadItemsTask.unobserveField("content") @@ -475,7 +473,7 @@ sub ItemDataLoaded(msg) m.genreList.setFocus(true) m.loading = false - m.spinner.visible = false + stopLoadingSpinner() return end if @@ -498,7 +496,7 @@ sub ItemDataLoaded(msg) m.itemGrid.setFocus(true) m.genreList.setFocus(false) - m.spinner.visible = false + stopLoadingSpinner() end sub ' @@ -571,7 +569,7 @@ end sub ' 'Load next set of items sub loadMoreData() - m.spinner.visible = true + startLoadingSpinner(false) if m.Loading = true then return m.Loading = true m.loadItemsTask.startIndex = m.loadedItems @@ -594,7 +592,7 @@ sub onItemalphaSelected() m.loadItemsTask.searchTerm = "" m.VoiceBox.text = "" m.loadItemsTask.nameStartsWith = m.alpha.itemAlphaSelected - m.spinner.visible = true + startLoadingSpinner(false) loadInitialItems() end if end sub @@ -609,7 +607,7 @@ sub onvoiceFilter() m.loadItemsTask.NameStartsWith = " " m.loadItemsTask.searchTerm = m.voiceBox.text m.loadItemsTask.recursive = true - m.spinner.visible = true + startLoadingSpinner(false) loadInitialItems() end if end sub @@ -842,7 +840,6 @@ function onKeyEvent(key as string, press as boolean) as boolean end if if key = "replay" - m.spinner.visible = true m.loadItemsTask.searchTerm = "" m.loadItemsTask.nameStartsWith = "" m.voiceBox.text = "" diff --git a/components/ItemGrid/ItemGrid.xml b/components/ItemGrid/ItemGrid.xml index 3c5d2c79..8522ab45 100644 --- a/components/ItemGrid/ItemGrid.xml +++ b/components/ItemGrid/ItemGrid.xml @@ -22,7 +22,6 @@