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.
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.
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.
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.
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).
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()
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…
Did you try explicitly setting the destination rectangle?
player.SetDestinationRect({x: 0, y: 0, w: 1280, h: 720}) ' 720x480 for SD
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
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
Changing the CompositionMode: to “Source” on my canvas and then setting the player.SetDestinationRect(canvas.GetCanvasRect()) seemed to work. I am now seeing the videos on the screen. Thanks RokuChris! Now to implement custom button events and the overlay, as well as make ad calls before the start of each video and I’m good. I’ll let you guys know if I run into any other problem. Appreciate the help.