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: 
ssaguiar
Streaming Star

How to change from one scene to another?

Jump to solution

Hi to all

I wish to know if somebody can answer one question, which seems simple but I am not getting to work fine.

I am working in a channel project for a iptv provider.

There are 2 scenes (screen), one of them is the login screen (which will be remake to use Roku Pay) and, when the user has logged in, he will be shown the player screen.

After that, when the user open the channel, if already registered (logged in), he will be presented to the player scene (screen).

Ok, now the bad part:

If the user is logged out (using a remote command - thru the server admin or by another app (Android or IOS), then he will be logged out in the Roku channel and will be presented to the login screen gain.

If he logs in again the channels will not play.

This is caused by the fact that the channel's scenes are being added (the login scene will have 2 instances and the player scene will also have 2 instances working).

the code I use to instantiate the scenes is:

In main.brs:

if((regDeviceid = invalid) or (regToken = invalid)) then
    m.scene = m.screen.CreateScene("LoginScene")
    m.scene.signalBeacon("AppDialogInitiate")
    m.screen.show()
else
   m.scene = m.screen.CreateScene("HomeScene")
   m.scene.signalBeacon("AppDialogInitiate")
   m.screen.show()
end if
 
In the LoginScene.brs:
 
m.screen = CreateObject("roSGScreen") 'Create Screen object
m.scene = m.screen.CreateScene("HomeScene")
m.screen.show()
m.top.signalBeacon("AppDialogComplete")

 

and, in the HomeScene.brs (player):

    ' call a task for this:
    m.screen = CreateObject("roSGScreen") 'Create Screen object
    m.screen.CreateScene("LoginScene")
    m.screen.show()
 
As you can see, I create a new screen (roSGScreen) on every call to transfer to the other scene (wich causes te scene to remain in memory).
 
I tried to create a global screen (roSGScreen) in main.brs and refer to it in the scenes but it didn't work.
 
I searched in iternet and found some (few) materials, stating that we must use Screens Back Stack using array, as in:
 
There is also an example, in Roku's examples which uses stack: 
scenegraph-master-sample-master/DetailsScreen
 
I ask: is this the way to go? If so, where can I find some examples and tutorial (which are very rare in Roku)?
 
I really thanks you for any clue about this matter.
 
Thanks
 
0 Kudos
1 Solution

Accepted Solutions
renojim
Community Streaming Expert

Re: How to change from one scene to another?

Jump to solution

In general you only want one roScreen that creates one scene with multiple screens (not to be confused with multiple roScreens).  So you'd have a login screen and a home screen under one scene and then change the visibility of those screens as appropriate in your code.

<?xml version="1.0" encoding="utf-8" ?>
<component name="home_scene" extends="Scene" initialFocus="login_screen">
   <script type="text/brightscript" uri="pkg:/components/home_scene.brs" />
   <children>
      <login_screen
         id="login_screen"
         visible="true"
         translation="[0,0]"
      />
      <home_screen
         id="home_screen"
         visible="false"
         translation="[0,0]"
      />
   </children>
</component>

 

You should note that IPTV channels/apps are highly frowned upon by Roku if the provider can't prove he has the rights to whatever services he's providing.  If this is in any way not legitimate I'd stay away from it if I were you.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.

View solution in original post

2 REPLIES 2
renojim
Community Streaming Expert

Re: How to change from one scene to another?

Jump to solution

In general you only want one roScreen that creates one scene with multiple screens (not to be confused with multiple roScreens).  So you'd have a login screen and a home screen under one scene and then change the visibility of those screens as appropriate in your code.

<?xml version="1.0" encoding="utf-8" ?>
<component name="home_scene" extends="Scene" initialFocus="login_screen">
   <script type="text/brightscript" uri="pkg:/components/home_scene.brs" />
   <children>
      <login_screen
         id="login_screen"
         visible="true"
         translation="[0,0]"
      />
      <home_screen
         id="home_screen"
         visible="false"
         translation="[0,0]"
      />
   </children>
</component>

 

You should note that IPTV channels/apps are highly frowned upon by Roku if the provider can't prove he has the rights to whatever services he's providing.  If this is in any way not legitimate I'd stay away from it if I were you.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
ssaguiar
Streaming Star

Re: How to change from one scene to another?

Jump to solution

Thank you my friend for your answer.

I work in Brazil for a IPTV legal provider. We have all authorizations from the content providers we resell content of.

Again thank you for your help. I will try to get it working.

 

Cheers.

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.