diff --git a/components/ItemGrid/ItemGrid.bs b/components/ItemGrid/ItemGrid.bs index 759bacd7e..e7c59fd1e 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()") + myGlobal = m.global + m.options = m.top.findNode("options") - m.showItemCount = m.global.session.user.settings["itemgrid.showItemCount"] + m.showItemCount = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["itemgrid.reset"] - m.top.gridTitles = m.global.session.user.settings["itemgrid.gridTitles"] + m.top.gridTitles = myGlobal.session.user.settings["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() + myGlobal = m.global 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 = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["display.livetv.sortField"] + sortAscendingStr = myGlobal.session.user.settings["display.livetv.sortAscending"] + m.filter = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["display.music.view"] + m.sortField = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".sortField"] + sortAscendingStr = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".sortAscending"] + m.filter = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".sortField"] + sortAscendingStr = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".sortAscending"] + m.filter = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".filter"] + m.view = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["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 myGlobal.session.user.settings["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/ItemGridOptions.bs b/components/ItemGrid/ItemGridOptions.bs index 7a10e11dd..d52e8264e 100644 --- a/components/ItemGrid/ItemGridOptions.bs +++ b/components/ItemGrid/ItemGridOptions.bs @@ -131,12 +131,13 @@ sub optionsSet() m.menus[1].content = sortContent m.menus[1].checkedItem = m.selectedSortIndex + myGlobal = m.global if m.top.sortAscending = 1 - m.menus[1].focusedCheckedIconUri = m.global.constants.icons.ascending_black - m.menus[1].checkedIconUri = m.global.constants.icons.ascending_white + m.menus[1].focusedCheckedIconUri = myGlobal.constants.icons.ascending_black + m.menus[1].checkedIconUri = myGlobal.constants.icons.ascending_white else - m.menus[1].focusedCheckedIconUri = m.global.constants.icons.descending_black - m.menus[1].checkedIconUri = m.global.constants.icons.descending_white + m.menus[1].focusedCheckedIconUri = myGlobal.constants.icons.descending_black + m.menus[1].checkedIconUri = myGlobal.constants.icons.descending_white end if end if @@ -300,9 +301,10 @@ function onKeyEvent(key as string, press as boolean) as boolean ' Handle Sort screen if m.selectedItem = 1 + myGlobal = m.global if m.menus[1].itemSelected <> m.selectedSortIndex - m.menus[1].focusedCheckedIconUri = m.global.constants.icons.ascending_black - m.menus[1].checkedIconUri = m.global.constants.icons.ascending_white + m.menus[1].focusedCheckedIconUri = myGlobal.constants.icons.ascending_black + m.menus[1].checkedIconUri = myGlobal.constants.icons.ascending_white m.selectedSortIndex = m.menus[1].itemSelected m.top.sortAscending = true @@ -311,12 +313,12 @@ function onKeyEvent(key as string, press as boolean) as boolean if m.top.sortAscending = true m.top.sortAscending = false - m.menus[1].focusedCheckedIconUri = m.global.constants.icons.descending_black - m.menus[1].checkedIconUri = m.global.constants.icons.descending_white + m.menus[1].focusedCheckedIconUri = myGlobal.constants.icons.descending_black + m.menus[1].checkedIconUri = myGlobal.constants.icons.descending_white else m.top.sortAscending = true - m.menus[1].focusedCheckedIconUri = m.global.constants.icons.ascending_black - m.menus[1].checkedIconUri = m.global.constants.icons.ascending_white + m.menus[1].focusedCheckedIconUri = myGlobal.constants.icons.ascending_black + m.menus[1].checkedIconUri = myGlobal.constants.icons.ascending_white end if end if end if diff --git a/components/ItemGrid/LoadVideoContentTask.bs b/components/ItemGrid/LoadVideoContentTask.bs index 74da4f449..872c340d1 100644 --- a/components/ItemGrid/LoadVideoContentTask.bs +++ b/components/ItemGrid/LoadVideoContentTask.bs @@ -17,21 +17,22 @@ sub init() end sub sub loadItems() + myGlobal = m.global ' 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 myGlobal.queueManager.callFunc("isPrerollActive") ' Prerolls not allowed if we're resuming video - if m.global.queueManager.callFunc("getCurrentItem").startingPoint = 0 + if myGlobal.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")) + myGlobal.queueManager.callFunc("push", myGlobal.queueManager.callFunc("getCurrentItem")) m.top.itemId = preRoll.items[0].id - m.global.queueManager.callFunc("setPrerollStatus", false) + myGlobal.queueManager.callFunc("setPrerollStatus", false) m.top.isIntro = true end if end if @@ -39,7 +40,7 @@ sub loadItems() end if if m.top.selectedAudioStreamIndex = 0 - currentItem = m.global.queueManager.callFunc("getCurrentItem") + currentItem = myGlobal.queueManager.callFunc("getCurrentItem") if isValid(currentItem) and isValid(currentItem.json) m.top.selectedAudioStreamIndex = FindPreferredAudioStream(currentItem.json.MediaStreams) end if @@ -79,6 +80,8 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s return end if + myGlobal = m.global + videotype = LCase(meta.type) ' Check for any Live TV streams or Recordings coming from other places other than the TV Guide @@ -119,7 +122,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s end if if LCase(m.top.itemType) = "episode" - userSession = m.global.session.user + userSession = myGlobal.session.user if userSession.settings["playback.playnextepisode"] = "enabled" or userSession.settings["playback.playnextepisode"] = "webclient" and userSession.Configuration.EnableNextEpisodeAutoPlay addNextEpisodesToQueue(video.showID) end if @@ -127,7 +130,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s playbackPosition = 0! - currentItem = m.global.queueManager.callFunc("getCurrentItem") + currentItem = myGlobal.queueManager.callFunc("getCurrentItem") if isValid(currentItem) and isValid(currentItem.startingPoint) playbackPosition = currentItem.startingPoint @@ -209,8 +212,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 = myGlobal.session.user.settings["playback.tryDirect.h264ProfileLevel"] and m.playbackInfo.MediaSources[0].MediaStreams[0].codec = "h264" + tryDirectPlay = tryDirectPlay or (myGlobal.session.user.settings["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" @@ -226,7 +229,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s else if m.playbackInfo.MediaSources[0].TranscodingUrl = invalid ' If server does not provide a transcode URL, display a message to the user - m.global.sceneManager.callFunc("userMessage", tr("Error Getting Playback Information"), tr("An error was encountered while playing this item. Server did not provide required transcoding data.")) + myGlobal.sceneManager.callFunc("userMessage", tr("Error Getting Playback Information"), tr("An error was encountered while playing this item. Server did not provide required transcoding data.")) video.errorMsg = "Error getting playback information" video.content = invalid return @@ -250,7 +253,9 @@ 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" + myGlobal = m.global + + if myGlobal.session.user.configuration.SubtitleMode = "None" return SubtitleSelection.none ' No subtitles desired: return none end if @@ -276,7 +281,7 @@ function defaultSubtitleTrackFromVid(videoID) as integer return defaultTextSubs end if - if not m.global.session.user.settings["playback.subs.onlytext"] + if not myGlobal.session.user.settings["playback.subs.onlytext"] return defaultSubtitleTrack(subtitles["all"], selectedAudioLanguage) ' if no appropriate text subs exist, allow non-text end if @@ -476,6 +481,7 @@ end function ' Add next episodes to the playback queue sub addNextEpisodesToQueue(showID) + myGlobal = m.global ' Don't queue next episodes if we already have a playback queue maxQueueCount = 1 @@ -483,13 +489,13 @@ sub addNextEpisodesToQueue(showID) maxQueueCount = 2 end if - if m.global.queueManager.callFunc("getCount") > maxQueueCount then return + if myGlobal.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 = myGlobal.queueManager.callFunc("getItemByIndex", 1) if isValid(currentVideo) and isValid(currentVideo.id) videoID = currentVideo.id @@ -503,7 +509,7 @@ sub addNextEpisodesToQueue(showID) end if url = Substitute("Shows/{0}/Episodes", showID) - urlParams = { "UserId": m.global.session.user.id } + urlParams = { "UserId": myGlobal.session.user.id } urlParams.Append({ "StartItemId": videoID }) urlParams.Append({ "Limit": 50 }) resp = APIRequest(url, urlParams) @@ -511,7 +517,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]) + myGlobal.queueManager.callFunc("push", data.Items[i]) end for end if end sub @@ -570,8 +576,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 + myGlobal = m.global + preferredLanguage = myGlobal.session.user.Configuration.AudioLanguagePreference + playDefault = myGlobal.session.user.Configuration.PlayDefaultAudioTrack if playDefault <> invalid and playDefault = true return 1 @@ -579,7 +586,7 @@ function FindPreferredAudioStream(streams as dynamic) as integer ' Do we already have the MediaStreams or not? if streams = invalid - url = Substitute("Users/{0}/Items/{1}", m.global.session.user.id, m.top.itemId) + url = Substitute("Users/{0}/Items/{1}", myGlobal.session.user.id, m.top.itemId) resp = APIRequest(url) jsonResponse = getJson(resp) diff --git a/components/ItemGrid/MovieLibraryView.bs b/components/ItemGrid/MovieLibraryView.bs index 5ff0fae71..c2ba78183 100644 --- a/components/ItemGrid/MovieLibraryView.bs +++ b/components/ItemGrid/MovieLibraryView.bs @@ -29,6 +29,7 @@ sub setupNodes() end sub sub init() + myGlobal = m.global setupNodes() 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 = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["itemgrid.reset"] end sub sub OnScreenHidden() @@ -112,6 +113,7 @@ end sub sub loadInitialItems() m.loadItemsTask.control = "stop" startLoadingSpinner(false) + myGlobal = m.global 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 = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".sortField"] + m.filter = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".filter"] + m.filterOptions = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".filterOptions"] + m.view = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".landing"] + m.sortAscending = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["itemgrid.gridTitles"] if LCase(m.top.showItemTitles) = "hidealways" m.itemGrid.itemSize = "[230, 315]" m.itemGrid.rowHeights = "[315]" @@ -222,7 +224,7 @@ sub loadInitialItems() m.getFiltersTask.observeField("filters", "FilterDataLoaded") m.getFiltersTask.params = { - userid: m.global.session.user.id, + userid: myGlobal.session.user.id, parentid: m.top.parentItem.Id, includeitemtypes: "Movie" } diff --git a/components/ItemGrid/MusicLibraryView.bs b/components/ItemGrid/MusicLibraryView.bs index 8ff8c6ce2..835a3e459 100644 --- a/components/ItemGrid/MusicLibraryView.bs +++ b/components/ItemGrid/MusicLibraryView.bs @@ -24,6 +24,7 @@ sub setupNodes() end sub sub init() + myGlobal = m.global setupNodes() 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 = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["itemgrid.reset"] end sub sub OnScreenHidden() @@ -106,6 +107,7 @@ end sub sub loadInitialItems() m.loadItemsTask.control = "stop" startLoadingSpinner(false) + myGlobal = m.global 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 = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".sortField"] + m.sortAscending = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".sortAscending"] + m.filter = myGlobal.session.user.settings["display." + m.top.parentItem.Id + ".filter"] + m.view = myGlobal.session.user.settings["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 = myGlobal.session.user.settings["itemgrid.gridTitles"] if LCase(m.top.parentItem.json.type) = "musicgenre" m.itemGrid.translation = "[96, 60]" diff --git a/components/ListPoster.bs b/components/ListPoster.bs index 223105044..e4340ed7a 100644 --- a/components/ListPoster.bs +++ b/components/ListPoster.bs @@ -65,8 +65,9 @@ sub itemContentChanged() as void m.poster = m.top.findNode("poster") itemData = m.top.itemContent m.title.text = itemData.title + myGlobal = m.global - if m.global.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] = false + if myGlobal.session.user.settings["ui.tvshows.disableUnwatchedEpisodeCount"] = false 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 myGlobal.session.user.settings["ui.tvshows.blurunwatched"] = true if itemData.json.lookup("Type") = "Episode" and isValid(itemData.json.userdata) if not itemData.json.userdata.played imageUrl = imageUrl + "&blur=15" diff --git a/components/home/HomeRows.bs b/components/home/HomeRows.bs index 598a08961..4b3f0420d 100644 --- a/components/home/HomeRows.bs +++ b/components/home/HomeRows.bs @@ -75,17 +75,17 @@ sub processUserSections() m.expectedRowCount = 1 ' the favorites row is hardcoded to always show atm m.processedRowCount = 0 - sessionUser = m.global.session.user + myGlobal = m.global ' calculate expected row count by processing homesections for i = 0 to 6 - userSection = sessionUser.settings["homesection" + i.toStr()] + userSection = myGlobal.session.user.settings["homesection" + i.toStr()] sectionName = userSection ?? "none" sectionName = LCase(sectionName) if sectionName = "latestmedia" ' expect 1 row per filtered media library - m.filteredLatest = filterNodeArray(m.libraryData, "id", sessionUser.configuration.LatestItemsExcludes) + m.filteredLatest = filterNodeArray(m.libraryData, "id", myGlobal.session.user.configuration.LatestItemsExcludes) for each latestLibrary in m.filteredLatest if latestLibrary.collectionType <> "boxsets" and latestLibrary.collectionType <> "livetv" and latestLibrary.json.CollectionType <> "Program" m.expectedRowCount++ @@ -99,7 +99,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 = myGlobal.session.user.settings["homesection" + i.toStr()] sectionName = userSection ?? "none" sectionName = LCase(sectionName) @@ -112,10 +112,10 @@ sub processUserSections() if sectionLoaded then loadedSections++ ' If 2 sections with data are loaded or we're at the end of the web client section data, consider the home view loaded - if not m.global.app_loaded + if not myGlobal.app_loaded if loadedSections = 2 or i = 6 m.top.signalBeacon("AppLaunchComplete") ' Roku Performance monitoring - m.global.app_loaded = true + myGlobal.app_loaded = true end if end if end for diff --git a/components/home/LoadItemsTask.bs b/components/home/LoadItemsTask.bs index f947d1250..f3ee10556 100644 --- a/components/home/LoadItemsTask.bs +++ b/components/home/LoadItemsTask.bs @@ -13,11 +13,12 @@ end sub sub loadItems() results = [] + myGlobal = m.global ' Load Libraries if m.top.itemsToLoad = "libraries" - url = Substitute("Users/{0}/Views/", m.global.session.user.id) + url = Substitute("Users/{0}/Views/", myGlobal.session.user.id) resp = APIRequest(url) data = getJson(resp) if isValid(data) and isValid(data.Items) @@ -33,7 +34,7 @@ sub loadItems() ' Load Latest Additions to Libraries else if m.top.itemsToLoad = "latest" - activeUser = m.global.session.user.id + activeUser = myGlobal.session.user.id if isValid(activeUser) url = Substitute("Users/{0}/Items/Latest", activeUser) params = {} @@ -67,13 +68,13 @@ sub loadItems() params["SortBy"] = "DatePlayed" params["SortOrder"] = "Descending" params["ImageTypeLimit"] = 1 - params["UserId"] = m.global.session.user.id - params["EnableRewatching"] = m.global.session.user.settings["ui.details.enablerewatchingnextup"] + params["UserId"] = myGlobal.session.user.id + params["EnableRewatching"] = myGlobal.session.user.settings["ui.details.enablerewatchingnextup"] params["DisableFirstEpisode"] = false params["limit"] = 24 params["EnableTotalRecordCount"] = false - maxDaysInNextUp = m.global.session.user.settings["ui.details.maxdaysnextup"].ToInt() + maxDaysInNextUp = myGlobal.session.user.settings["ui.details.maxdaysnextup"].ToInt() if isValid(maxDaysInNextUp) if maxDaysInNextUp > 0 dateToday = CreateObject("roDateTime") @@ -129,7 +130,7 @@ sub loadItems() end if ' Load Continue Watching else if m.top.itemsToLoad = "continue" - activeUser = m.global.session.user.id + activeUser = myGlobal.session.user.id if isValid(activeUser) url = Substitute("Users/{0}/Items/Resume", activeUser) @@ -156,7 +157,7 @@ sub loadItems() else if m.top.itemsToLoad = "favorites" - url = Substitute("Users/{0}/Items", m.global.session.user.id) + url = Substitute("Users/{0}/Items", myGlobal.session.user.id) params = {} params["Filters"] = "IsFavorite" @@ -188,7 +189,7 @@ sub loadItems() else if m.top.itemsToLoad = "onNow" url = "LiveTv/Programs/Recommended" params = {} - params["userId"] = m.global.session.user.id + params["userId"] = myGlobal.session.user.id params["isAiring"] = true params["limit"] = 16 ' 16 to be consistent with "Latest In" params["imageTypeLimit"] = 1 @@ -223,7 +224,7 @@ sub loadItems() end for else if m.top.itemsToLoad = "specialfeatures" params = {} - url = Substitute("Users/{0}/Items/{1}/SpecialFeatures", m.global.session.user.id, m.top.itemId) + url = Substitute("Users/{0}/Items/{1}/SpecialFeatures", myGlobal.session.user.id, m.top.itemId) resp = APIRequest(url, params) data = getJson(resp) if data <> invalid and data.count() > 0 @@ -253,7 +254,7 @@ sub loadItems() end for end if else if m.top.itemsToLoad = "likethis" - params = { "userId": m.global.session.user.id, "limit": 16 } + params = { "userId": myGlobal.session.user.id, "limit": 16 } url = Substitute("Items/{0}/Similar", m.top.itemId) resp = APIRequest(url, params) data = getJson(resp) diff --git a/components/liveTv/LoadChannelsTask.bs b/components/liveTv/LoadChannelsTask.bs index 7d00651d6..b8ef23a3f 100644 --- a/components/liveTv/LoadChannelsTask.bs +++ b/components/liveTv/LoadChannelsTask.bs @@ -6,6 +6,7 @@ sub init() end sub sub loadChannels() + myGlobal = m.global results = [] @@ -22,7 +23,7 @@ sub loadChannels() SortBy: sort_field, SortOrder: sort_order, recursive: m.top.recursive, - UserId: m.global.session.user.id + UserId: myGlobal.session.user.id } ' Handle special case when getting names starting with numeral @@ -43,7 +44,7 @@ sub loadChannels() params.append({ isFavorite: true }) end if - url = Substitute("Users/{0}/Items/", m.global.session.user.id) + url = Substitute("Users/{0}/Items/", myGlobal.session.user.id) resp = APIRequest(url, params) data = getJson(resp) diff --git a/components/manager/ViewCreator.bs b/components/manager/ViewCreator.bs index c2efcd07c..49017ccba 100644 --- a/components/manager/ViewCreator.bs +++ b/components/manager/ViewCreator.bs @@ -7,6 +7,7 @@ end sub ' Play Video sub CreateVideoPlayerView() + myGlobal = m.global m.playbackData = {} m.selectedSubtitle = {} @@ -16,17 +17,17 @@ sub CreateVideoPlayerView() m.view.observeField("selectSubtitlePressed", "onSelectSubtitlePressed") m.view.observeField("selectAudioPressed", "onSelectAudioPressed") - mediaSourceId = m.global.queueManager.callFunc("getCurrentItem").mediaSourceId + mediaSourceId = myGlobal.queueManager.callFunc("getCurrentItem").mediaSourceId if not isValid(mediaSourceId) or mediaSourceId = "" - mediaSourceId = m.global.queueManager.callFunc("getCurrentItem").id + mediaSourceId = myGlobal.queueManager.callFunc("getCurrentItem").id end if m.getPlaybackInfoTask = createObject("roSGNode", "GetPlaybackInfoTask") m.getPlaybackInfoTask.videoID = mediaSourceId m.getPlaybackInfoTask.observeField("data", "onPlaybackInfoLoaded") - m.global.sceneManager.callFunc("pushScene", m.view) + myGlobal.sceneManager.callFunc("pushScene", m.view) end sub ' ----------------- @@ -37,6 +38,7 @@ end sub ' onSelectAudioPressed: Display audio selection dialog ' sub onSelectAudioPressed() + myGlobal = m.global audioData = { data: [] } @@ -59,12 +61,13 @@ sub onSelectAudioPressed() audioData.data.push(audioStreamItem) end for - m.global.sceneManager.callFunc("radioDialog", tr("Select Audio"), audioData) - m.global.sceneManager.observeField("returnData", "onSelectionMade") + myGlobal.sceneManager.callFunc("radioDialog", tr("Select Audio"), audioData) + myGlobal.sceneManager.observeField("returnData", "onSelectionMade") end sub ' User requested subtitle selection popup sub onSelectSubtitlePressed() + myGlobal = m.global subtitleData = { data: [] } @@ -110,23 +113,24 @@ sub onSelectSubtitlePressed() "Type": "subtitleselection" }) - m.global.sceneManager.callFunc("radioDialog", tr("Select Subtitles"), subtitleData) - m.global.sceneManager.observeField("returnData", "onSelectionMade") + myGlobal.sceneManager.callFunc("radioDialog", tr("Select Subtitles"), subtitleData) + myGlobal.sceneManager.observeField("returnData", "onSelectionMade") end sub ' User has selected something from the radioDialog popup sub onSelectionMade() - m.global.sceneManager.unobserveField("returnData") + myGlobal = m.global + myGlobal.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(myGlobal.sceneManager.returnData) then return + if not isValid(myGlobal.sceneManager.returnData.type) then return - if LCase(m.global.sceneManager.returnData.type) = "subtitleselection" + if LCase(myGlobal.sceneManager.returnData.type) = "subtitleselection" processSubtitleSelection() return end if - if LCase(m.global.sceneManager.returnData.type) = "audioselection" + if LCase(myGlobal.sceneManager.returnData.type) = "audioselection" processAudioSelection() return end if @@ -216,22 +220,23 @@ end sub ' Playback state change event handlers sub onStateChange() if LCase(m.view.state) = "finished" + myGlobal = m.global ' Close any open dialogs - if m.global.sceneManager.callFunc("isDialogOpen") - m.global.sceneManager.callFunc("dismissDialog") + if myGlobal.sceneManager.callFunc("isDialogOpen") + myGlobal.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 myGlobal.queueManager.callFunc("getPosition") < myGlobal.queueManager.callFunc("getCount") - 1 + myGlobal.sceneManager.callFunc("clearPreviousScene") + myGlobal.queueManager.callFunc("moveForward") + myGlobal.queueManager.callFunc("playQueue") return end if ' Playback completed, return user to previous screen - m.global.sceneManager.callFunc("popScene") - m.global.audioPlayer.loopMode = "" + myGlobal.sceneManager.callFunc("popScene") + myGlobal.audioPlayer.loopMode = "" end if end sub diff --git a/components/mediaPlayers/AudioPlayer.bs b/components/mediaPlayers/AudioPlayer.bs index db3750082..afbc37ab7 100644 --- a/components/mediaPlayers/AudioPlayer.bs +++ b/components/mediaPlayers/AudioPlayer.bs @@ -28,16 +28,17 @@ end sub sub ReportPlayback(state as string) if not isValid(m.top.position) then return + myGlobal = m.global params = { - "ItemId": m.global.queueManager.callFunc("getCurrentItem").id, + "ItemId": myGlobal.queueManager.callFunc("getCurrentItem").id, "PlaySessionId": m.top.content.id, "PositionTicks": int(m.top.position) * 10000000&, 'Ensure a LongInteger is used "IsPaused": (LCase(m.top.state) = "paused") } ' Report playstate via global task - playstateTask = m.global.playstateTask + playstateTask = myGlobal.playstateTask playstateTask.setFields({ status: state, params: params }) playstateTask.control = "RUN" end sub diff --git a/components/movies/AudioTrackListItem.bs b/components/movies/AudioTrackListItem.bs index 54eac58e6..1de9a8ee5 100644 --- a/components/movies/AudioTrackListItem.bs +++ b/components/movies/AudioTrackListItem.bs @@ -2,6 +2,7 @@ sub init() m.title = m.top.findNode("title") m.description = m.top.findNode("description") m.selectedIcon = m.top.findNode("selectedIcon") + m.checkIconWhite = m.global.constants.icons.check_white end sub sub itemContentChanged() @@ -13,7 +14,7 @@ sub itemContentChanged() end if if m.top.itemContent.selected - m.selectedIcon.uri = m.global.constants.icons.check_white + m.selectedIcon.uri = m.checkIconWhite else m.selectedIcon.uri = "" end if diff --git a/components/movies/MovieDetails.bs b/components/movies/MovieDetails.bs index e7aa3d3ad..65a758131 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) + myGlobal = m.global 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 myGlobal.session.user.settings["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 myGlobal.session.user.settings["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 myGlobal.session.user.settings["ui.details.hidetagline"] = false if itemData.taglines.count() > 0 setFieldText("tagline", itemData.taglines[0]) end if diff --git a/components/movies/MovieOptions.bs b/components/movies/MovieOptions.bs index fa8cc481f..d12cc779a 100644 --- a/components/movies/MovieOptions.bs +++ b/components/movies/MovieOptions.bs @@ -15,8 +15,9 @@ sub init() m.audioNames = [] ' Set button colors to global - m.top.findNode("videoMenu").focusBitmapBlendColor = m.global.constants.colors.button - m.top.findNode("audioMenu").focusBitmapBlendColor = m.global.constants.colors.button + buttonColor = m.global.constants.colors.button + m.top.findNode("videoMenu").focusBitmapBlendColor = buttonColor + m.top.findNode("audioMenu").focusBitmapBlendColor = buttonColor ' Animation m.fadeAnim = m.top.findNode("fadeAnim") diff --git a/components/movies/VideoTrackListItem.bs b/components/movies/VideoTrackListItem.bs index 54eac58e6..1de9a8ee5 100644 --- a/components/movies/VideoTrackListItem.bs +++ b/components/movies/VideoTrackListItem.bs @@ -2,6 +2,7 @@ sub init() m.title = m.top.findNode("title") m.description = m.top.findNode("description") m.selectedIcon = m.top.findNode("selectedIcon") + m.checkIconWhite = m.global.constants.icons.check_white end sub sub itemContentChanged() @@ -13,7 +14,7 @@ sub itemContentChanged() end if if m.top.itemContent.selected - m.selectedIcon.uri = m.global.constants.icons.check_white + m.selectedIcon.uri = m.checkIconWhite else m.selectedIcon.uri = "" end if diff --git a/components/music/AudioPlayerView.bs b/components/music/AudioPlayerView.bs index 12786a6bb..b39412e3b 100644 --- a/components/music/AudioPlayerView.bs +++ b/components/music/AudioPlayerView.bs @@ -4,14 +4,18 @@ import "pkg:/source/api/baserequest.bs" import "pkg:/source/utils/config.bs" sub init() + myGlobal = m.global m.top.optionsAvailable = false m.inScrubMode = false m.lastRecordedPositionTimestamp = 0 m.scrubTimestamp = -1 - m.playlistTypeCount = m.global.queueManager.callFunc("getQueueUniqueTypes").count() + m.playlistTypeCount = myGlobal.queueManager.callFunc("getQueueUniqueTypes").count() + + myGlobal.audioPlayer.observeField("state", "audioStateChanged") + myGlobal.audioPlayer.observeField("position", "audioPositionChanged") + myGlobal.audioPlayer.observeField("bufferingStatus", "bufferPositionChanged") - setupAudioNode() setupAnimationTasks() setupButtons() setupInfoNodes() @@ -91,13 +95,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") @@ -148,11 +145,12 @@ end sub sub bufferPositionChanged() if m.inScrubMode then return + myGlobal = m.global - if not isValid(m.global.audioPlayer.bufferingStatus) + if not isValid(myGlobal.audioPlayer.bufferingStatus) bufferPositionBarWidth = m.seekBar.width else - bufferPositionBarWidth = m.seekBar.width * m.global.audioPlayer.bufferingStatus.percentage + bufferPositionBarWidth = m.seekBar.width * myGlobal.audioPlayer.bufferingStatus.percentage end if ' Ensure position bar is never wider than the seek bar @@ -167,17 +165,18 @@ end sub sub audioPositionChanged() stopLoadingSpinner() + myGlobal = m.global - if m.global.audioPlayer.position = 0 + if myGlobal.audioPlayer.position = 0 m.playPosition.width = 0 end if - if not isValid(m.global.audioPlayer.position) + if not isValid(myGlobal.audioPlayer.position) playPositionBarWidth = 0 else if not isValid(m.songDuration) playPositionBarWidth = 0 else - songPercentComplete = m.global.audioPlayer.position / m.songDuration + songPercentComplete = myGlobal.audioPlayer.position / m.songDuration playPositionBarWidth = m.seekBar.width * songPercentComplete end if @@ -189,7 +188,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(myGlobal.audioPlayer.position, false) end if ' Use animation to make the display smooth @@ -197,9 +196,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(myGlobal.audioPlayer.position) + m.lastRecordedPositionTimestamp = myGlobal.audioPlayer.position + m.positionTimestamp.text = secondsToHuman(myGlobal.audioPlayer.position, false) else m.lastRecordedPositionTimestamp = 0 m.positionTimestamp.text = "0:00" @@ -247,25 +246,25 @@ sub endScreenSaver() end sub sub audioStateChanged() - + myGlobal = m.global ' Song Finished, attempt to move to next song - if m.global.audioPlayer.state = "finished" + if myGlobal.audioPlayer.state = "finished" ' User has enabled single song loop, play current song again - if m.global.audioPlayer.loopMode = "one" + if myGlobal.audioPlayer.loopMode = "one" m.scrubTimestamp = -1 playAction() exitScrubMode() return end if - if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1 + if myGlobal.queueManager.callFunc("getPosition") < myGlobal.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 myGlobal.audioPlayer.loopMode = "all" + myGlobal.queueManager.callFunc("setPosition", -1) LoadNextSong() return end if @@ -277,18 +276,19 @@ sub audioStateChanged() end sub function playAction() as boolean - if m.global.audioPlayer.state = "playing" - m.global.audioPlayer.control = "pause" + myGlobal = m.global + if myGlobal.audioPlayer.state = "playing" + myGlobal.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 myGlobal.audioPlayer.state = "paused" + myGlobal.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 myGlobal.audioPlayer.state = "finished" + myGlobal.audioPlayer.control = "play" ' Write screen tracker for screensaver WriteAsciiFile("tmp:/scene.temp", "nowplaying") MoveFile("tmp:/scene.temp", "tmp:/scene") @@ -298,20 +298,21 @@ function playAction() as boolean end function function previousClicked() as boolean - currentQueuePosition = m.global.queueManager.callFunc("getPosition") + myGlobal = m.global + currentQueuePosition = myGlobal.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 = myGlobal.queueManager.callFunc("getItemByIndex", currentQueuePosition - 1) + previousItemType = myGlobal.queueManager.callFunc("getItemType", previousItem) if previousItemType <> "audio" - m.global.audioPlayer.control = "stop" + myGlobal.audioPlayer.control = "stop" - m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveBack") - m.global.queueManager.callFunc("playQueue") + myGlobal.sceneManager.callFunc("clearPreviousScene") + myGlobal.queueManager.callFunc("moveBack") + myGlobal.queueManager.callFunc("playQueue") return true end if end if @@ -321,16 +322,16 @@ function previousClicked() as boolean m.lastRecordedPositionTimestamp = 0 m.positionTimestamp.text = "0:00" - if m.global.audioPlayer.state = "playing" - m.global.audioPlayer.control = "stop" + if myGlobal.audioPlayer.state = "playing" + myGlobal.audioPlayer.control = "stop" end if ' Reset loop mode due to manual user interaction - if m.global.audioPlayer.loopMode = "one" + if myGlobal.audioPlayer.loopMode = "one" resetLoopModeToDefault() end if - m.global.queueManager.callFunc("moveBack") + myGlobal.queueManager.callFunc("moveBack") pageContentChanged() return true @@ -342,13 +343,13 @@ sub resetLoopModeToDefault() 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" + myGlobal = m.global + if myGlobal.audioPlayer.loopMode = "" + myGlobal.audioPlayer.loopMode = "all" + else if myGlobal.audioPlayer.loopMode = "all" + myGlobal.audioPlayer.loopMode = "one" else - m.global.audioPlayer.loopMode = "" + myGlobal.audioPlayer.loopMode = "" end if setLoopButtonImage() @@ -357,10 +358,12 @@ function loopClicked() as boolean end function sub setLoopButtonImage() - if m.global.audioPlayer.loopMode = "all" + myGlobal = m.global + + if myGlobal.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 myGlobal.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 +371,21 @@ sub setLoopButtonImage() end sub function nextClicked() as boolean + myGlobal = m.global + if m.playlistTypeCount > 1 - currentQueuePosition = m.global.queueManager.callFunc("getPosition") - if currentQueuePosition < m.global.queueManager.callFunc("getCount") - 1 + currentQueuePosition = myGlobal.queueManager.callFunc("getPosition") + if currentQueuePosition < myGlobal.queueManager.callFunc("getCount") - 1 - nextItem = m.global.queueManager.callFunc("getItemByIndex", currentQueuePosition + 1) - nextItemType = m.global.queueManager.callFunc("getItemType", nextItem) + nextItem = myGlobal.queueManager.callFunc("getItemByIndex", currentQueuePosition + 1) + nextItemType = myGlobal.queueManager.callFunc("getItemType", nextItem) if nextItemType <> "audio" - m.global.audioPlayer.control = "stop" + myGlobal.audioPlayer.control = "stop" - m.global.sceneManager.callFunc("clearPreviousScene") - m.global.queueManager.callFunc("moveForward") - m.global.queueManager.callFunc("playQueue") + myGlobal.sceneManager.callFunc("clearPreviousScene") + myGlobal.queueManager.callFunc("moveForward") + myGlobal.queueManager.callFunc("playQueue") return true end if end if @@ -392,11 +397,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 myGlobal.audioPlayer.loopMode = "one" resetLoopModeToDefault() end if - if m.global.queueManager.callFunc("getPosition") < m.global.queueManager.callFunc("getCount") - 1 + if myGlobal.queueManager.callFunc("getPosition") < myGlobal.queueManager.callFunc("getCount") - 1 LoadNextSong() end if @@ -409,9 +414,10 @@ end sub function findCurrentSongIndex(songList) as integer if not isValidAndNotEmpty(songList) then return 0 + myGlobal = m.global for i = 0 to songList.count() - 1 - if songList[i].id = m.global.queueManager.callFunc("getCurrentItem").id + if songList[i].id = myGlobal.queueManager.callFunc("getCurrentItem").id return i end if end for @@ -420,15 +426,15 @@ function findCurrentSongIndex(songList) as integer end function function shuffleClicked() as boolean - - currentSongIndex = findCurrentSongIndex(m.global.queueManager.callFunc("getUnshuffledQueue")) + myGlobal = m.global + currentSongIndex = findCurrentSongIndex(myGlobal.queueManager.callFunc("getUnshuffledQueue")) toggleShuffleEnabled() - if not m.global.queueManager.callFunc("getIsShuffled") + if not myGlobal.queueManager.callFunc("getIsShuffled") m.shuffleIndicator.opacity = ".4" m.shuffleIndicator.uri = m.shuffleIndicator.uri.Replace("-on", "-off") - m.global.queueManager.callFunc("setPosition", currentSongIndex) + myGlobal.queueManager.callFunc("setPosition", currentSongIndex) setTrackNumberDisplay() return true end if @@ -448,19 +454,22 @@ sub setShuffleIconState() end sub sub setTrackNumberDisplay() - setFieldTextValue("numberofsongs", "Track " + stri(m.global.queueManager.callFunc("getPosition") + 1) + "/" + stri(m.global.queueManager.callFunc("getCount"))) + myGlobal = m.global + setFieldTextValue("numberofsongs", "Track " + stri(myGlobal.queueManager.callFunc("getPosition") + 1) + "/" + stri(myGlobal.queueManager.callFunc("getCount"))) end sub sub LoadNextSong() - if m.global.audioPlayer.state = "playing" - m.global.audioPlayer.control = "stop" + myGlobal = m.global + + if myGlobal.audioPlayer.state = "playing" + myGlobal.audioPlayer.control = "stop" end if exitScrubMode() ' Reset playPosition bar without animation m.playPosition.width = 0 - m.global.queueManager.callFunc("moveForward") + myGlobal.queueManager.callFunc("moveForward") pageContentChanged() end sub @@ -491,11 +500,13 @@ sub onAudioStreamLoaded() data = m.LoadAudioStreamTask.content[0] m.LoadAudioStreamTask.unobserveField("content") if data <> invalid and data.count() > 0 + myGlobal = m.global + ' Reset buffer bar without animation m.bufferPosition.width = 0 useMetaTask = false - currentItem = m.global.queueManager.callFunc("getCurrentItem") + currentItem = myGlobal.queueManager.callFunc("getCurrentItem") if not isValid(currentItem.RunTimeTicks) useMetaTask = true @@ -531,9 +542,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" + myGlobal.audioPlayer.content = data + myGlobal.audioPlayer.control = "none" + myGlobal.audioPlayer.control = "play" end if end sub @@ -773,8 +784,9 @@ function onKeyEvent(key as string, press as boolean) as boolean end if if key = "back" - m.global.audioPlayer.control = "stop" - m.global.audioPlayer.loopMode = "" + myGlobal = m.global + myGlobal.audioPlayer.control = "stop" + myGlobal.audioPlayer.loopMode = "" else if key = "rewind" return previousClicked() else if key = "fastforward"