如何判断 html 视频当前是否正在播放

How to tell if html video is currently playing

我正在尝试测试 Html 视频当前是否正在播放,但似乎无法弄清楚如何获取 currentTime。我一直在尝试这样的事情:

async videoIsPlaying(indexOfVideo = 0) {
    return ClientFunction(() => {
        const video = document.getElementsByTagName('video')[indexOfVideo];
        return video.currentTime > 0;
    });
}

但我的期望是:

await t.expect(await playerPage.videoIsPlaying()).eql(true);

返回:

AssertionError: expected [Function: __$$clientFunction$$] to deeply equal true

我做错了什么?另外,我使用 .eql() 因为 .ok() returns 对于任何结果都是真实的。

啊...只需要触发函数,并因此传入索引...

async videoIsPlaying(indexOfVideo = 0) {
    return await ClientFunction((indexOfVideo) => {
        const video = document.getElementsByTagName('video')[indexOfVideo];
        return video.currentTime > 0;
    })(indexOfVideo);
}

仅供参考,此函数存在于页面对象中