Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
AJstream
Binge Watcher

How to bring back home screen without intrupting the stream?

I am very new to programming, I am using the sample (Simple_Grid_and_Video) but I would like to use "up" or "down" key to bring back the main screen without stopping the playback.(while the channel is playing in the background)

Here is what I got but it didn't work.

I would appreciate any help

Code below is the "HomeScene.brs" from the same sample I added the red part

' ********** Copyright 2016 Roku Corp.  All Rights Reserved. ********** 
 ' inits grid screen
 ' creates all children
 ' sets all observers 
Function Init()
    ' listen on port 8089
    ? "[HomeScene] Init"

    'main grid screen node
    m.GridScreen = m.top.findNode("GridScreen")
    'video player node
    m.videoPlayer = m.top.findNode("videoPlayer")

    'added handler on item selecting event in grid screen
    m.top.observeField("rowItemSelected", "OnRowItemSelected")
    
    ' loading indicator starts at initializatio of channel
    m.loadingIndicator = m.top.findNode("loadingIndicator")
End Function 

' Row item selected handler
Sub OnRowItemSelected()
    ? "[HomeScene] OnRowItemSelected"
    m.GridScreen.visible = "false"
    selectedItem = m.GridScreen.focusedContent
    
    'init of video player and start playback
    m.videoPlayer.visible = true
    m.videoPlayer.setFocus(true)
    m.videoPlayer.content = selectedItem
    m.videoPlayer.control = "play"
    m.videoPlayer.observeField("state", "OnVideoPlayerStateChange")
End Sub

Sub OnVideoPlayerStateChange()
    ? "HomeScene > OnVideoPlayerStateChange : state == ";m.videoPlayer.state
    if m.videoPlayer.state = "error"
        'hide vide player in case of error
        m.videoPlayer.visible = false
        m.GridScreen.visible = true
        m.GridScreen.setFocus(true)
    else if m.videoPlayer.state = "playing"
    else if m.videoPlayer.state = "finished"
        'hide vide player if video is finished
        m.videoPlayer.visible = false
        m.GridScreen.visible = true
        m.GridScreen.setFocus(true)
    end if
end Sub

' if content set, focus on GridScreen
Sub OnChangeContent()
    ? "OnChangeContent "
    m.GridScreen.setFocus(true)
    m.loadingIndicator.control = "stop"
End Sub

' Main Remote keypress event loop
Function OnkeyEvent(key, press) as Boolean
    ? ">>> HomeScene >> OnkeyEvent"
    result = false
    if press
        ? "key == ";key
		if key="up" or key = "down"
		   if m.GridScreen.visible = false 
		      m.GridScreen.visible = true
	    else m.GridScreen.visible = false

        if key = "options"
            ' option key handler
        else if m.GridScreen.visible = false and key = "back"
            'hide video player and stop playback if back button was pressed
            m.videoPlayer.visible = false
            m.videoPlayer.control = "stop"
            m.GridScreen.visible = true
            m.GridScreen.setFocus(true)
            result = true
end if
end if end if end if return result End Function

 

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.