且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

暂停***视频并使用表单显示div

更新时间:2023-10-30 10:49:04

使用下面的代码来暂停和恢复视频,而不是停止并重新开始播放视频

  var iframe = document.getElementsByTagName(iframe)[0] .contentWindow; 

iframe.postMessage('{event:command,func:playVideo,args:}','*');
iframe.postMessage('{event:command,func:pauseVideo,args:}','*');


I have a *** video on my website:

<div id="video">
  <iframe width="560" height="315" src="https://www.***.com/embed/some_video" frameborder="0" allowfullscreen></iframe> 
</div>

after some fixed time, I want to pause it and ask the user a question by overlaying a form over the video:

<h1>how do you like the video so far? </h1>
<div id="question">
  <form> 
    <input type="radio" name="question" value="poor" checked>Poor<br> 
    <input type="radio" name="question" value="good">Good<br> 
    <input type="submit" value="Submit"> 
  </form>
</div>

What would be the javascript code to pause the video after a fixed period of time and what would be the css for displaying the form nicely? Basically I want to mimic the way lectures on coursera.org once looked like.

Use the below code to pause and resume the video on opening and closing the popup instead of stop and starting the video again

var iframe = document.getElementsByTagName("iframe")[0].contentWindow;

iframe.postMessage('{"event":"command","func": "playVideo","args":""}','*');
iframe.postMessage('{"event":"command","func": "pauseVideo","args":""}','*');