Refactor and fix player (#19)

* Refactor and fix player

* Rename functions, fix video loading indicator

* Hide loading indicator on exit
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2022-12-02 10:46:48 -05:00
1 parent 2d1490f925
commit 68a8d61eb0
14 files changed
+388 -329

No files matched your search

@@ -6,6 +6,7 @@ function Init()
m.top.ObserveField("rowItemSelected", "OnHomeGridScreenVideoSelected")
m.top.ObserveField("focus", "OnFocusChange")
m.top.ObserveField("playvideo", "OnPlayVideoCommand")
m.top.ObserveField("refresh", "OnRefresh")
m.top.focus = true
@@ -18,6 +19,10 @@ function OnFocusChange()
end if
end function
function OnRefresh()
InitContent()
end function
function InitContent()
m.sortedContent = []
contentNode = CreateObject("roSGNode", "ContentNode")
@@ -106,23 +111,12 @@ function OnHomeGridScreenVideoSelected(event as object) as void
videoId = itemContent.videoId
CloseVideo()
ShowVideoScreen(videoId, m.top)
end function
function CloseVideo()
if m.videoPlayer <> invalid
m.videoPlayer.control = "stop"
m.videoPlayer.visible = false
m.videoPlayer.getParent().removeChild(m.videoPlayer)
m.videoPlayer = invalid
end if
PlayVideo(videoId, m.top)
end function
function OnPlayVideoCommand()
videoId = m.top.playvideo
CloseVideo()
ShowVideoScreen(videoId, m.top)
PlayVideo(videoId)
end function
function OnkeyEvent(key as string, press as boolean) as boolean
@@ -9,6 +9,7 @@
<field id="escape" type="string" alwaysNotify="true" />
<field id="focus" type="boolean" alwaysNotify="true" />
<field id="playvideo" type="string" alwaysNotify="true" />
<field id="refresh" type="boolean" alwaysNotify="true" />
</interface>
<children>
<RowList