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: 
jvalero
Visitor

roVideoPlayer not displaying...

I've developed a channel which works fine using roVideoScreen. However, I'm now trying to implement a basic video overlay using roImageCanvas and I also want to implement the remote LEFT as a restart video/jump back and the RIGHT as jump to next video. I've done a lot of reading on the subject and I realize that in order to do this I need to implement roVideoPlayer in place of roVideoScreen. I have the component setup, and I can get it to start pushing status updates and messages on the Roku box BrightScript Debugger, but the videos never start streaming and they never show up. What am I missing?

I'm building my playList from an XML feed, which I then parse and place into an AA filled with the Content Meta-Data.

player = CreateObject("roVideoPlayer")
messagePort = CreateObject("roMessagePort")
player.SetMessagePort(messagePort)
player.SetPositionNotificationPeriod(1)
player.SetContentList(playList)
player.Play()


I then setup an event loop and do get back status updates for the If Type(msg) = "roVideoPlayerEvent" portion of the loop, but none of the other events ever fire and nothing ever shows up on my screen.
0 Kudos
10 REPLIES 10
RokuChris
Roku Employee
Roku Employee

Re: roVideoPlayer not displaying...

roVideoPlayer should be used in conjunction with either roImageCanvas or roScreen. Those are the components that will raise events associated with remote key presses. Take a look at the customvideoplayer sample in the SDK to see how that works.
0 Kudos
jvalero
Visitor

Re: roVideoPlayer not displaying...

Okay, I'm not trying to implement the key press events yet. I'm just trying to get basic playback using roVideoPlayer, which should stream from the player.Play() correct? Or are you saying that default playback will require a key press? Just to clarify, I do understand the relationship of how the roImageCanvas has to listen for the key press events as roVideoPlayer does not have an event listener for key presses, but I'm not at that stage yet. I'm just trying to get standard playback in the roVideoPlayer working without any special remote key functionality or overlay. Both of those will come next.
0 Kudos
RokuJoel
Binge Watcher

Re: roVideoPlayer not displaying...

probably something is not correct in your "playlist" variable.

if your playlist is a list of videos to sequentially play, that will not work. You would probably set contentlist(playlist[index]) if you wanted to select one video from a list (array) of videos.

otherwise perhaps post an example of the data structure contained in your "playlist" variable.

- Joel
0 Kudos
jvalero
Visitor

Re: roVideoPlayer not displaying...

Thanks for the quick responses guys.

I'm building my playList array like this.

Iterate through each video node in my XML, and pull out the following data creating an AA for each one and then pushing it into my playList array.

Here is my current code:

'// Create Metadata Hash
metaData = {
Description: decription,
videoUrl: videoUrl,
Length: duration,
pubDate: videoTime,
Title: videoTitle,
StreamUrls: videoItems,
StreamBitrates: videoBitrates,
StreamQualities: videoQualities,
StreamFormat: "mp4"
}

'// Push Metadata Into Playlist
playList.push(metaData)


For the URLs, Bitrates and Qualities I am also building arrays, that are in sequence with one another so videoItems, videoBitrates and videoQualities are arrays.

This playList format works with roVideoScreen by using screen.SetContent(playList[index]), so I am essentially now converting it over to be player.SetContentList(playList).
0 Kudos
TheEndless
Channel Surfer

Re: roVideoPlayer not displaying...

I'm pretty sure the roVideoPlayer requires a transparent image canvas (or roScreen) in order to be seen. Try adding the following immediately prior to opening the video player:
canvas = CreateObject("roImageCanvas")
canvas.SetLayer(0, {Color: "#00000000"})
canvas.Show()
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
jvalero
Visitor

Re: roVideoPlayer not displaying...

Tried it. Unfortunately, no change. I did have other roImageCanvas running, one being my screen facade and the other the overlay. I even tried it with the overlay disabled. It's just not streaming the videos, even though the debugger shows:

Unexpected event type: 8
msg = end of stream | index = 0
Video status: 0 0
msg = startup progress | index = 0
Video status: 0 0
msg = startup progress | index = 66
Video status: 66 0
msg = startup progress | index = 132
Video status: 132 0
msg = | index = 2
Unexpected event type: 0
msg = startup progress | index = 198
Video status: 198 0
msg = startup progress | index = 264
Video status: 264 0
msg = startup progress | index = 330
Video status: 330 0
msg = Stream started. | index = 0
Stream Started
msg = startup progress | index = 330
Video status: 330 0
msg = startup progress | index = 561
Video status: 561 0
msg = startup progress | index = 592
Video status: 592 0
msg = startup progress | index = 809
Video status: 809 0
msg = startup progress | index = 999
Video status: 999 0
msg = startup progress | index = 999
Video status: 999 0
msg = startup progress | index = 1000
Video status: 1000 0
msg = start of play | index = 0
Video status: 0 0
msg = | index = 0
msg = | index = 1
msg = | index = 2
msg = | index = 3
msg = | index = 4
msg = | index = 5

etc... etc...
0 Kudos
TheEndless
Channel Surfer

Re: roVideoPlayer not displaying...

Did you try explicitly setting the destination rectangle?
player.SetDestinationRect({x: 0, y: 0, w: 1280, h: 720}) ' 720x480 for SD
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
jvalero
Visitor

Re: roVideoPlayer not displaying...

I had tried earlier on when trying to implement roVideoPlayer. I have now tried it again with and without the transparent canvas you suggested. The stream just never starts and the screen remains black. Any other suggestions?

Can someone post an example of the roVideoPlayer script that they have working? Something in a live app, not the example video player as I've already taken a good long look at it and tried implementing what it is doing. Thanks!

Also I have a question regarding your examples. In the exSimpleVideoPlayer and the exVideoPlayer examples that are included in the SDK, you are using roVideoScreen instead of the actual roVideoPlayer. Is there a reason for this? Also I notice that all of the Event Loops for roVideoScreen in your examples include an event listener for isButtonPressed() an event that is actually triggered by this screen and does not work. Are the examples outdated? See following code example from exVideoPlayer:

while true
msg = wait(0, port)

if type(msg) = "roVideoScreenEvent" then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
exit while
elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
else
print "Unexpected event type: "; msg.GetType()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: roVideoPlayer not displaying...

roVideoScreen is the preferred playback component because it gives users a consistent experience across the platform. You want to look at the customvideoplayer example for roVideoPlayer.

Based on the events you're seeing, I'd say the video is playing. It's just not being displayed on the screen. I think the missing piece may be setting the CompositionMode on your canvas to "source"...

	port = CreateObject("roMessagePort")
canvas = CreateObject("roImageCanvas")
canvas.SetMessagePort(port)
canvas.SetLayer(0, { color: "#00000000", CompositionMode: "Source" })
canvas.Show()

player = CreateObject("roVideoPlayer")
player.SetMessagePort(port)
player.SetDestinationRect(canvas.GetCanvasRect())
player.SetContentList([{
streamFormat: "mp4"
stream: { url: "http://video.ted.com/talks/podcast/DavidBrooks_2011.mp4" }
}])
player.Play()

while true
msg = Wait(0, port)
print type(msg)
end while
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.