Trouble With SetPreviewMode(true)

Hey guys,

I am in the process of building a Free Preview Channel that will upgrade to my current published Pay Channel. I want to use the SetPreviewMode in order to have the Free Preview channel play the first 2 minutes of each video, but I can’t seem to get it to work, I read where others had the same issue. Below is my videoscreen.brs Any help would be appreciated. Hoping that I am just missing something simple. Thanks!

Function showVideoScreen(episode As Object)

if type(episode) <> “roAssociativeArray” then
print “invalid data passed to showVideoScreen”
return -1
endif

port = CreateObject(“roMessagePort”)
screen = CreateObject(“roVideoScreen”)
screen.SetMessagePort(port)
screen.SetPreviewMode(true)
screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()

'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)

while true
msg = wait(0, port)

if type(msg) = “roVideoScreenEvent” then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isfullresult()
print “Video Completed Playback Normally”
RegDelete(episode.ContentId)
print “deleted bookmark for playback position”
elseif 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

End Function

You’ll need to set the PlayDuration meta-data before screen.setcontent(episode)
PlayDuration - Integer - Optional Playback Max Duration in Seconds - 120 (e.g. 2 minute preview)

Thanks, so it would be screen.PlayDuration(120) Yes?

no, episode.PlayDuration(120) since it’s metadata for the episode. I wouldn’t use this for a commercial project though, as users can fast forward/rewind through the entire file and watch minutes at a time.
It’s better to use a different video that is 2 minutes long if you need a 2 minute ‘preview’.

Thanks, that’s good advice. Originally, I was planning on using my already existing preview videos, but thought I would save the server space and avoid the extra xml work, but I had no idea that you could fast forward thru the video with the SetPreviewMode, thanks much

You can use EnableTrickPlay(false) to disable fast forward etc.

–Mark

“RokuMarkn” wrote:
You can use EnableTrickPlay(false) to disable fast forward etc.

–Mark

Thanks Mark, I read that EnableTrickPlay(false) also disables play and pause, this that true or can it be made to only effect fast forward?

EnableTrickPlay doesn’t work on firmware <4.9 - so first gen devices would crash if you tried to use it. (have to check firmware)
I did notice first gen devices did get a new firmware update to add the username/password for the dev access screen (3.1). Never got an answer to what other changes were made though.

I believe the only other change to 3.1 firmware was this:
ifListScreen.SetUpBehaviorAtTopRow(“exit”)

Each time I use episode.PlayDuration(120) the videoscreen will not open at anymore, should it be screen.episode.PlayDuration(120)

port = CreateObject(“roMessagePort”)
screen = CreateObject(“roVideoScreen”)
screen.SetMessagePort(port)
screen.SetPreviewMode(true)
screen.SetPositionNotificationPeriod(30)
episode.PlayDuration(120)
screen.SetContent(episode)
screen.Show()

each time I add PlayDuration either as episode.PlayDuration or screen.PlayDuration the video screen won’t open at all

PlayDuration is a variable, not a function. You would set it like this:


episode.PlayDuration = 120

–Mark

Thanks, that got it to work. After seeing it in action, I think specific preview videos would be best, as I could just play the entire video 2 minutes at a time using PlayDuration