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?

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

that might help while identifying the issue.

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.