JavaScript/AppleScript:获取 html 视频的当前时间 [英] JavaScript / AppleScript: Get current time of html video

查看:39
本文介绍了JavaScript/AppleScript:获取 html 视频的当前时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取这个视频的当前时间(用户代理必须使用 AppleScript 或 AppleScript 中的 Javascript 设置为 iOS 10、iPhone.

I’d like to get the current time of this video (user agent must be set to iOS 10, iPhone) using Applescript or Javascript within AppleScript.

因为可以用这个来改变视频位置......

As it is possible to change the video position with this…

tell application "Safari"

do JavaScript "document.getElementsByTagName('video')[0].currentTime = " & 90

end tell

……我是这么想的……

tell application "Safari"

    set ttime to do JavaScript "document.getElementsByTagName('video')[0].currentTime()"

    return ttime

end tell

... 可以解决问题 - 但事实并非如此.请帮忙:)

… would do the trick - but it doesn’t. Please help :)

推荐答案

HTMLMediaElement.currentTime 是一个属性,而不是一个函数.你不需要调用它,所以去掉括号:

HTMLMediaElement.currentTime is a property, not a function. You don't need to call it, so remove the parentheses:

set ttime to do JavaScript "document.getElementsByTagName('video')[0].currentTime"

这篇关于JavaScript/AppleScript:获取 html 视频的当前时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆