← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #238993]: Need to verify Youtube Video is playing

 

Question #238993 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/238993

RaiMan proposed the following answer:
@Eugene
Yes this might work, but not always (still phases !?)

This is my solution:
watching the elapsed time display in the control bar and looking for the capture 1.1 seconds before.
Should change while running.

This works for me: (used version 1.0.1)

The lines starting with #dev# I used while developing the script

switchApp("Safari")
top = find("top-left-youtube-logo.png")

# to eval the relative position of the elapsed time display
#dev# highlight(-2)
#dev# r = selectRegion()
#dev# print r, r.x-top.x, r.y-top.y

# elapsed time display
# values might have to be adjusted depending on your top capture
time = Region(top.x+225, top.y+426, 40,20)
# make control bar visible
time.hover()
wait(1)

pause = "button-pause.png"
play = "button-play.png"  
button = time.left(30).grow(5)
#dev# button.highlight(2)

# switch to play, if not playing
if button.exists(play, 0):
    button.click()
    
# show, we started to watch
hover(button.leftAt(20))
while True:
    lastTime = capture(time)
    wait(1.1)
    if (time.exists(Pattern(lastTime).exact(), 0)):
        # probably stopped, show it
        time.highlight(2)
        print "stopped?"
        break

There might be an equivalent solution using observe().

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.