MCPcopy Create free account
hub / github.com/Xu22Web/tech-study-js / handleVideo

Function handleVideo

tech-study.js:3978–4020  ·  view source on GitHub ↗

* @description 处理视频

()

Source from the content-addressed store, hash-verified

3976 * @description 处理视频
3977 */
3978async function handleVideo() {
3979 // videos
3980 const videos = await $_('video', undefined, 10000);
3981 // 视频
3982 const video = videos[0];
3983 // 播放按键
3984 const playBtn = $$('.prism-play-btn')[0];
3985 if (video && playBtn) {
3986 // 设置是否静音
3987 watchEffect(() => (video.muted = settings[SettingType.VIDEO_MUTED]));
3988 log('正在尝试播放视频...');
3989 // 播放超时
3990 const timeout = setTimeout(() => {
3991 log('视频播放超时!');
3992 // 提示
3993 createTip('视频播放超时!');
3994 // 关闭页面
3995 handleCloseTaskWin();
3996 }, 20000);
3997 // 能播放
3998 video.addEventListener('canplay', () => {
3999 log('正在尝试播放视频...');
4000 if (video.paused) {
4001 // 尝试使用js的方式播放
4002 video.play();
4003 if (video.paused) {
4004 // 尝试点击播放按钮播放
4005 playBtn.click();
4006 }
4007 }
4008 // 已经播放
4009 if (!video.paused) {
4010 clearTimeout(timeout);
4011 // 视听学习
4012 reading(1);
4013 }
4014 });
4015 return;
4016 }
4017 log('未找到视频!');
4018 // 关闭页面
4019 handleCloseTaskWin();
4020}
4021/**
4022 * @description 读新闻或者看视频
4023 * @param type :0为新闻,1为视频

Callers 1

tech-study.jsFile · 0.70

Calls 7

$_Function · 0.70
$$Function · 0.70
watchEffectFunction · 0.70
logFunction · 0.70
createTipFunction · 0.70
handleCloseTaskWinFunction · 0.70
readingFunction · 0.70

Tested by

no test coverage detected