最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Video repeat itself in Iframe - Stack Overflow

programmeradmin5浏览0评论

I have a video in an iframe (the video is from my domain) I want the video to repeat after it finishes.

<iframe src="video/video1.mp4" width="100px" height="100px" allowullScreen></iframe>

Please help.

Thanks in advance!

I have a video in an iframe (the video is from my domain) I want the video to repeat after it finishes.

<iframe src="video/video1.mp4" width="100px" height="100px" allowullScreen></iframe>

Please help.

Thanks in advance!

Share Improve this question edited Jul 16, 2015 at 15:18 Daniel Causebrook 4771 gold badge8 silver badges21 bronze badges asked Jul 16, 2015 at 14:20 Saurabh MahajanSaurabh Mahajan 2,9797 gold badges28 silver badges32 bronze badges 8
  • 2 Have you tried anything at all that you want to share with us? Is the content in the iframe from the same domain as you or is it from another website? – Equalsk Commented Jul 16, 2015 at 14:21
  • 1 Questions that consist of 2 lines of text, do not have a question mark and do not contain any code are very bad candidates for an answer. – blex Commented Jul 16, 2015 at 14:24
  • @Equalsk: the video is from same website means from same domain – Saurabh Mahajan Commented Jul 16, 2015 at 14:25
  • Good, at least this should be possible then. Have you tried anything so far? Look at this SO post and figure out how to get the player element from the iframe, then go from there. – Equalsk Commented Jul 16, 2015 at 14:30
  • 1 Could you provide more information? It's nearly impossible to answer this question as it stands, because you give nothing that we can look at and help you with. What is the code are you using? What have you been trying? – Daniel Causebrook Commented Jul 16, 2015 at 14:31
 |  Show 3 more ments

2 Answers 2

Reset to default 3

you provided the following code:

<iframe src="video/video1.mp4" width="100px" height="100px" allowFullScreen></iframe>

in order to let it repeat itself just do the following:

<video style="width: 100px; height: 100px" controls loop>
    <source src="video/video1.mp4" type="video/mp4">
    Your browser does not support playing this Video
</video>

I think it would be better if, instead of using the iframe tag (which is for displaying webpages not content like videos), you use the HTML5 <video> tag. This is better because it allows you to loop the video easily, without js even, and allows much greater control. It also has a better UI.

<video width="320" height="240" loop autoplay>
  <source src="video/video1.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>

That's all you need!

EDIT:

If you want to customise the video there may be other attributes you find useful:

<video ... loop ... > : loops the video.

<video ... autoplay ... > : starts the video automatically.

<video ... controls ... > : adds controls on the bottom of the video so the user can play and pause the video etc.

<video ... muted ... > : mutes the video so no sound is played.

发布评论

评论列表(0)

  1. 暂无评论