diff --git a/components/data/SceneManager.brs b/components/data/SceneManager.brs index e876957f..85140a4d 100755 --- a/components/data/SceneManager.brs +++ b/components/data/SceneManager.brs @@ -1,4 +1,5 @@ import "pkg:/source/roku_modules/log/LogMixin.brs" +import "pkg:/source/utils/deviceCapabilities.brs" sub init() m.log = log.Logger("SceneManager") @@ -6,6 +7,8 @@ sub init() m.scene = m.top.getScene() m.content = m.scene.findNode("content") m.overhang = m.scene.findNode("overhang") + m.postTask = CreateObject("roSGNode", "PostTask") + m.postTask.observeField("responseCode", "postFinished") end sub ' @@ -77,16 +80,21 @@ end sub sub popScene() group = m.groups.pop() if group <> invalid - if group.isSubType("JFGroup") + groupType = group.subtype() + + if groupType = "JFGroup" unregisterOverhangData(group) - else if group.isSubType("JFVideo") + else if groupType = "JFVideo" ' Stop video to make sure app communicates stop playstate to server group.control = "stop" + else if groupType = "Settings" + ' update device profile after exiting the settings page - some settings affect the device profile + postProfile() end if group.visible = false - if group.isSubType("JFScreen") + if groupType = "JFScreen" group.callFunc("OnScreenHidden") end if else @@ -355,3 +363,22 @@ end sub function isDialogOpen() as boolean return m.scene.dialog <> invalid end function + +' Send Device Profile information to server +function postProfile() as boolean + m.postTask.arrayData = getDeviceCapabilities() + m.postTask.apiUrl = "/Sessions/Capabilities/Full" + m.postTask.control = "RUN" + return true +end function + +' Return the Post Task to it's default state +sub postFinished() + m.postTask.unobserveField("responseCode") + ' Empty the Post Task data to its default state + m.postTask.apiUrl = "" + m.postTask.arrayData = {} + m.postTask.stringData = "" + m.postTask.responseCode = 0 + m.postTask.observeField("responseCode", "postFinished") +end sub diff --git a/components/data/SceneManager.xml b/components/data/SceneManager.xml index 3cc43b64..b9ecf60b 100755 --- a/components/data/SceneManager.xml +++ b/components/data/SceneManager.xml @@ -14,6 +14,7 @@ + diff --git a/source/Main.brs b/source/Main.brs index 298650bd..3a164518 100644 --- a/source/Main.brs +++ b/source/Main.brs @@ -32,7 +32,7 @@ sub Main (args as dynamic) as void ' First thing to do is validate the ability to use the API if not LoginFlow() then return ' tell jellyfin server about device capabilities - PostDeviceProfile() + m.global.sceneManager.callFunc("postProfile") ' remove previous scenes from the stack sceneManager.callFunc("clearScenes") @@ -621,12 +621,12 @@ sub Main (args as dynamic) as void ' The audio codec capability has changed if true. print "event.audioCodecCapabilityChanged = ", event.audioCodecCapabilityChanged - PostDeviceProfile() + m.global.sceneManager.callFunc("postProfile") else if isValid(event.videoCodecCapabilityChanged) ' The video codec capability has changed if true. print "event.videoCodecCapabilityChanged = ", event.videoCodecCapabilityChanged - PostDeviceProfile() + m.global.sceneManager.callFunc("postProfile") else if isValid(event.appFocus) ' It is set to False when the System Overlay (such as the confirm partner button HUD or the caption control overlay) takes focus and True when the channel regains focus print "event.appFocus = ", event.appFocus diff --git a/source/utils/deviceCapabilities.brs b/source/utils/deviceCapabilities.brs index fcc256ce..cf1dcc7e 100644 --- a/source/utils/deviceCapabilities.brs +++ b/source/utils/deviceCapabilities.brs @@ -17,14 +17,6 @@ function getDeviceCapabilities() as object } end function -' Send Device Profile information to server -sub PostDeviceProfile() - body = getDeviceCapabilities() - req = APIRequest("/Sessions/Capabilities/Full") - req.SetRequest("POST") - postJson(req, FormatJson(body)) -end sub - function getDeviceProfile() as object playMpeg2 = m.global.session.user.settings["playback.mpeg2"] playAv1 = m.global.session.user.settings["playback.av1"]