Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
增加判断视频是否已经在播放
Browse files Browse the repository at this point in the history
  • Loading branch information
catlair committed Jun 9, 2021
1 parent 2ab729b commit ad421d8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/dailyTask/playVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ export default async function playVideo(page: Page, logger?: Logger) {
logger = getLogger('playVideo');
}
try {
const isVideoPlaying = await page.$eval(
'video',
(video: HTMLVideoElement) =>
new Promise(res => {
const prevTime = video.currentTime;
setTimeout(() => res(prevTime !== video.currentTime), 1000);
}),
);
if (isVideoPlaying) {
logger.debug('视频正在播放...');
return;
}
logger.debug('播放视频...');
const $video = await page.$('video');
await $video.click();
Expand Down

0 comments on commit ad421d8

Please sign in to comment.