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

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

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

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

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

@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

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

Follow the below link
https://community.roku.com/t5/Roku-Developer-Program/Video-player-quot-Video-quot-component-automatically-unpauses-without-modyfing-quot-control-quot/td-p/774289