切换播放和暂停YouTube视频并使用javascript添加进度栏

问题描述

播放按钮问题解决后,我在视频中添加了暂停按钮,如下所示:

<div class="col-md-6">
        <div class='py-3' ><?php echo $course_name?></div>
        <div style='pointer-events: none' id="video-placeholder" class='w-100'>
            <iframe width="560" height="315" id="player"  src="<?php echo $course_video?>" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
        </div>
        
        <div id='controls' class='row w-100 justify-content-center mt-3'>
            <i id="play" class="material-icons">play_arrow</i>
            <i id="pause" class="material-icons">pause</i>
            <input type="range" id="progress-bar" value="0">
        </div>
    </div>

JavaScript是:

$('#play').on('click',function(e) {
            e.preventDefault();
            $("#player")[0].src += "?autoplay=1";
        }),$('#pause').on('click',function(e) {
            e.preventDefault();
            $("#player")[0].src += "?autoplay=0";
        })

当我单击播放图标时,它正在播放视频,然后当我单击暂停图标时,它正在暂停视频,但是当我返回单击播放图标时,它不播放,如何使其播放并暂停所有我点击的时间?以及如何激活进度栏?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...