From 1cb0eb9e1b9cfd24588cde92afac990f60d8bb47 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 28 Sep 2024 13:20:27 -0400 Subject: [PATCH 1/8] report "finished" video state to server --- components/PlaystateTask.bs | 2 +- components/video/VideoPlayerView.bs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/components/PlaystateTask.bs b/components/PlaystateTask.bs index fc06ae3e1..556ab52f2 100644 --- a/components/PlaystateTask.bs +++ b/components/PlaystateTask.bs @@ -8,7 +8,7 @@ end sub sub PlaystateUpdate() if m.top.status = "start" url = "Sessions/Playing" - else if m.top.status = "stop" + else if m.top.status = "stop" or m.top.status = "finished" url = "Sessions/Playing/Stopped" else if m.top.status = "update" url = "Sessions/Playing/Progress" diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index 56f230ee8..a9b708d79 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -1,7 +1,9 @@ import "pkg:/source/utils/misc.bs" import "pkg:/source/utils/config.bs" +import "pkg:/source/roku_modules/log/LogMixin.brs" sub init() + m.log = log.Logger("VideoPlayerView") ' Hide the overhang on init to prevent showing 2 clocks m.top.getScene().findNode("overhang").visible = false m.currentItem = m.global.queueManager.callFunc("getCurrentItem") @@ -600,6 +602,7 @@ end sub ' ' When Video Player state changes sub onState(msg) + m.log.debug("start onState()", m.top.state) if isValid(m.captionTask) m.captionTask.playerState = m.top.state + m.top.globalCaptionMode end if @@ -649,16 +652,22 @@ sub onState(msg) m.playbackTimer.control = "stop" ReportPlayback("stop") m.playReported = false + else if m.top.state = "finished" + m.playbackTimer.control = "stop" + ReportPlayback("finished") + m.top.control = "stop" + m.top.backPressed = true ' exit video player end if - + m.log.debug("end onState()", m.top.state) end sub ' ' Report playback to server sub ReportPlayback(state = "update" as string) - if m.top.position = invalid then return + m.log.debug("start ReportPlayback()", state, int(m.top.position)) + params = { "ItemId": m.top.id, "PlaySessionId": m.top.PlaySessionId, @@ -677,6 +686,8 @@ sub ReportPlayback(state = "update" as string) playstateTask = m.global.playstateTask playstateTask.setFields({ status: state, params: params }) playstateTask.control = "RUN" + + m.log.debug("end ReportPlayback()", state, int(m.top.position)) end sub ' From 16eb0a601ad7267f1c2734c236c66639fae83acc Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 28 Sep 2024 14:56:26 -0400 Subject: [PATCH 2/8] change api endpoint --- components/PlaystateTask.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/PlaystateTask.bs b/components/PlaystateTask.bs index 556ab52f2..ff8d8f5e8 100644 --- a/components/PlaystateTask.bs +++ b/components/PlaystateTask.bs @@ -8,9 +8,9 @@ end sub sub PlaystateUpdate() if m.top.status = "start" url = "Sessions/Playing" - else if m.top.status = "stop" or m.top.status = "finished" + else if m.top.status = "stop" url = "Sessions/Playing/Stopped" - else if m.top.status = "update" + else if m.top.status = "update" or m.top.status = "finished" url = "Sessions/Playing/Progress" else ' Unknown State From ecba5333acd01ace88f1ef2148b0f12c0cbe2c80 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 28 Sep 2024 14:57:07 -0400 Subject: [PATCH 3/8] don't manually stop and exit player when state = finished --- components/video/VideoPlayerView.bs | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index a9b708d79..c3588448b 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -655,8 +655,6 @@ sub onState(msg) else if m.top.state = "finished" m.playbackTimer.control = "stop" ReportPlayback("finished") - m.top.control = "stop" - m.top.backPressed = true ' exit video player end if m.log.debug("end onState()", m.top.state) end sub From b6a65e63ef3e457b026b7c01984c1d5a888b303a Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 28 Sep 2024 15:34:24 -0400 Subject: [PATCH 4/8] update server when starting in buffered state --- components/video/VideoPlayerView.bs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index c3588448b..b3ebc0f2e 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -611,11 +611,18 @@ sub onState(msg) m.osd.playbackState = m.top.state ' When buffering, start timer to monitor buffering process - if m.top.state = "buffering" and m.bufferCheckTimer <> invalid + if m.top.state = "buffering" + ' start buffer timer + if isValid(m.bufferCheckTimer) + m.bufferCheckTimer.control = "start" + m.bufferCheckTimer.ObserveField("fire", "bufferCheck") + end if - ' start timer - m.bufferCheckTimer.control = "start" - m.bufferCheckTimer.ObserveField("fire", "bufferCheck") + ' update server if needed + if not m.playReported + m.playReported = true + ReportPlayback("start") + end if else if m.top.state = "error" if not m.playReported and m.top.transcodeAvailable m.top.retryWithTranscoding = true ' If playback was not reported, retry with transcoding From 4fd7d42039cea05e89eec7cf90a0cf1ab5cb575d Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 28 Sep 2024 17:08:39 -0400 Subject: [PATCH 5/8] add debugging for video errors --- components/video/VideoPlayerView.bs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index b3ebc0f2e..53a2cf111 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -624,6 +624,10 @@ sub onState(msg) ReportPlayback("start") end if else if m.top.state = "error" + m.log.error(m.top.errorCode, m.top.errorMsg, m.top.errorStr, m.top.errorCode) + + print m.top.errorInfo + if not m.playReported and m.top.transcodeAvailable m.top.retryWithTranscoding = true ' If playback was not reported, retry with transcoding else From 5e35ffa49f6b2fb8e04d878f9c807c1fec4b3185 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 28 Sep 2024 17:12:26 -0400 Subject: [PATCH 6/8] force exit from video player when finished to set TV back to SDR --- components/video/VideoPlayerView.bs | 1 + 1 file changed, 1 insertion(+) diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index 53a2cf111..bf6026db5 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -666,6 +666,7 @@ sub onState(msg) else if m.top.state = "finished" m.playbackTimer.control = "stop" ReportPlayback("finished") + m.top.backPressed = true ' force exit from video player to set TV back to SDR end if m.log.debug("end onState()", m.top.state) end sub From d23a77e572df8c02fe23c89fe8b3e2f383575c1c Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 28 Sep 2024 19:40:14 -0400 Subject: [PATCH 7/8] fix api endpoint for finished state --- components/PlaystateTask.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/PlaystateTask.bs b/components/PlaystateTask.bs index ff8d8f5e8..556ab52f2 100644 --- a/components/PlaystateTask.bs +++ b/components/PlaystateTask.bs @@ -8,9 +8,9 @@ end sub sub PlaystateUpdate() if m.top.status = "start" url = "Sessions/Playing" - else if m.top.status = "stop" + else if m.top.status = "stop" or m.top.status = "finished" url = "Sessions/Playing/Stopped" - else if m.top.status = "update" or m.top.status = "finished" + else if m.top.status = "update" url = "Sessions/Playing/Progress" else ' Unknown State From c90645777a1785f0dc90a5a53a0ae0f27c7fb341 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sun, 29 Sep 2024 10:57:49 -0400 Subject: [PATCH 8/8] log unhandled state and remove unused var --- components/video/VideoPlayerView.bs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index bf6026db5..5850bbd94 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -637,7 +637,6 @@ sub onState(msg) ' Stop playback and exit player m.top.control = "stop" - m.top.backPressed = true else if m.top.state = "playing" ' Check if next episode is available @@ -666,7 +665,8 @@ sub onState(msg) else if m.top.state = "finished" m.playbackTimer.control = "stop" ReportPlayback("finished") - m.top.backPressed = true ' force exit from video player to set TV back to SDR + else + m.log.warning("Unhandled state", m.top.state, m.playReported, m.playFinished) end if m.log.debug("end onState()", m.top.state) end sub @@ -723,7 +723,6 @@ sub bufferCheck(msg) ' Stop playback and exit player m.top.control = "stop" - m.top.backPressed = true end if end if