Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Transparent
Level 7

roUniversalControlEvent - Pause/Play functions

Hi, I'm trying to implement the ability to Play and Pause my video when sent by ECP. I got the following code from customvideoplayer.

**How can I implement my video app to allow it to Play/Pause upon receiving a command through ECP (Posting /Keypress/Play) - When I try to it says code 13/code 113 in the debugger
I've code below that I'm trying to play with to get it to work but I'm not sure if I'm heading with the right approach.

Screenshot: Send video url and it plays fine
http://imgur.com/a/PcQ0v

Screenshot: Command I'm sending to try to Pause the video
http://imgur.com/a/DyPBB

Screenshot: What I'm getting back from debugger when I try to send Pause/Unpause(play) command
http://imgur.com/a/z00IC

msg = wait(0, m.port)
if msg <> invalid
'If this is a startup progress status message, record progress
'and update the UI accordingly:
if msg.isStatusMessage() and msg.GetMessage() = "startup progress"
m.paused = false
progress% = msg.GetIndex() / 10
if m.progress <> progress%
m.progress = progress%
end if

'Playback progress (in seconds):
else if msg.isPlaybackPosition()
m.position = msg.GetIndex()

else if msg.isRemoteKeyPressed()
index = msg.GetIndex()
print "Remote button pressed: " + index.tostr()

if index = 4 or index = 8 '<LEFT> or <REV>
m.position = m.position - 60
m.player.Seek(m.position * 1000)
else if index = 5 or index = 9 '<RIGHT> or <FWD>
m.position = m.position + 60
m.player.Seek(m.position * 1000)
else if index = 13 '<PAUSE/PLAY>
if m.player.paused m.player.Resume() else m.player.Pause()
end if

else if msg.isPaused()
this.paused = true


else if msg.isResumed()
this.paused = false


end if
'Output events for debug
print msg.GetType(); ","; msg.GetIndex(); ": "; msg.GetMessage()
if msg.GetInfo() <> invalid print msg.GetInfo();
end if
end while



Or is this the right way to do it -
  'event = port.GetMessage()
' if (event <> invalid)
' if (type(event) = "roUniversalControlEvent")
' code = event.GetInt()
' print "code: " + stri(code)
' if code = 13
'if player.paused player.Resume() else player.Pause()
' end if

' else if msg.isPaused()
' this.paused = true

' else if msg.isResumed()
' this.paused = false

' endif
' endif
0 Kudos
20 Replies
squirreltown
Level 9

Re: roUniversalControlEvent - Pause/Play functions

"m" is the global associative array in Brightscript. If you wanted to use the same message port for your whole channel you would name it "m.port", and then it will work in all of your functions. If you just name it "port" it will go out of scope when the function it's assigned in closes.

You didn't actually say what your problem is, if you have one. I would suggest reading this board on threads concerning port usage. A lot of it won't make sense at first but there is literally no other way to get a handle on it short of having it explained in person or the answers you will get to specific questions here.
Kinetics Screensavers
0 Kudos
Transparent
Level 7

Re: roUniversalControlEvent - Pause/Play functions

I'm trying to figure out how to implement pause/play when using external control protocol to send messages to control my video app, I thought atleast one of the above code should work and can't figure out why it isn't working
0 Kudos
squirreltown
Level 9

Re: roUniversalControlEvent - Pause/Play functions

"Transparent" wrote:
I'm trying to figure out how to implement pause/play when using external control protocol to send messages to control my video app, I thought at least one of the above code should work and can't figure out why it isn't working


Probably because ECP and roUniversalControlEvent are different things.

heres the RTFM on ECP - https://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide
Kinetics Screensavers
0 Kudos
Transparent
Level 7

Re: roUniversalControlEvent - Pause/Play functions

Okay but if I try to play the video using ECP play command it says 'code 13' in the debugger, and code 13 is for Play/Pause in the roUniversalControlEvent
0 Kudos
squirreltown
Level 9

Re: roUniversalControlEvent - Pause/Play functions

"Transparent" wrote:
Okay but if I try to play the video using ECP play command it says 'code 13' in the debugger, and code 13 is for Play/Pause in the roUniversalControlEvent


Is that a question? What exactly is the problem?
Kinetics Screensavers
0 Kudos
EnTerr
Level 8

Re: roUniversalControlEvent - Pause/Play functions

I haven't the foggiest what does "customvideoplayer" use!
Is it roVideoPlayer? If so, use .pause()/.resume()
0 Kudos
Transparent
Level 7

Re: roUniversalControlEvent - Pause/Play functions

"EnTerr" wrote:
I haven't the foggiest what does "customvideoplayer" use!
Is it roVideoPlayer? If so, use .pause()/.resume()



I am using .pause() and .resume(). s: if the event from using play or pause command code = 13, play or pause the video. shouldn't this work? because Play and Pause are given defined as code 13? Seems like the right way to do it in my mind but I can't seem to get it to work
0 Kudos
belltown
Level 7

Re: roUniversalControlEvent - Pause/Play functions

None of what you're saying makes any sense. Why not just post the code you're using, and describe what happens when you say "I can't seem to get it to work", versus what you think should happen.
https://github.com/belltown/
0 Kudos
Transparent
Level 7

Re: roUniversalControlEvent - Pause/Play functions

"belltown" wrote:
None of what you're saying makes any sense. Why not just post the code you're using, and describe what happens when you say "I can't seem to get it to work", versus what you think should happen.


I guess my question isn't as my name...aye...

'Why not just post the code you're using' - But I did post a segment of the code i'm trying to use, posting the whole lot of code I have would cause confusion as its a mess

'describe what happens' - it does not pause. It says code 13/code 113 in the debugger upon trying to play/pause as above

I've added pictures above to try and make it clearer what i'm doing if that helps
0 Kudos