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: 
Aashish_Kumar
Reel Rookie

Roku video player pause button not working

Hey Roku Community,

I'm currently working on an application that involves controlling the Roku video player, and I'm encountering an issue with pausing the video. Here's a breakdown of the problem:

Issue Description: When the user presses the pause button, I'm attempting to set m.video.state to "paused" as per the Roku video player API. However, despite setting the state to "paused", the video does not pause as expected.

Steps Taken:

  1. Reviewed Roku's official documentation for the video player API to ensure correct usage.
  2. Verified code logic to ensure that m.video.state is being set correctly when the pause button is pressed.
  3. Implemented console logs to track the value of m.video.state before and after attempting to pause the video.
  4. Tested the application in real Roku device environments to replicate the issue
Labels (1)
0 Kudos
7 REPLIES 7
renojim
Community Streaming Expert

Re: Roku video player pause button not working

state is READ-ONLY and gives you the current state of the video node.  control is what you want to use and you want to set it to pause.

https://developer.roku.com/docs/references/scenegraph/media-playback-nodes/video.md

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
Jman1
Newbie

Re: Roku video player pause button not working

That was a great response I came here to find out as well...Thanks

Prodigy'sOATH©
0 Kudos
Aashish_Kumar
Reel Rookie

Re: Roku video player pause button not working

WE ARE ALREADY USING THIS -----
 
if m.video.state = "playing"
  setControlMode("pause")
  m.play.uri = "pkg:/images/play.png"
  m.video.control = "pause"
  m.video.state = "paused"
else if m.video.state = "paused"
  setControlMode("play")
  m.video.control = "resume"
  onStateChange()
  m.play.uri = "pkg:/images/pause.png"
end if
0 Kudos
RoyalPetBox
Reel Rookie

Re: Roku video player pause button not working

This worked for me this week:

Function onKeyEvent(key as String, press as Boolean) as Boolean  'Maps back button to leave video
    if press
        if key = "back"  'If the back button is pressed
            if m.Video.visible
                returnToUIPage()
                return true
            end if         
        else
            if key = "play"
                  if m.Video.state = "playing"
                        m.Video.control = "pause"
                        return true
                    else
                        m.Video.control = "resume"
                        return true
                   end if
            end if
        end if
      return false
    end if
end Function

 

0 Kudos
renojim
Community Streaming Expert

Re: Roku video player pause button not working

@Aashish_Kumar, first, stop setting the state to anything!  You can't set a READ-ONLY field.  Second, when it's playing, you're setting it to pause and when it's paused you're setting it to resume.  It's just going to bounce back and forth between playing and paused.  Without seeing the rest of the code, it's hard to say if that's part of your problem.

Add prints to your code.  It's the best way to see what's going on.  stop can also be utilized when things aren't happening as expected:

 

if m.video.state = "playing"
  print "playing"
  m.video.control = "pause"
  stop
  ... other code
else if m.video.state = "paused"
  print "paused"
  ... other code
end if

 

 

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
Aashish_Kumar
Reel Rookie

Re: Roku video player pause button not working

Currently when i set control = "pause" it has change the state to pause but after 1 2 sec it has change to playing automatic

0 Kudos
MaheshDAZN
Reel Rookie

Re: Roku video player pause button not working

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.