From 95b84d0e11e357a8efd82b85ef0b7b654ed50458 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Thu, 17 Oct 2024 11:54:52 -0400 Subject: [PATCH] save global refs to prevent deep copies --- components/ItemGrid/GridItem.bs | 10 +- components/ItemGrid/ItemGrid.bs | 37 ++--- components/ItemGrid/LoadVideoContentTask.bs | 43 +++--- components/ItemGrid/MovieLibraryView.bs | 20 +-- components/ItemGrid/MusicLibraryView.bs | 16 +- components/JFVideo.bs | 5 +- components/ListPoster.bs | 13 +- components/WhatsNewDialog.bs | 5 +- components/home/HomeItem.bs | 22 +-- components/home/HomeRows.bs | 9 +- components/home/LoadItemsTask.bs | 5 +- components/manager/ViewCreator.bs | 39 ++--- components/movies/MovieDetails.bs | 7 +- components/music/AudioPlayerView.bs | 158 ++++++++++---------- components/photos/PhotoDetails.bs | 5 +- components/settings/settings.bs | 9 +- components/tvshows/TVListDetails.bs | 7 +- components/tvshows/TVShowDetails.bs | 5 +- components/video/OSD.bs | 4 +- components/video/VideoPlayerView.bs | 27 ++-- 20 files changed, 239 insertions(+), 207 deletions(-) diff --git a/components/ItemGrid/GridItem.bs b/components/ItemGrid/GridItem.bs index 9f7a62ae1..0658304e3 100644 --- a/components/ItemGrid/GridItem.bs +++ b/components/ItemGrid/GridItem.bs @@ -42,10 +42,10 @@ end sub sub itemContentChanged() m.backdrop.blendColor = "#00a4db" ' set default in case global var is invalid - localGlobal = m.global + myGlobal = m.global - if isValid(localGlobal) and isValid(localGlobal.constants) and isValid(localGlobal.constants.poster_bg_pallet) - posterBackgrounds = localGlobal.constants.poster_bg_pallet + if isValid(myGlobal) and isValid(myGlobal.constants) and isValid(myGlobal.constants.poster_bg_pallet) + posterBackgrounds = myGlobal.constants.poster_bg_pallet m.backdrop.blendColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1] end if @@ -62,8 +62,8 @@ sub itemContentChanged() m.itemIcon.uri = itemData.iconUrl m.itemText.text = itemData.Title else if itemData.type = "Series" - if isValid(localGlobal) and isValid(localGlobal.session) and isValid(localGlobal.session.user) and isValid(localGlobal.session.user.settings) - if localGlobal.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] = false + if isValid(myGlobal) and isValid(myGlobal.session) and isValid(myGlobal.session.user) and isValid(myGlobal.session.user.settings) + if myGlobal.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] = false if isValid(itemData.json) and isValid(itemData.json.UserData) and isValid(itemData.json.UserData.UnplayedItemCount) if itemData.json.UserData.UnplayedItemCount > 0 m.unplayedCount.visible = true diff --git a/components/ItemGrid/ItemGrid.bs b/components/ItemGrid/ItemGrid.bs index 759bacd7e..2b5875d9c 100644 --- a/components/ItemGrid/ItemGrid.bs +++ b/components/ItemGrid/ItemGrid.bs @@ -7,9 +7,11 @@ import "pkg:/source/roku_modules/log/LogMixin.brs" sub init() m.log = log.Logger("ItemGrid") m.log.debug("start init()") + userSettings = m.global.session.user.settings + m.options = m.top.findNode("options") - m.showItemCount = m.global.session.user.settings["itemgrid.showItemCount"] + m.showItemCount = userSettings["itemgrid.showItemCount"] m.tvGuide = invalid m.channelFocused = invalid @@ -68,9 +70,9 @@ sub init() m.alphaMenu = m.alpha.findNode("alphaMenu") 'Get reset folder setting - m.resetGrid = m.global.session.user.settings["itemgrid.reset"] + m.resetGrid = userSettings["itemgrid.reset"] - m.top.gridTitles = m.global.session.user.settings["itemgrid.gridTitles"] + m.top.gridTitles = userSettings["itemgrid.gridTitles"] m.log.debug("end init()") end sub @@ -84,6 +86,7 @@ sub loadInitialItems() m.log.debug("start loadInitialItems()") m.loadItemsTask.control = "stop" startLoadingSpinner() + userSettings = m.global.session.user.settings if m.top.parentItem.json.Type = "CollectionFolder" 'or m.top.parentItem.json.Type = "Folder" m.top.HomeLibraryItem = m.top.parentItem.Id @@ -96,25 +99,25 @@ sub loadInitialItems() ' Read view/sort/filter settings if m.top.parentItem.collectionType = "livetv" ' Translate between app and server nomenclature - viewSetting = m.global.session.user.settings["display.livetv.landing"] + viewSetting = userSettings["display.livetv.landing"] if viewSetting = "guide" m.view = "tvGuide" else m.view = "livetv" end if - m.sortField = m.global.session.user.settings["display.livetv.sortField"] - sortAscendingStr = m.global.session.user.settings["display.livetv.sortAscending"] - m.filter = m.global.session.user.settings["display.livetv.filter"] + m.sortField = userSettings["display.livetv.sortField"] + sortAscendingStr = userSettings["display.livetv.sortAscending"] + m.filter = userSettings["display.livetv.filter"] else if m.top.parentItem.collectionType = "music" - m.view = m.global.session.user.settings["display.music.view"] - m.sortField = m.global.session.user.settings["display." + m.top.parentItem.Id + ".sortField"] - sortAscendingStr = m.global.session.user.settings["display." + m.top.parentItem.Id + ".sortAscending"] - m.filter = m.global.session.user.settings["display." + m.top.parentItem.Id + ".filter"] + m.view = userSettings["display.music.view"] + m.sortField = userSettings["display." + m.top.parentItem.Id + ".sortField"] + sortAscendingStr = userSettings["display." + m.top.parentItem.Id + ".sortAscending"] + m.filter = userSettings["display." + m.top.parentItem.Id + ".filter"] else - m.sortField = m.global.session.user.settings["display." + m.top.parentItem.Id + ".sortField"] - sortAscendingStr = m.global.session.user.settings["display." + m.top.parentItem.Id + ".sortAscending"] - m.filter = m.global.session.user.settings["display." + m.top.parentItem.Id + ".filter"] - m.view = m.global.session.user.settings["display." + m.top.parentItem.Id + ".landing"] + m.sortField = userSettings["display." + m.top.parentItem.Id + ".sortField"] + sortAscendingStr = userSettings["display." + m.top.parentItem.Id + ".sortAscending"] + m.filter = userSettings["display." + m.top.parentItem.Id + ".filter"] + m.view = userSettings["display." + m.top.parentItem.Id + ".landing"] end if if m.sortField = invalid @@ -180,7 +183,7 @@ sub loadInitialItems() m.loadItemsTask.itemType = "MusicArtist" m.loadItemsTask.itemId = m.top.parentItem.Id - m.view = m.global.session.user.settings["display.music.view"] + m.view = userSettings["display.music.view"] if m.view = "music-album" m.loadItemsTask.itemType = "MusicAlbum" @@ -191,7 +194,7 @@ sub loadInitialItems() ' For LiveTV, we want to "Fit" the item images, not zoom m.top.imageDisplayMode = "scaleToFit" - if m.global.session.user.settings["display.livetv.landing"] = "guide" and m.options.view <> "livetv" + if userSettings["display.livetv.landing"] = "guide" and m.options.view <> "livetv" showTvGuide() end if else if m.top.parentItem.collectionType = "CollectionFolder" or m.top.parentItem.type = "CollectionFolder" or m.top.parentItem.collectionType = "boxsets" or m.top.parentItem.Type = "Boxset" or m.top.parentItem.Type = "Boxsets" or m.top.parentItem.Type = "Folder" or m.top.parentItem.Type = "Channel" diff --git a/components/ItemGrid/LoadVideoContentTask.bs b/components/ItemGrid/LoadVideoContentTask.bs index 74da4f449..1ab4edbb0 100644 --- a/components/ItemGrid/LoadVideoContentTask.bs +++ b/components/ItemGrid/LoadVideoContentTask.bs @@ -17,21 +17,23 @@ sub init() end sub sub loadItems() + queueManager = m.global.queueManager + ' Reset intro tracker in case task gets reused m.top.isIntro = false ' Only show preroll once per queue - if m.global.queueManager.callFunc("isPrerollActive") + if queueManager.callFunc("isPrerollActive") ' Prerolls not allowed if we're resuming video - if m.global.queueManager.callFunc("getCurrentItem").startingPoint = 0 + if queueManager.callFunc("getCurrentItem").startingPoint = 0 preRoll = GetIntroVideos(m.top.itemId) if isValid(preRoll) and preRoll.TotalRecordCount > 0 and isValid(preRoll.items[0]) ' If an error is thrown in the Intros plugin, instead of passing the error they pass the entire rick roll music video. ' Bypass the music video and treat it as an error message if lcase(preRoll.items[0].name) <> "rick roll'd" - m.global.queueManager.callFunc("push", m.global.queueManager.callFunc("getCurrentItem")) + queueManager.callFunc("push", queueManager.callFunc("getCurrentItem")) m.top.itemId = preRoll.items[0].id - m.global.queueManager.callFunc("setPrerollStatus", false) + queueManager.callFunc("setPrerollStatus", false) m.top.isIntro = true end if end if @@ -39,7 +41,7 @@ sub loadItems() end if if m.top.selectedAudioStreamIndex = 0 - currentItem = m.global.queueManager.callFunc("getCurrentItem") + currentItem = queueManager.callFunc("getCurrentItem") if isValid(currentItem) and isValid(currentItem.json) m.top.selectedAudioStreamIndex = FindPreferredAudioStream(currentItem.json.MediaStreams) end if @@ -79,6 +81,10 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s return end if + queueManager = m.global.queueManager + userSession = m.global.session.user + userSettings = userSession.settings + videotype = LCase(meta.type) ' Check for any Live TV streams or Recordings coming from other places other than the TV Guide @@ -119,15 +125,14 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s end if if LCase(m.top.itemType) = "episode" - userSession = m.global.session.user - if userSession.settings["playback.playnextepisode"] = "enabled" or userSession.settings["playback.playnextepisode"] = "webclient" and userSession.Configuration.EnableNextEpisodeAutoPlay + if userSettings["playback.playnextepisode"] = "enabled" or userSettings["playback.playnextepisode"] = "webclient" and userSession.Configuration.EnableNextEpisodeAutoPlay addNextEpisodesToQueue(video.showID) end if end if playbackPosition = 0! - currentItem = m.global.queueManager.callFunc("getCurrentItem") + currentItem = queueManager.callFunc("getCurrentItem") if isValid(currentItem) and isValid(currentItem.startingPoint) playbackPosition = currentItem.startingPoint @@ -209,8 +214,8 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s ' transcode is that the Encoding Level is not supported, then try to direct play but silently ' fall back to the transcode if that fails. if m.playbackInfo.MediaSources[0].MediaStreams.Count() > 0 and meta.live = false - tryDirectPlay = m.global.session.user.settings["playback.tryDirect.h264ProfileLevel"] and m.playbackInfo.MediaSources[0].MediaStreams[0].codec = "h264" - tryDirectPlay = tryDirectPlay or (m.global.session.user.settings["playback.tryDirect.hevcProfileLevel"] and m.playbackInfo.MediaSources[0].MediaStreams[0].codec = "hevc") + tryDirectPlay = userSettings["playback.tryDirect.h264ProfileLevel"] and m.playbackInfo.MediaSources[0].MediaStreams[0].codec = "h264" + tryDirectPlay = tryDirectPlay or (userSettings["playback.tryDirect.hevcProfileLevel"] and m.playbackInfo.MediaSources[0].MediaStreams[0].codec = "hevc") if tryDirectPlay and isValid(m.playbackInfo.MediaSources[0].TranscodingUrl) and forceTranscoding = false transcodingReasons = getTranscodeReasons(m.playbackInfo.MediaSources[0].TranscodingUrl) if transcodingReasons.Count() = 1 and transcodingReasons[0] = "VideoLevelNotSupported" @@ -250,7 +255,8 @@ end sub ' @param {dynamic} videoID - id of video user is playing ' @return {integer} indicating the default track's server-side index. Defaults to {SubtitleSelection.none} is one is not found function defaultSubtitleTrackFromVid(videoID) as integer - if m.global.session.user.configuration.SubtitleMode = "None" + userSession = m.global.session.user + if userSession.configuration.SubtitleMode = "None" return SubtitleSelection.none ' No subtitles desired: return none end if @@ -276,7 +282,7 @@ function defaultSubtitleTrackFromVid(videoID) as integer return defaultTextSubs end if - if not m.global.session.user.settings["playback.subs.onlytext"] + if not userSession.settings["playback.subs.onlytext"] return defaultSubtitleTrack(subtitles["all"], selectedAudioLanguage) ' if no appropriate text subs exist, allow non-text end if @@ -476,6 +482,8 @@ end function ' Add next episodes to the playback queue sub addNextEpisodesToQueue(showID) + queueManager = m.global.queueManager + ' Don't queue next episodes if we already have a playback queue maxQueueCount = 1 @@ -483,13 +491,13 @@ sub addNextEpisodesToQueue(showID) maxQueueCount = 2 end if - if m.global.queueManager.callFunc("getCount") > maxQueueCount then return + if queueManager.callFunc("getCount") > maxQueueCount then return videoID = m.top.itemId ' If first item is an intro video, use the next item in the queue if m.top.isIntro - currentVideo = m.global.queueManager.callFunc("getItemByIndex", 1) + currentVideo = queueManager.callFunc("getItemByIndex", 1) if isValid(currentVideo) and isValid(currentVideo.id) videoID = currentVideo.id @@ -511,7 +519,7 @@ sub addNextEpisodesToQueue(showID) if isValid(data) and data.Items.Count() > 1 for i = 1 to data.Items.Count() - 1 - m.global.queueManager.callFunc("push", data.Items[i]) + queueManager.callFunc("push", data.Items[i]) end for end if end sub @@ -570,8 +578,9 @@ function sortSubtitles(id as string, MediaStreams) end function function FindPreferredAudioStream(streams as dynamic) as integer - preferredLanguage = m.global.session.user.Configuration.AudioLanguagePreference - playDefault = m.global.session.user.Configuration.PlayDefaultAudioTrack + userConfig = m.global.session.user.configuration + preferredLanguage = userConfig.AudioLanguagePreference + playDefault = userConfig.PlayDefaultAudioTrack if playDefault <> invalid and playDefault = true return 1 diff --git a/components/ItemGrid/MovieLibraryView.bs b/components/ItemGrid/MovieLibraryView.bs index 5ff0fae71..1f7294f5f 100644 --- a/components/ItemGrid/MovieLibraryView.bs +++ b/components/ItemGrid/MovieLibraryView.bs @@ -30,6 +30,7 @@ end sub sub init() setupNodes() + userSettings = m.global.session.user.settings m.overhang.isVisible = false @@ -39,7 +40,7 @@ sub init() alphaMicText = m.alpha.findNode("alphaMicText") alphaMicText.visible = false - m.showItemCount = m.global.session.user.settings["itemgrid.showItemCount"] + m.showItemCount = userSettings["itemgrid.showItemCount"] m.swapAnimation.observeField("state", "swapDone") @@ -86,7 +87,7 @@ sub init() m.loadItemsTask.totalRecordCount = 0 'Get reset folder setting - m.resetGrid = m.global.session.user.settings["itemgrid.reset"] + m.resetGrid = userSettings["itemgrid.reset"] end sub sub OnScreenHidden() @@ -112,6 +113,7 @@ end sub sub loadInitialItems() m.loadItemsTask.control = "stop" startLoadingSpinner(false) + userSettings = m.global.session.user.settings if m.top.parentItem.json.Type = "CollectionFolder" m.top.HomeLibraryItem = m.top.parentItem.Id @@ -123,15 +125,15 @@ sub loadInitialItems() SetBackground("") end if - m.sortField = m.global.session.user.settings["display." + m.top.parentItem.Id + ".sortField"] - m.filter = m.global.session.user.settings["display." + m.top.parentItem.Id + ".filter"] - m.filterOptions = m.global.session.user.settings["display." + m.top.parentItem.Id + ".filterOptions"] - m.view = m.global.session.user.settings["display." + m.top.parentItem.Id + ".landing"] - m.sortAscending = m.global.session.user.settings["display." + m.top.parentItem.Id + ".sortAscending"] + m.sortField = userSettings["display." + m.top.parentItem.Id + ".sortField"] + m.filter = userSettings["display." + m.top.parentItem.Id + ".filter"] + m.filterOptions = userSettings["display." + m.top.parentItem.Id + ".filterOptions"] + m.view = userSettings["display." + m.top.parentItem.Id + ".landing"] + m.sortAscending = userSettings["display." + m.top.parentItem.Id + ".sortAscending"] ' If user has not set a preferred view for this folder, check if they've set a default view if not isValid(m.view) - m.view = m.global.session.user.settings["itemgrid.movieDefaultView"] + m.view = userSettings["itemgrid.movieDefaultView"] end if if not isValid(m.sortField) then m.sortField = "SortName" @@ -200,7 +202,7 @@ sub loadInitialItems() m.itemGrid.numRows = "3" m.selectedMovieOverview.visible = false m.infoGroup.visible = false - m.top.showItemTitles = m.global.session.user.settings["itemgrid.gridTitles"] + m.top.showItemTitles = userSettings["itemgrid.gridTitles"] if LCase(m.top.showItemTitles) = "hidealways" m.itemGrid.itemSize = "[230, 315]" m.itemGrid.rowHeights = "[315]" diff --git a/components/ItemGrid/MusicLibraryView.bs b/components/ItemGrid/MusicLibraryView.bs index 8ff8c6ce2..efa883fee 100644 --- a/components/ItemGrid/MusicLibraryView.bs +++ b/components/ItemGrid/MusicLibraryView.bs @@ -25,6 +25,7 @@ end sub sub init() setupNodes() + userSettings = m.global.session.user.settings m.overhang.isVisible = false @@ -34,7 +35,7 @@ sub init() alphaMicText = m.alpha.findNode("alphaMicText") alphaMicText.visible = false - m.showItemCount = m.global.session.user.settings["itemgrid.showItemCount"] + m.showItemCount = userSettings["itemgrid.showItemCount"] m.swapAnimation.observeField("state", "swapDone") @@ -80,7 +81,7 @@ sub init() m.loadItemsTask.totalRecordCount = 0 'Get reset folder setting - m.resetGrid = m.global.session.user.settings["itemgrid.reset"] + m.resetGrid = userSettings["itemgrid.reset"] end sub sub OnScreenHidden() @@ -106,6 +107,7 @@ end sub sub loadInitialItems() m.loadItemsTask.control = "stop" startLoadingSpinner(false) + userSettings = m.global.session.user.settings if LCase(m.top.parentItem.json.Type) = "collectionfolder" m.top.HomeLibraryItem = m.top.parentItem.Id @@ -117,17 +119,17 @@ sub loadInitialItems() SetBackground("") end if - m.sortField = m.global.session.user.settings["display." + m.top.parentItem.Id + ".sortField"] - m.sortAscending = m.global.session.user.settings["display." + m.top.parentItem.Id + ".sortAscending"] - m.filter = m.global.session.user.settings["display." + m.top.parentItem.Id + ".filter"] - m.view = m.global.session.user.settings["display." + m.top.parentItem.Id + ".landing"] + m.sortField = userSettings["display." + m.top.parentItem.Id + ".sortField"] + m.sortAscending = userSettings["display." + m.top.parentItem.Id + ".sortAscending"] + m.filter = userSettings["display." + m.top.parentItem.Id + ".filter"] + m.view = userSettings["display." + m.top.parentItem.Id + ".landing"] if not isValid(m.sortField) then m.sortField = "SortName" if not isValid(m.filter) then m.filter = "All" if not isValid(m.view) then m.view = "ArtistsPresentation" if not isValid(m.sortAscending) then m.sortAscending = true - m.top.showItemTitles = m.global.session.user.settings["itemgrid.gridTitles"] + m.top.showItemTitles = userSettings["itemgrid.gridTitles"] if LCase(m.top.parentItem.json.type) = "musicgenre" m.itemGrid.translation = "[96, 60]" diff --git a/components/JFVideo.bs b/components/JFVideo.bs index 5be3d8537..f7c631e0c 100644 --- a/components/JFVideo.bs +++ b/components/JFVideo.bs @@ -13,7 +13,8 @@ sub init() m.top.transcodeReasons = [] m.bufferCheckTimer.duration = 30 - if m.global.session.user.settings["ui.design.hideclock"] = true + userSettings = m.global.session.user.settings + if userSettings["ui.design.hideclock"] clockNode = findNodeBySubtype(m.top, "clock") if clockNode[0] <> invalid then clockNode[0].parent.removeChild(clockNode[0].node) end if @@ -22,7 +23,7 @@ sub init() m.nextEpisodeButton = m.top.findNode("nextEpisode") m.nextEpisodeButton.text = tr("Next Episode") m.nextEpisodeButton.setFocus(false) - m.nextupbuttonseconds = m.global.session.user.settings["playback.nextupbuttonseconds"].ToInt() + m.nextupbuttonseconds = userSettings["playback.nextupbuttonseconds"].ToInt() m.showNextEpisodeButtonAnimation = m.top.findNode("showNextEpisodeButton") m.hideNextEpisodeButtonAnimation = m.top.findNode("hideNextEpisodeButton") diff --git a/components/ListPoster.bs b/components/ListPoster.bs index 223105044..59d309cc5 100644 --- a/components/ListPoster.bs +++ b/components/ListPoster.bs @@ -17,10 +17,10 @@ sub init() ' Randomize the background colors backdropColor = "#00a4db" ' set default in case global var is invalid - localGlobal = m.global + myGlobal = m.global - if isValid(localGlobal) and isValid(localGlobal.constants) and isValid(localGlobal.constants.poster_bg_pallet) - posterBackgrounds = localGlobal.constants.poster_bg_pallet + if isValid(myGlobal) and isValid(myGlobal.constants) and isValid(myGlobal.constants.poster_bg_pallet) + posterBackgrounds = myGlobal.constants.poster_bg_pallet backdropColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1] end if @@ -65,8 +65,9 @@ sub itemContentChanged() as void m.poster = m.top.findNode("poster") itemData = m.top.itemContent m.title.text = itemData.title + userSettings = m.global.session.user.settings - if m.global.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] = false + if not userSettings["ui.tvshows.disableUnwatchedEpisodeCount"] if isValid(itemData.json.UserData) and isValid(itemData.json.UserData.UnplayedItemCount) if itemData.json.UserData.UnplayedItemCount > 0 m.unplayedCount.visible = true @@ -94,7 +95,7 @@ sub itemContentChanged() as void imageUrl = itemData.posterURL - if m.global.session.user.settings["ui.tvshows.blurunwatched"] = true + if userSettings["ui.tvshows.blurunwatched"] if itemData.json.lookup("Type") = "Episode" and isValid(itemData.json.userdata) if not itemData.json.userdata.played imageUrl = imageUrl + "&blur=15" @@ -116,7 +117,7 @@ sub focusChanged() m.staticTitle.visible = false m.title.visible = true ' text to speech for accessibility - if m.global.device.isAudioGuideEnabled = true + if m.global.device.isAudioGuideEnabled txt2Speech = CreateObject("roTextToSpeech") txt2Speech.Flush() txt2Speech.Say(m.title.text) diff --git a/components/WhatsNewDialog.bs b/components/WhatsNewDialog.bs index a556de8f8..c528c4d60 100644 --- a/components/WhatsNewDialog.bs +++ b/components/WhatsNewDialog.bs @@ -1,11 +1,12 @@ sub init() m.content = m.top.findNode("content") + appVersion = m.global.app.version setPalette() m.top.id = "OKDialog" m.top.height = 900 - m.top.title = tr("Welcome to version") + " " + m.global.app.version + m.top.title = tr("Welcome to version") + " " + appVersion m.top.buttons = [tr("OK")] dialogStyles = { @@ -27,7 +28,7 @@ sub init() textLine = m.content.CreateChild("StdDlgMultiStyleTextItem") textLine.drawingStyles = dialogStyles - textLine.text = tr("To view a complete list of changes visit") + " https://github.com/jellyfin/jellyfin-roku/releases/tag/v" + m.global.app.version + "" + textLine.text = tr("To view a complete list of changes visit") + " https://github.com/jellyfin/jellyfin-roku/releases/tag/v" + appVersion + "" end sub sub setPalette() diff --git a/components/home/HomeItem.bs b/components/home/HomeItem.bs index b1ddeb2be..935130df9 100644 --- a/components/home/HomeItem.bs +++ b/components/home/HomeItem.bs @@ -22,10 +22,10 @@ sub init() ' Randomize the background colors backdropColor = "#00a4db" ' set default in case global var is invalid - localGlobal = m.global + myGlobal = m.global - if isValid(localGlobal) and isValid(localGlobal.constants) and isValid(localGlobal.constants.poster_bg_pallet) - posterBackgrounds = localGlobal.constants.poster_bg_pallet + if isValid(myGlobal) and isValid(myGlobal.constants) and isValid(myGlobal.constants.poster_bg_pallet) + posterBackgrounds = myGlobal.constants.poster_bg_pallet backdropColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1] end if @@ -54,7 +54,7 @@ sub itemContentChanged() if isValid(m.unplayedCount) then m.unplayedCount.visible = false itemData = m.top.itemContent if itemData = invalid then return - localGlobal = m.global + userSettings = m.global.session.user.settings itemData.Title = itemData.name ' Temporarily required while we move from "HomeItem" to "JFContentItem" @@ -69,9 +69,9 @@ sub itemContentChanged() m.itemTextExtra.width = itemData.imageWidth m.itemTextExtra.visible = true m.itemTextExtra.text = "" - m.backdrop.width = itemData.imageWidth + if isValid(itemData.iconUrl) m.itemIcon.uri = itemData.iconUrl end if @@ -82,8 +82,8 @@ sub itemContentChanged() m.playedIndicator.visible = false if LCase(itemData.type) = "series" - if isValid(localGlobal) and isValid(localGlobal.session) and isValid(localGlobal.session.user) and isValid(localGlobal.session.user.settings) - if not localGlobal.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] + if isValid(userSettings) + if not userSettings["ui.tvshows.disableUnwatchedEpisodeCount"] if isValid(itemData.json.UserData) and isValid(itemData.json.UserData.UnplayedItemCount) if itemData.json.UserData.UnplayedItemCount > 0 if isValid(m.unplayedCount) then m.unplayedCount.visible = true @@ -151,16 +151,16 @@ sub itemContentChanged() drawProgressBar(itemData) end if - if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "webclient" - tmpSetting = localGlobal.session.user.Configuration.useEpisodeImagesInNextUpAndResume + if userSettings["ui.general.episodeimagesnextup"] = "webclient" + tmpSetting = m.global.session.user.Configuration.useEpisodeImagesInNextUpAndResume if isValid(tmpSetting) and tmpSetting m.itemPoster.uri = itemData.thumbnailURL else m.itemPoster.uri = itemData.widePosterURL end if - else if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "show" + else if userSettings["ui.general.episodeimagesnextup"] = "show" m.itemPoster.uri = itemData.widePosterURL - else if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "episode" + else if userSettings["ui.general.episodeimagesnextup"] = "episode" m.itemPoster.uri = itemData.thumbnailURL end if diff --git a/components/home/HomeRows.bs b/components/home/HomeRows.bs index 598a08961..d691cb154 100644 --- a/components/home/HomeRows.bs +++ b/components/home/HomeRows.bs @@ -76,10 +76,11 @@ sub processUserSections() m.processedRowCount = 0 sessionUser = m.global.session.user + userSettings = sessionUser.settings ' calculate expected row count by processing homesections for i = 0 to 6 - userSection = sessionUser.settings["homesection" + i.toStr()] + userSection = userSettings["homesection" + i.toStr()] sectionName = userSection ?? "none" sectionName = LCase(sectionName) @@ -99,7 +100,7 @@ sub processUserSections() ' Add home sections in order based on user settings loadedSections = 0 for i = 0 to 6 - userSection = sessionUser.settings["homesection" + i.toStr()] + userSection = userSettings["homesection" + i.toStr()] sectionName = userSection ?? "none" sectionName = LCase(sectionName) @@ -149,10 +150,10 @@ function getOriginalSectionIndex(sectionName as string) as integer sectionIndex = 0 indexLatestMediaSection = 0 - sessionUser = m.global.session.user + userSettings = m.global.session.user.settings for i = 0 to 6 - userSection = sessionUser.settings["homesection" + i.toStr()] + userSection = userSettings["homesection" + i.toStr()] settingSectionName = userSection ?? "none" settingSectionName = LCase(settingSectionName) diff --git a/components/home/LoadItemsTask.bs b/components/home/LoadItemsTask.bs index f947d1250..b918a8df7 100644 --- a/components/home/LoadItemsTask.bs +++ b/components/home/LoadItemsTask.bs @@ -60,6 +60,7 @@ sub loadItems() ' Load Next Up else if m.top.itemsToLoad = "nextUp" + userSettings = m.global.session.user.settings url = "Shows/NextUp" params = {} @@ -68,12 +69,12 @@ sub loadItems() params["SortOrder"] = "Descending" params["ImageTypeLimit"] = 1 params["UserId"] = m.global.session.user.id - params["EnableRewatching"] = m.global.session.user.settings["ui.details.enablerewatchingnextup"] + params["EnableRewatching"] = userSettings["ui.details.enablerewatchingnextup"] params["DisableFirstEpisode"] = false params["limit"] = 24 params["EnableTotalRecordCount"] = false - maxDaysInNextUp = m.global.session.user.settings["ui.details.maxdaysnextup"].ToInt() + maxDaysInNextUp = userSettings["ui.details.maxdaysnextup"].ToInt() if isValid(maxDaysInNextUp) if maxDaysInNextUp > 0 dateToday = CreateObject("roDateTime") diff --git a/components/manager/ViewCreator.bs b/components/manager/ViewCreator.bs index c2efcd07c..58bd92a86 100644 --- a/components/manager/ViewCreator.bs +++ b/components/manager/ViewCreator.bs @@ -58,9 +58,9 @@ sub onSelectAudioPressed() audioData.data.push(audioStreamItem) end for - - m.global.sceneManager.callFunc("radioDialog", tr("Select Audio"), audioData) - m.global.sceneManager.observeField("returnData", "onSelectionMade") + sceneManager = m.global.sceneManager + sceneManager.callFunc("radioDialog", tr("Select Audio"), audioData) + sceneManager.observeField("returnData", "onSelectionMade") end sub ' User requested subtitle selection popup @@ -110,23 +110,25 @@ sub onSelectSubtitlePressed() "Type": "subtitleselection" }) - m.global.sceneManager.callFunc("radioDialog", tr("Select Subtitles"), subtitleData) - m.global.sceneManager.observeField("returnData", "onSelectionMade") + sceneManager = m.global.sceneManager + sceneManager.callFunc("radioDialog", tr("Select Subtitles"), subtitleData) + sceneManager.observeField("returnData", "onSelectionMade") end sub ' User has selected something from the radioDialog popup sub onSelectionMade() - m.global.sceneManager.unobserveField("returnData") + sceneManager = m.global.sceneManager + sceneManager.unobserveField("returnData") - if not isValid(m.global.sceneManager.returnData) then return - if not isValid(m.global.sceneManager.returnData.type) then return + if not isValid(sceneManager.returnData) then return + if not isValid(sceneManager.returnData.type) then return - if LCase(m.global.sceneManager.returnData.type) = "subtitleselection" + if LCase(sceneManager.returnData.type) = "subtitleselection" processSubtitleSelection() return end if - if LCase(m.global.sceneManager.returnData.type) = "audioselection" + if LCase(sceneManager.returnData.type) = "audioselection" processAudioSelection() return end if @@ -216,21 +218,24 @@ end sub ' Playback state change event handlers sub onStateChange() if LCase(m.view.state) = "finished" + sceneManager = m.global.sceneManager + queueManager = m.global.queueManager + ' Close any open dialogs - if m.global.sceneManager.callFunc("isDialogOpen") - m.global.sceneManager.callFunc("dismissDialog") + if sceneManager.callFunc("isDialogOpen") + sceneManager.callFunc("dismissDialog") end if ' If there is something next in the queue, play it - if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1 - m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveForward") - m.global.queueManager.callFunc("playQueue") + if queueManager.callFunc("getPosition") < queueManager.callFunc("getCount") - 1 + sceneManager.callFunc("clearPreviousScene") + queueManager.callFunc("moveForward") + queueManager.callFunc("playQueue") return end if ' Playback completed, return user to previous screen - m.global.sceneManager.callFunc("popScene") + sceneManager.callFunc("popScene") m.global.audioPlayer.loopMode = "" end if end sub diff --git a/components/movies/MovieDetails.bs b/components/movies/MovieDetails.bs index e7aa3d3ad..5812f4c47 100644 --- a/components/movies/MovieDetails.bs +++ b/components/movies/MovieDetails.bs @@ -97,6 +97,7 @@ sub itemContentChanged() ' Updates video metadata item = m.top.itemContent if isValid(item) and isValid(item.json) + userSettings = m.global.session.user.settings itemData = item.json m.top.id = itemData.id m.top.findNode("moviePoster").uri = m.top.itemContent.posterURL @@ -120,7 +121,7 @@ sub itemContentChanged() m.infoGroup.removeChild(m.top.findNode("officialRating")) end if - if m.global.session.user.settings["ui.movies.showRatings"] + if userSettings["ui.movies.showRatings"] if isValid(itemData.communityRating) setFieldText("communityRating", int(itemData.communityRating * 10) / 10) else @@ -145,7 +146,7 @@ sub itemContentChanged() if type(itemData.RunTimeTicks) = "LongInteger" setFieldText("runtime", stri(getRuntime()) + " mins") - if m.global.session.user.settings["ui.design.hideclock"] <> true + if userSettings["ui.design.hideclock"] <> true setFieldText("ends-at", tr("Ends at %1").Replace("%1", getEndTime())) end if end if @@ -173,7 +174,7 @@ sub itemContentChanged() m.top.findNode("details").removeChild(m.top.findNode("director")) end if - if m.global.session.user.settings["ui.details.hidetagline"] = false + if userSettings["ui.details.hidetagline"] = false if itemData.taglines.count() > 0 setFieldText("tagline", itemData.taglines[0]) end if diff --git a/components/music/AudioPlayerView.bs b/components/music/AudioPlayerView.bs index 12786a6bb..6270b0cae 100644 --- a/components/music/AudioPlayerView.bs +++ b/components/music/AudioPlayerView.bs @@ -9,9 +9,14 @@ sub init() m.lastRecordedPositionTimestamp = 0 m.scrubTimestamp = -1 - m.playlistTypeCount = m.global.queueManager.callFunc("getQueueUniqueTypes").count() + m.queueManager = m.global.queueManager + m.playlistTypeCount = m.queueManager.callFunc("getQueueUniqueTypes").count() + + m.audioPlayer = m.global.audioPlayer + m.audioPlayer.observeField("state", "audioStateChanged") + m.audioPlayer.observeField("position", "audioPositionChanged") + m.audioPlayer.observeField("bufferingStatus", "bufferPositionChanged") - setupAudioNode() setupAnimationTasks() setupButtons() setupInfoNodes() @@ -91,13 +96,6 @@ sub setupDataTasks() m.LoadScreenSaverTimeoutTask = CreateObject("roSGNode", "LoadScreenSaverTimeoutTask") end sub -' Creates audio node used to play song(s) -sub setupAudioNode() - m.global.audioPlayer.observeField("state", "audioStateChanged") - m.global.audioPlayer.observeField("position", "audioPositionChanged") - m.global.audioPlayer.observeField("bufferingStatus", "bufferPositionChanged") -end sub - ' Setup playback buttons, default to Play button selected sub setupButtons() m.buttons = m.top.findNode("buttons") @@ -149,10 +147,10 @@ end sub sub bufferPositionChanged() if m.inScrubMode then return - if not isValid(m.global.audioPlayer.bufferingStatus) + if not isValid(m.audioPlayer.bufferingStatus) bufferPositionBarWidth = m.seekBar.width else - bufferPositionBarWidth = m.seekBar.width * m.global.audioPlayer.bufferingStatus.percentage + bufferPositionBarWidth = m.seekBar.width * m.audioPlayer.bufferingStatus.percentage end if ' Ensure position bar is never wider than the seek bar @@ -168,16 +166,16 @@ end sub sub audioPositionChanged() stopLoadingSpinner() - if m.global.audioPlayer.position = 0 + if m.audioPlayer.position = 0 m.playPosition.width = 0 end if - if not isValid(m.global.audioPlayer.position) + if not isValid(m.audioPlayer.position) playPositionBarWidth = 0 else if not isValid(m.songDuration) playPositionBarWidth = 0 else - songPercentComplete = m.global.audioPlayer.position / m.songDuration + songPercentComplete = m.audioPlayer.position / m.songDuration playPositionBarWidth = m.seekBar.width * songPercentComplete end if @@ -189,7 +187,7 @@ sub audioPositionChanged() if not m.inScrubMode moveSeekbarThumb(playPositionBarWidth) ' Change the seek position timestamp - m.seekTimestamp.text = secondsToHuman(m.global.audioPlayer.position, false) + m.seekTimestamp.text = secondsToHuman(m.audioPlayer.position, false) end if ' Use animation to make the display smooth @@ -197,9 +195,9 @@ sub audioPositionChanged() m.playPositionAnimation.control = "start" ' Update displayed position timestamp - if isValid(m.global.audioPlayer.position) - m.lastRecordedPositionTimestamp = m.global.audioPlayer.position - m.positionTimestamp.text = secondsToHuman(m.global.audioPlayer.position, false) + if isValid(m.audioPlayer.position) + m.lastRecordedPositionTimestamp = m.audioPlayer.position + m.positionTimestamp.text = secondsToHuman(m.audioPlayer.position, false) else m.lastRecordedPositionTimestamp = 0 m.positionTimestamp.text = "0:00" @@ -247,25 +245,24 @@ sub endScreenSaver() end sub sub audioStateChanged() - ' Song Finished, attempt to move to next song - if m.global.audioPlayer.state = "finished" + if m.audioPlayer.state = "finished" ' User has enabled single song loop, play current song again - if m.global.audioPlayer.loopMode = "one" + if m.audioPlayer.loopMode = "one" m.scrubTimestamp = -1 playAction() exitScrubMode() return end if - if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1 + if m.queueManager.callFunc("getPosition") < m.queueManager.callFunc("getCount") - 1 m.top.state = "finished" else ' We are at the end of the song queue ' User has enabled loop for entire song queue, move back to first song - if m.global.audioPlayer.loopMode = "all" - m.global.queueManager.callFunc("setPosition", -1) + if m.audioPlayer.loopMode = "all" + m.queueManager.callFunc("setPosition", -1) LoadNextSong() return end if @@ -277,18 +274,19 @@ sub audioStateChanged() end sub function playAction() as boolean - if m.global.audioPlayer.state = "playing" - m.global.audioPlayer.control = "pause" + + if m.audioPlayer.state = "playing" + m.audioPlayer.control = "pause" ' Allow screen to go to real screensaver WriteAsciiFile("tmp:/scene.temp", "nowplaying-paused") MoveFile("tmp:/scene.temp", "tmp:/scene") - else if m.global.audioPlayer.state = "paused" - m.global.audioPlayer.control = "resume" + else if m.audioPlayer.state = "paused" + m.audioPlayer.control = "resume" ' Write screen tracker for screensaver WriteAsciiFile("tmp:/scene.temp", "nowplaying") MoveFile("tmp:/scene.temp", "tmp:/scene") - else if m.global.audioPlayer.state = "finished" - m.global.audioPlayer.control = "play" + else if m.audioPlayer.state = "finished" + m.audioPlayer.control = "play" ' Write screen tracker for screensaver WriteAsciiFile("tmp:/scene.temp", "nowplaying") MoveFile("tmp:/scene.temp", "tmp:/scene") @@ -298,20 +296,19 @@ function playAction() as boolean end function function previousClicked() as boolean - currentQueuePosition = m.global.queueManager.callFunc("getPosition") - + currentQueuePosition = m.queueManager.callFunc("getPosition") if currentQueuePosition = 0 then return false if m.playlistTypeCount > 1 - previousItem = m.global.queueManager.callFunc("getItemByIndex", currentQueuePosition - 1) - previousItemType = m.global.queueManager.callFunc("getItemType", previousItem) + previousItem = m.queueManager.callFunc("getItemByIndex", currentQueuePosition - 1) + previousItemType = m.queueManager.callFunc("getItemType", previousItem) if previousItemType <> "audio" - m.global.audioPlayer.control = "stop" + m.audioPlayer.control = "stop" m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveBack") - m.global.queueManager.callFunc("playQueue") + m.queueManager.callFunc("moveBack") + m.queueManager.callFunc("playQueue") return true end if end if @@ -321,34 +318,33 @@ function previousClicked() as boolean m.lastRecordedPositionTimestamp = 0 m.positionTimestamp.text = "0:00" - if m.global.audioPlayer.state = "playing" - m.global.audioPlayer.control = "stop" + if m.audioPlayer.state = "playing" + m.audioPlayer.control = "stop" end if ' Reset loop mode due to manual user interaction - if m.global.audioPlayer.loopMode = "one" + if m.audioPlayer.loopMode = "one" resetLoopModeToDefault() end if - m.global.queueManager.callFunc("moveBack") + m.queueManager.callFunc("moveBack") pageContentChanged() return true end function sub resetLoopModeToDefault() - m.global.audioPlayer.loopMode = "" + m.audioPlayer.loopMode = "" setLoopButtonImage() end sub function loopClicked() as boolean - - if m.global.audioPlayer.loopMode = "" - m.global.audioPlayer.loopMode = "all" - else if m.global.audioPlayer.loopMode = "all" - m.global.audioPlayer.loopMode = "one" + if m.audioPlayer.loopMode = "" + m.audioPlayer.loopMode = "all" + else if m.audioPlayer.loopMode = "all" + m.audioPlayer.loopMode = "one" else - m.global.audioPlayer.loopMode = "" + m.audioPlayer.loopMode = "" end if setLoopButtonImage() @@ -357,10 +353,10 @@ function loopClicked() as boolean end function sub setLoopButtonImage() - if m.global.audioPlayer.loopMode = "all" + if m.audioPlayer.loopMode = "all" m.loopIndicator.opacity = "1" m.loopIndicator.uri = m.loopIndicator.uri.Replace("-off", "-on") - else if m.global.audioPlayer.loopMode = "one" + else if m.audioPlayer.loopMode = "one" m.loopIndicator.uri = m.loopIndicator.uri.Replace("-on", "1-on") else m.loopIndicator.uri = m.loopIndicator.uri.Replace("1-on", "-off") @@ -368,19 +364,20 @@ sub setLoopButtonImage() end sub function nextClicked() as boolean + if m.playlistTypeCount > 1 - currentQueuePosition = m.global.queueManager.callFunc("getPosition") - if currentQueuePosition < m.global.queueManager.callFunc("getCount") - 1 + currentQueuePosition = m.queueManager.callFunc("getPosition") + if currentQueuePosition < m.queueManager.callFunc("getCount") - 1 - nextItem = m.global.queueManager.callFunc("getItemByIndex", currentQueuePosition + 1) - nextItemType = m.global.queueManager.callFunc("getItemType", nextItem) + nextItem = m.queueManager.callFunc("getItemByIndex", currentQueuePosition + 1) + nextItemType = m.queueManager.callFunc("getItemType", nextItem) if nextItemType <> "audio" - m.global.audioPlayer.control = "stop" + m.audioPlayer.control = "stop" m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveForward") - m.global.queueManager.callFunc("playQueue") + m.queueManager.callFunc("moveForward") + m.queueManager.callFunc("playQueue") return true end if end if @@ -392,11 +389,11 @@ function nextClicked() as boolean m.positionTimestamp.text = "0:00" ' Reset loop mode due to manual user interaction - if m.global.audioPlayer.loopMode = "one" + if m.audioPlayer.loopMode = "one" resetLoopModeToDefault() end if - if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1 + if m.queueManager.callFunc("getPosition") < m.queueManager.callFunc("getCount") - 1 LoadNextSong() end if @@ -404,14 +401,14 @@ function nextClicked() as boolean end function sub toggleShuffleEnabled() - m.global.queueManager.callFunc("toggleShuffle") + m.queueManager.callFunc("toggleShuffle") end sub function findCurrentSongIndex(songList) as integer if not isValidAndNotEmpty(songList) then return 0 for i = 0 to songList.count() - 1 - if songList[i].id = m.global.queueManager.callFunc("getCurrentItem").id + if songList[i].id = m.queueManager.callFunc("getCurrentItem").id return i end if end for @@ -420,15 +417,14 @@ function findCurrentSongIndex(songList) as integer end function function shuffleClicked() as boolean - - currentSongIndex = findCurrentSongIndex(m.global.queueManager.callFunc("getUnshuffledQueue")) + currentSongIndex = findCurrentSongIndex(m.queueManager.callFunc("getUnshuffledQueue")) toggleShuffleEnabled() - if not m.global.queueManager.callFunc("getIsShuffled") + if not m.queueManager.callFunc("getIsShuffled") m.shuffleIndicator.opacity = ".4" m.shuffleIndicator.uri = m.shuffleIndicator.uri.Replace("-on", "-off") - m.global.queueManager.callFunc("setPosition", currentSongIndex) + m.queueManager.callFunc("setPosition", currentSongIndex) setTrackNumberDisplay() return true end if @@ -441,26 +437,26 @@ function shuffleClicked() as boolean end function sub setShuffleIconState() - if m.global.queueManager.callFunc("getIsShuffled") + if m.queueManager.callFunc("getIsShuffled") m.shuffleIndicator.opacity = "1" m.shuffleIndicator.uri = m.shuffleIndicator.uri.Replace("-off", "-on") end if end sub sub setTrackNumberDisplay() - setFieldTextValue("numberofsongs", "Track " + stri(m.global.queueManager.callFunc("getPosition") + 1) + "/" + stri(m.global.queueManager.callFunc("getCount"))) + setFieldTextValue("numberofsongs", "Track " + stri(m.queueManager.callFunc("getPosition") + 1) + "/" + stri(m.queueManager.callFunc("getCount"))) end sub sub LoadNextSong() - if m.global.audioPlayer.state = "playing" - m.global.audioPlayer.control = "stop" + if m.audioPlayer.state = "playing" + m.audioPlayer.control = "stop" end if exitScrubMode() ' Reset playPosition bar without animation m.playPosition.width = 0 - m.global.queueManager.callFunc("moveForward") + m.queueManager.callFunc("moveForward") pageContentChanged() end sub @@ -469,7 +465,7 @@ sub pageContentChanged() m.LoadAudioStreamTask.control = "STOP" - currentItem = m.global.queueManager.callFunc("getCurrentItem") + currentItem = m.queueManager.callFunc("getCurrentItem") m.LoadAudioStreamTask.itemId = currentItem.id m.LoadAudioStreamTask.observeField("content", "onAudioStreamLoaded") @@ -478,7 +474,7 @@ end sub ' If we have more and 1 song to play, fade in the next and previous controls sub loadButtons() - if m.global.queueManager.callFunc("getCount") > 1 + if m.queueManager.callFunc("getCount") > 1 m.shuffleIndicator.opacity = ".4" m.loopIndicator.opacity = ".4" m.displayButtonsAnimation.control = "start" @@ -495,7 +491,7 @@ sub onAudioStreamLoaded() m.bufferPosition.width = 0 useMetaTask = false - currentItem = m.global.queueManager.callFunc("getCurrentItem") + currentItem = m.queueManager.callFunc("getCurrentItem") if not isValid(currentItem.RunTimeTicks) useMetaTask = true @@ -531,9 +527,9 @@ sub onAudioStreamLoaded() m.totalLengthTimestamp.text = ticksToHuman(currentItem.RunTimeTicks) end if - m.global.audioPlayer.content = data - m.global.audioPlayer.control = "none" - m.global.audioPlayer.control = "play" + m.audioPlayer.content = data + m.audioPlayer.control = "none" + m.audioPlayer.control = "play" end if end sub @@ -739,7 +735,7 @@ function onKeyEvent(key as string, press as boolean) as boolean if m.inScrubMode startLoadingSpinner() m.inScrubMode = false - m.global.audioPlayer.seek = m.scrubTimestamp + m.audioPlayer.seek = m.scrubTimestamp return true end if @@ -773,15 +769,15 @@ function onKeyEvent(key as string, press as boolean) as boolean end if if key = "back" - m.global.audioPlayer.control = "stop" - m.global.audioPlayer.loopMode = "" + m.audioPlayer.control = "stop" + m.audioPlayer.loopMode = "" else if key = "rewind" return previousClicked() else if key = "fastforward" return nextClicked() else if key = "left" if m.buttons.hasFocus() - if m.global.queueManager.callFunc("getCount") = 1 then return false + if m.queueManager.callFunc("getCount") = 1 then return false if m.top.selectedButtonIndex > 0 m.previouslySelectedButtonIndex = m.top.selectedButtonIndex @@ -791,7 +787,7 @@ function onKeyEvent(key as string, press as boolean) as boolean end if else if key = "right" if m.buttons.hasFocus() - if m.global.queueManager.callFunc("getCount") = 1 then return false + if m.queueManager.callFunc("getCount") = 1 then return false m.previouslySelectedButtonIndex = m.top.selectedButtonIndex if m.top.selectedButtonIndex < m.buttonCount - 1 then m.top.selectedButtonIndex = m.top.selectedButtonIndex + 1 diff --git a/components/photos/PhotoDetails.bs b/components/photos/PhotoDetails.bs index 07d16f67a..7e3571b27 100644 --- a/components/photos/PhotoDetails.bs +++ b/components/photos/PhotoDetails.bs @@ -10,8 +10,9 @@ sub init() m.textBackground = m.top.findNode("background") m.statusTimer = m.top.findNode("statusTimer") m.statusTimer.observeField("fire", "statusUpdate") - m.slideshow = m.global.session.user.settings["photos.slideshow"] - m.random = m.global.session.user.settings["photos.random"] + userSettings = m.global.session.user.settings + m.slideshow = userSettings["photos.slideshow"] + m.random = userSettings["photos.random"] m.showStatusAnimation = m.top.findNode("showStatusAnimation") m.hideStatusAnimation = m.top.findNode("hideStatusAnimation") diff --git a/components/settings/settings.bs b/components/settings/settings.bs index dec4b043c..55239d77d 100644 --- a/components/settings/settings.bs +++ b/components/settings/settings.bs @@ -91,26 +91,28 @@ sub settingFocused() m.integerSetting.visible = false m.radioSetting.visible = false + userSettings = m.global.session.user.settings + if selectedSetting.type = invalid return else if selectedSetting.type = "bool" m.boolSetting.visible = true - if m.global.session.user.settings[selectedSetting.settingName] = true + if userSettings[selectedSetting.settingName] = true m.boolSetting.checkedItem = 1 else m.boolSetting.checkedItem = 0 end if else if selectedSetting.type = "integer" - integerValue = m.global.session.user.settings[selectedSetting.settingName].ToStr() + integerValue = userSettings[selectedSetting.settingName].ToStr() if isValid(integerValue) m.integerSetting.text = integerValue end if m.integerSetting.visible = true else if LCase(selectedSetting.type) = "radio" - selectedValue = m.global.session.user.settings[selectedSetting.settingName] + selectedValue = userSettings[selectedSetting.settingName] radioContent = CreateObject("roSGNode", "ContentNode") @@ -173,7 +175,6 @@ sub boolSettingChanged() set_setting(selectedSetting.settingName, "true") ' setting specific triggers if selectedSetting.settingName = "global.rememberme" - print "m.global.session.user.id=", m.global.session.user.id set_setting("active_user", m.global.session.user.id) end if else diff --git a/components/tvshows/TVListDetails.bs b/components/tvshows/TVListDetails.bs index 986c73f25..5c72a513f 100644 --- a/components/tvshows/TVListDetails.bs +++ b/components/tvshows/TVListDetails.bs @@ -21,6 +21,7 @@ end sub sub itemContentChanged() item = m.top.itemContent itemData = item.json + userSettings = m.global.session.user.settings ' Set default video source if user hasn't selected one yet if item.selectedVideoStreamId = "" and isValid(itemData.MediaSources) @@ -46,7 +47,7 @@ sub itemContentChanged() imageUrl = item.posterURL - if m.global.session.user.settings["ui.tvshows.blurunwatched"] = true + if userSettings["ui.tvshows.blurunwatched"] = true if itemData.lookup("Type") = "Episode" if not itemData.userdata.played imageUrl = imageUrl + "&blur=15" @@ -64,12 +65,12 @@ sub itemContentChanged() m.top.findNode("runtime").text = stri(runTime).trim() + " mins" end if - if m.global.session.user.settings["ui.design.hideclock"] <> true + if userSettings["ui.design.hideclock"] <> true m.top.findNode("endtime").text = tr("Ends at %1").Replace("%1", getEndTime()) end if end if - if m.global.session.user.settings["ui.tvshows.disableCommunityRating"] = false + if userSettings["ui.tvshows.disableCommunityRating"] = false if isValid(itemData.communityRating) m.top.findNode("star").visible = true m.top.findNode("communityRating").text = str(int(itemData.communityRating * 10) / 10) diff --git a/components/tvshows/TVShowDetails.bs b/components/tvshows/TVShowDetails.bs index 241845905..b460ad8f6 100644 --- a/components/tvshows/TVShowDetails.bs +++ b/components/tvshows/TVShowDetails.bs @@ -181,8 +181,9 @@ end function sub onShuffleEpisodeDataLoaded() m.getShuffleEpisodesTask.unobserveField("data") - m.global.queueManager.callFunc("set", m.getShuffleEpisodesTask.data.items) - m.global.queueManager.callFunc("playQueue") + queueManager = m.global.queueManager + queueManager.callFunc("set", m.getShuffleEpisodesTask.data.items) + queueManager.callFunc("playQueue") end sub function onKeyEvent(key as string, press as boolean) as boolean diff --git a/components/video/OSD.bs b/components/video/OSD.bs index 4f687c7a4..95928db45 100644 --- a/components/video/OSD.bs +++ b/components/video/OSD.bs @@ -35,7 +35,6 @@ sub init() m.optionControls.buttonFocused = m.optionControls.getChildCount() - 1 m.videoControls.getChild(m.defaultButtonIndex).focus = true - m.deviceInfo = CreateObject("roDeviceInfo") end sub ' onProgressPercentageChanged: Handler for changes to m.top.progressPercentage param @@ -211,7 +210,8 @@ sub inactiveCheck() return end if - if m.deviceInfo.timeSinceLastKeypress() >= m.top.inactiveTimeout + deviceInfo = CreateObject("roDeviceInfo") + if deviceInfo.timeSinceLastKeypress() >= m.top.inactiveTimeout m.top.action = "hide" end if end sub diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index b662cfcf9..0c881583b 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -6,6 +6,7 @@ sub init() m.log = log.Logger("VideoPlayerView") ' Hide the overhang on init to prevent showing 2 clocks m.top.getScene().findNode("overhang").visible = false + userSettings = m.global.session.user.settings m.currentItem = m.global.queueManager.callFunc("getCurrentItem") m.top.id = m.currentItem.id @@ -45,7 +46,7 @@ sub init() m.top.transcodeReasons = [] m.bufferCheckTimer.duration = 30 - if m.global.session.user.settings["ui.design.hideclock"] = true + if userSettings["ui.design.hideclock"] = true clockNode = findNodeBySubtype(m.top, "clock") if clockNode[0] <> invalid then clockNode[0].parent.removeChild(clockNode[0].node) end if @@ -54,7 +55,7 @@ sub init() m.nextEpisodeButton = m.top.findNode("nextEpisode") m.nextEpisodeButton.text = tr("Next Episode") m.nextEpisodeButton.setFocus(false) - m.nextupbuttonseconds = m.global.session.user.settings["playback.nextupbuttonseconds"].ToInt() + m.nextupbuttonseconds = userSettings["playback.nextupbuttonseconds"].ToInt() m.showNextEpisodeButtonAnimation = m.top.findNode("showNextEpisodeButton") m.hideNextEpisodeButtonAnimation = m.top.findNode("hideNextEpisodeButton") @@ -99,24 +100,28 @@ end sub ' @param {string} action - skip action to take sub handleItemSkipAction(action as string) if action = "itemnext" + queueManager = m.global.queueManager + ' If there is something next in the queue, play it - if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1 + if queueManager.callFunc("getPosition") < queueManager.callFunc("getCount") - 1 m.top.control = "stop" m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveForward") - m.global.queueManager.callFunc("playQueue") + queueManager.callFunc("moveForward") + queueManager.callFunc("playQueue") end if return end if if action = "itemback" + queueManager = m.global.queueManager + ' If there is something previous in the queue, play it - if m.global.queueManager.callFunc("getPosition") > 0 + if queueManager.callFunc("getPosition") > 0 m.top.control = "stop" m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveBack") - m.global.queueManager.callFunc("playQueue") + queueManager.callFunc("moveBack") + queueManager.callFunc("playQueue") end if return @@ -520,9 +525,9 @@ sub showNextEpisodeButton() if m.top.content.contenttype <> 4 then return ' only display when content is type "Episode" if m.nextupbuttonseconds = 0 then return ' is the button disabled? if m.nextEpisodeButton.opacity <> 0 then return - userSession = m.global.session.user - if userSession.settings["playback.playnextepisode"] = "disabled" then return - if userSession.settings["playback.playnextepisode"] = "webclient" and not userSession.Configuration.EnableNextEpisodeAutoPlay then return + userSettings = m.global.session.user.settings + if userSettings["playback.playnextepisode"] = "disabled" then return + if userSettings["playback.playnextepisode"] = "webclient" and not m.global.session.user.Configuration.EnableNextEpisodeAutoPlay then return m.nextEpisodeButton.visible = true m.showNextEpisodeButtonAnimation.control = "start"