Flicker between one roScreen and another roScreen

i cut out a lot of the clutter but my code in a nutshell is this;


Function Main() as void
loadscreen = CreateObject("roScreen" , true)
if m.device.legacy = true then
	loadscreen.SetPort(port)
else
	loadscreen.setmessageport(port)
end if
loadscreen.setalphaenable(true)
loadscreen.Clear(&h00000000)

while (true)
	loadscreen.Clear(&h00000000)
   	loadscreen.DrawObject(stuff)
	loadscreen.DrawText(stuff)
	loadscreen.SwapBuffers()
	msg=port.getmessage()
	if type(msg)= "roUniversalControlEvent"
		id = msg.GetInt()
		if (id = 6)
		'***** OK
		    launchplayer()
		end if
	end if
end while
End Function

which calls this…


function launchplayer()
	
	playerscreen = CreateObject("roScreen")
	port = CreateObject("roMessagePort")
	playerscreen = CreateObject("roScreen" , true)

	if m.device.legacy = true then playerscreen.SetPort(port) else playerscreen.setmessageport(port)
	playerscreen.setalphaenable(true)
	
	while (true)
	    	playerscreen.DrawObject(0,0,images[0]) 
		playerscreen.SwapBuffers()
		
		if viewtimer.totalseconds() >= (60 * 10) then
			exit while
		end if		
	
	
	    msg=port.getmessage()
		if type(msg) = "roAudioPlayerEvent"
		    'print msg
		    if msg.isStatusMessage() then
		        print "roAudioPlayerEvent: "; msg.getmessage()
		        if msg.getmessage() = "end of playlist"
				print "end of playlist"
		        	return 0
		        end if
		    endif
	    end if  
	    
		if type(msg)= "roUniversalControlEvent"
			id = msg.GetInt()
			'print msg
			print msg.GetInt()
				if (id = 2) or (id = 0)
					exit while
				end if	
		end if	
	end while
end function

the problem is, when the launchplayer() function is called and exited, it flickers between what was on the roScreen in launchplayer() and the roScreen ran beforehand. It happens on my Roku LT (2400) but not on my Roku 1000. how do I fix that?

I don’t think you can. Creating an roScreen causes the screen to go black until you call SwapBuffers(). What I usually do in a situation where I need to use two different roScreens is I’ll do a quick fade to black on the old screen and a fade in on the new screen, so it’s not quite so jarring. The other option would be to use the same roScreen and either store it globally or pass it back and forth to the functions that need it.

I always use exactly one roScreen through the whole app. It’s very simple and avoids this problem.

–Mark

@360tv , in your specific case just pass the screen as argument to launchPlayer() and use that inside (draw, run message loop on already existing port etc) like so:


Function Main() as void
    loadscreen = CreateObject("roScreen" , true)
    ...
		if (id = 6)
		'***** OK
		    launchPlayer(loadScreen)
		end if
    ...
End Function

function launchPlayer(playerScreen)
    port = playerScreen.getPort() '.getPort()/setPort() work on both old and new fw
    ...
end function

In addition this will save memory. A roScreen necessarily takes lots of memory. I am guesstimating ~7MB for HD. The only catch is on return will have to re-draw the screen… which i see you do on every loop, so all’s swell.

global roScreen…

duh! Thanks fellas!