From 119b14634e40e74eb78e9d1449c3cf36aaf2db9b Mon Sep 17 00:00:00 2001
From: 1hitsong <3330318+1hitsong@users.noreply.github.com>
Date: Sun, 20 Nov 2022 20:18:23 -0500
Subject: [PATCH] Code cleanup
---
components/JFVideo.brs | 40 +++++++++++++++++++++-------------------
components/JFVideo.xml | 4 ++--
source/VideoPlayer.brs | 2 --
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/components/JFVideo.brs b/components/JFVideo.brs
index c60d6727..20f3c7a2 100644
--- a/components/JFVideo.brs
+++ b/components/JFVideo.brs
@@ -19,8 +19,9 @@ sub init()
m.nextEpisodeButton = m.top.findNode("nextEpisode")
m.nextEpisodeButton.text = tr("Next Episode")
m.nextEpisodeButton.setFocus(false)
- m.shownextEpisodeButtonAnimation = m.top.findNode("shownextEpisodeButton")
- m.hidenextEpisodeButtonAnimation = m.top.findNode("hidenextEpisodeButton")
+
+ m.showNextEpisodeButtonAnimation = m.top.findNode("showNextEpisodeButton")
+ m.hideNextEpisodeButtonAnimation = m.top.findNode("hideNextEpisodeButton")
end sub
' Event handler for when video content field changes
@@ -35,9 +36,9 @@ end sub
'
' Runs Next Episode button animation and sets focus to button
-sub shownextEpisode()
+sub showNextEpisodeButton()
if not m.nextEpisodeButton.visible
- m.shownextEpisodeButtonAnimation.control = "start"
+ m.showNextEpisodeButtonAnimation.control = "start"
m.nextEpisodeButton.setFocus(true)
m.nextEpisodeButton.visible = true
end if
@@ -51,19 +52,21 @@ end sub
'
' Runs hide Next Episode button animation and sets focus back to video
-sub hidenextEpisode()
- 'm.top.trickPlayBar.unobserveField("visible")
- m.hidenextEpisodeButtonAnimation.control = "start"
+sub hideNextEpisodeButton()
+ m.hideNextEpisodeButtonAnimation.control = "start"
m.nextEpisodeButton.setFocus(false)
m.top.setFocus(true)
end sub
-sub handleNextEpisode()
- ' Dialog box is open
+' Checks if we need to display the Next Episode button
+sub checkTimeToDisplayNextEpisode()
if int(m.top.position) >= (m.top.runTime - 30)
- shownextEpisode()
+ showNextEpisodeButton()
updateCount()
- else
+ return
+ end if
+
+ if m.nextEpisodeButton.visible or m.nextEpisodeButton.hasFocus()
m.nextEpisodeButton.visible = false
m.nextEpisodeButton.setFocus(false)
end if
@@ -74,7 +77,7 @@ sub onPositionChanged()
' Check if dialog is open
m.dialog = m.top.getScene().findNode("dialogBackground")
if not isValid(m.dialog)
- handleNextEpisode()
+ checkTimeToDisplayNextEpisode()
end if
end sub
@@ -190,22 +193,21 @@ sub dialogClosed(msg)
sourceNode.close = true
end sub
-
-
function onKeyEvent(key as string, press as boolean) as boolean
if key = "OK" and m.nextEpisodeButton.hasfocus() and m.top.trickPlayMode = "play"
m.top.state = "finished"
- hidenextEpisode()
+ hideNextEpisodeButton()
return true
else
'Hide Next Episode Button
- m.nextEpisodeButton.visible = false
- m.nextEpisodeButton.setFocus(false)
- m.top.setFocus(true)
+ if m.nextEpisodeButton.visible or m.nextEpisodeButton.hasFocus()
+ m.nextEpisodeButton.visible = false
+ m.nextEpisodeButton.setFocus(false)
+ m.top.setFocus(true)
+ end if
end if
-
if not press then return false
if key = "down"
diff --git a/components/JFVideo.xml b/components/JFVideo.xml
index 8f2d4dd3..bcd593c7 100644
--- a/components/JFVideo.xml
+++ b/components/JFVideo.xml
@@ -33,10 +33,10 @@
-
+
-
+
diff --git a/source/VideoPlayer.brs b/source/VideoPlayer.brs
index da652a44..158b5484 100644
--- a/source/VideoPlayer.brs
+++ b/source/VideoPlayer.brs
@@ -46,7 +46,6 @@ sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -
end if
if m.videotype = "Episode" or m.videotype = "Series"
- 'print (meta.json.RunTimeTicks / 10000000) / 60
video.runTime = (meta.json.RunTimeTicks / 10000000.0)
video.content.contenttype = "episode"
end if
@@ -427,7 +426,6 @@ sub autoPlayNextEpisode(videoID as string, showID as string)
' setup new video node
nextVideo = CreateVideoPlayerGroup(data.Items[1].Id, invalid, 1, false, false)
' remove last videoplayer scene
-
m.global.sceneManager.callFunc("clearPreviousScene")
if nextVideo <> invalid
m.global.sceneManager.callFunc("pushScene", nextVideo)