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: 
newchannel
Roku Guru

How to keep graphic displayed on screen?

EDIT: I just reread my first post. I was working on an audio channel and a video channel at the same time and meant to post in my other forum topic the code snippets I was changing in order to try and show an image while channel is loading a list of videos from xml. Just wanted to explain why the posts orginaly says "audio" but then I was posting about videos. Sorry for the mistake.


But the audio channel with a list of audios is similar coding as well which will give me the same scenario ie: image flickering.

I'm guessing its a simple fix but I'm still a code newbie myself.
http://www.victoryNOWfilmsandtv.com
0 Kudos
7 REPLIES 7
RokuJoel
Binge Watcher

Re: How to keep graphic displayed on screen?

If this is based on the 2D API which I think you are using for this channel, then you would find your while true loop, and just before that, create a bitmap that you want to show on the screen:

bmp=createobject("roBitmap","pkg:/images/myimage.jpg")
bmp.setAlphaEnable(true)


Then, near the bottom of your loop, just before the screen.swapbuffers() or screen.finish() command:

screen.drawobject(x,y,bmp)

You would need to set the values of x and y so that the image appears where you want it to - 0,0 is the upper left hand of the screen.
also make sure that where your screen is created, you add (assuming that the variable name for your screen is "screen"):

screen.setAlphaEnable(true)

- Joel

- Joel
0 Kudos
newchannel
Roku Guru

Re: How to keep graphic displayed on screen?

Okay thanks Joel.

My try at it so far has the logo image remaining on the screen and doesn't begin playing any videos.Will try a few more changes.

Here is a piece in the code where I made additions

While TRUE
canvas.Clear(&h00000000)
msg=port.GetMessage()
If Type(msg)="roUniversalControlEvent"
bpressed=msg.GetInt()
If bpressed<100
Print"Remote button pressed: ";bpressed
Else
Print"Remote button released: ";bpressed
End If
If bpressed=0 Exit While'0=BACK BUTTON
'1=unused
If bpressed=2 Exit While'2=UP BUTTON
'3=DOWN BUTTON
'4=LEFT BUTTON
'5=RIGHT BUTTON
'6=SELECT BUTTON
'7=INSTANT REPLAY BUTTON
'8=REWIND BUTTON
'9=FAST FORWARD BUTTON
'10=INFO BUTTON
'11=unused
'12=unused
If bpressed=13 '13=PLAY/PAUSE BUTTON
If paused=FALSE
paused=TRUE
player.Pause()
Else
paused=FALSE
player.Resume()
End If
End If
Else If Type(msg)="roVideoPlayerEvent"
If msg.isStatusMessage()
If msg.GetMessage()="startup progress"
'Print"buffering=";msg.GetIndex()/10
If msg.GetIndex()/10=100 Print "Playing Video #:";index
Else If msg.GetMessage()="end of stream"
Print"message is full result event - back to position 0"
If index<max
index=index+1
RegWrite("indexpos",index.ToStr(),"studioc")
Else
index=0
RegWrite("indexpos",index.ToStr(),"studioc")
End If
RegWrite("indextime","0","studioc")
End If
Else If msg.isPlaybackPosition()
indextime=msg.GetIndex()
RegWrite("indextime",msg.GetIndex().ToStr(),"studioc")
Else If msg.isStreamStarted()
Print"stream started event"
Else If msg.isFullResult()
Print"message is full result event"
Else If msg.isRequestFailed()
Print"Video #:";index;" ";msg.GetMessage()
End If
canvas.drawobject(100,100,bmp)
End If
canvas.SwapBuffers()
End While
End Sub


further up in the code where I added canvas.setAlphaEnable(true)...I may have it in the wrong place and going to try it again after I move it. but here is where I have it at present.

Sub RunUserInterface()
port=CreateObject("roMessagePort")
progress=0 'buffering progress
position=0 'playback position (in seconds)
paused=FALSE 'is the video currently paused?
fonts=CreateObject("roFontRegistry") 'global font registry
canvas.setAlphaEnable(true)
canvas=CreateObject("roScreen",TRUE) 'user interface
player=CreateObject("roVideoPlayer")
player.SetPositionNotificationPeriod(1)



Still trying to learn but it hasn't sunk in yet.
http://www.victoryNOWfilmsandtv.com
0 Kudos
newchannel
Roku Guru

Re: How to keep graphic displayed on screen?

One change just made after posting the original note to you is I now get image then black then image flickering (off centered since I dont have x and y correct yet) then video begins. The change I made that caused this to happen is moving the canvas.setAlphaEnable(true) to the following area in the code.

'Setup image canvas:
canvas.setAlphaEnable(true)
canvas.SetPort(port) 'change from canvas.setmessageport(port) to restore roku1 functionality
player.SetMessagePort(port)
'canvas.SetLayer(0, { Color: "#000000" })
'canvas.Show()



Trying debugger but after last sideload it wont telnet.

EDIT: the flickering bitmap image can be seen flickering before the videos begin and also flickering off and on over video as it plays. My guess is I have something in the wrong place in the code.

I placed the canvas.drawobject(0,0,bmp) here:

Else If msg.isRequestFailed()
Print"Video #:";index;" ";msg.GetMessage()
End If
canvas.drawobject(0,0,bmp)
End If

canvas.SwapBuffers()
End While
End Sub
http://www.victoryNOWfilmsandtv.com
0 Kudos
newchannel
Roku Guru

Re: How to keep graphic displayed on screen?

Anyone have any ideas?
http://www.victoryNOWfilmsandtv.com
0 Kudos
newchannel
Roku Guru

Re: How to keep graphic displayed on screen?

Well I tried to place the code in different areas in the main.brs file but the image still continues to flicker before the video and while the video plays.
http://www.victoryNOWfilmsandtv.com
0 Kudos
NewManLiving
Visitor

Re: How to keep graphic displayed on screen?

In your first code sample you have a canvas clear statement at the top of your
Loop. At a glance that would be an area I would investigate. As you could be clearing
Constantly
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
newchannel
Roku Guru

Re: How to keep graphic displayed on screen?

EDIT: I just reread my first post. I was working on an audio channel and a video channel at the same time. But actually this post should have been about the video channel. I am wanting the image to stay on screen until the video loads. I need to show the viewer that the video is coming up and not have it the way it is now ie: splash, black screen, video plays


I have made several changes but cant stop the image from flickering even while the video plays the image is seen flickering.

I'm guessing its a simple fix but I'm still a code newbie myself.
http://www.victoryNOWfilmsandtv.com
0 Kudos