kooljay68
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
12:15 PM
Timer to stop live feed
Hello,
I need some direction in how to stop play once started with the timer
I thought this would work ... but it isn't ..... any direction in this would be greatly appreciated
Thanks
I need some direction in how to stop play once started with the timer
if msg.GetIndex() = 1
m.timer=createobject("roTimeSpan")
m.timer.mark()
while true
if m.timer.totalseconds < 20 then
PlayStart = 0
else
return showIndex
end if
end while
I thought this would work ... but it isn't ..... any direction in this would be greatly appreciated
Thanks
9 REPLIES 9

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
02:12 PM
Re: Timer to stop live feed
You should add the timer handling code to the event loop which handles the video. Change the wait to a timed wait, if it isn't already, and periodically check the elapsed time on the timer.
--Mark
--Mark
kooljay68
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
03:02 PM
Re: Timer to stop live feed
so does that mean the timer has to be part of the appVideoScreen.brs loop then?

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
03:06 PM
Re: Timer to stop live feed
Yes, that's correct.
--Mark
--Mark
kooljay68
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
03:16 PM
Re: Timer to stop live feed
ok ... I think I know where it goes now ... but I am a little lost on how I would change the different stop times if I wanted too ... which page would I have to send that command from ?
kooljay68
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
03:47 PM
Re: Timer to stop live feed
OK ... I added this to the video page and it does nothing .... I guess I am really lost on what I am supposed to do here - Please help.
screen.Show()
m.timer=createobject("roTimeSpan")
m.timer.mark()
'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)
while true
msg = wait(0, port)
if m.timer.totalseconds > 60 then
print "End Preview: "; msg.GetIndex(); " " msg.GetData()
end if
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
04:51 PM
Re: Timer to stop live feed
A wait timeout of 0 will wait forever, until a message is received.
You want to change that to an incremental timeout like
msg = wait(1000, port)
That way it will run through the loop at least once per second all by itself.
You want to change that to an incremental timeout like
msg = wait(1000, port)
That way it will run through the loop at least once per second all by itself.
kooljay68
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
05:19 PM
Re: Timer to stop live feed
OK .. I changed that like you say ... but I must still be off the mark ... because it will not kick out of the video ? Here is all of the code for the page ... maybe that will help
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.Show()
screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()
m.timer=createobject("roTimeSpan")
m.timer.mark()
'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)
while true
msg = wait(1000, port)
if m.timer.totalseconds > 60 then
print "End Preview: "; msg.GetIndex(); " " msg.GetData()
end if
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
End Function

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
06:06 PM
Re: Timer to stop live feed
"kooljay68" wrote:
OK .. I changed that like you say ... but I must still be off the mark ... because it will not kick out of the video ? Here is all of the code for the page ... maybe that will help
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.Show()
screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()
m.timer=createobject("roTimeSpan")
m.timer.mark()
'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)
while true
msg = wait(1000, port)
if m.timer.totalseconds > 60 then
print "End Preview: "; msg.GetIndex(); " " msg.GetData()
end if
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
End Function
You don't have code in there to exit the video. Right now, it will likely crash after 60 seconds, because you're not checking the validity of msg. That aside, at best it should print the message "End Preview..." to the console (every second) after it reaches 60 seconds, but it won't exit the video, because you're not closing the screen.
BTW, if your goal is to just show a portion of the video as a preview, you should be able to use the PlayDuration content metadata attribute, instead of timing it in code. Alternatively, you could kill the video based on the playback position notification.
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
kooljay68
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
06:33 PM
Re: Timer to stop live feed
Sweet ... I used PlayDuration and it worked like a charm .... Thank you for the input.