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: 
unDEFER
Streaming Star

Pause on playing cycle

Hello!

By some condition I need to pause playing video just after it starts playing. My code looks like this:

 

function onVideoStateChanged()
    print "VIDEO "; m.Video.state   
    if m.Video.state = "playing"
        if <some condition>
            print "Force pause"
            m.Video.control = "pause"
        end if
    end if
end function

But in the log I see:

 

VIDEO buffering
VIDEO playing
Force pause
VIDEO paused
VIDEO playing

 

And video anyway plays. (I don't remember any other my code which can unpause it by itself). How to get around it?

0 Kudos
2 REPLIES 2
AbhiK
Streaming Star

Re: Pause on playing cycle

Can you share some information about the stream you are using?

that might help while identifying the issue.

0 Kudos
unDEFER
Streaming Star

Re: Pause on playing cycle

I did the trick by the next code:

function onVideoStateChanged()
    print "VIDEO "; m.Video.state   
    if m.Video.state = "playing"
if m.ISaidPause
m.Video.control = "pause"
m.ISaidPause = false
end if
if <some condition> print "Force pause" m.Video.control = "pause"
m.ISaidPause = true end if end if end function

Where m.ISaidPause just boolean flag initialized by false.

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.