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

javascript - Html 5 video stop event - Stack Overflow

programmeradmin1浏览0评论

Im green with JS, bit i would like to implement to my website html 5 video.

video code looks like this

<video id="myvideo" style=width:600px; height:550px controls>
    <source src="video.mp4" type="video/mp4">
    <source src="video.ogg" type="video/ogg">
    Your browser does not support HTML5 video.
</video>

I would like to make video pasue on 15 second and trigger an event Now my event is on button button code

<button onclick="myFunction()">Watch</button>
<script>
    function myFunction() {
        RC_STARTGATE();
    }
</script>  

Edit: Button is temporary solution. I would like to remove button and something like this: Video starts=> after 15 seconds it pauses=> and triggers same event as button did RC_STARTGATE().

Edit 2: Great! now i need to get button removed and start timeout when video starts.

var vid = document.getElementById("myVideo");

function myFunction(){
    vid.play();

    setTimeout(function(){
        vid.pause();
    }, 15000); //

setTimeout(function(){
        RC_STARTGATE();
    }, 15000); //
}

Im green with JS, bit i would like to implement to my website html 5 video.

video code looks like this

<video id="myvideo" style=width:600px; height:550px controls>
    <source src="video.mp4" type="video/mp4">
    <source src="video.ogg" type="video/ogg">
    Your browser does not support HTML5 video.
</video>

I would like to make video pasue on 15 second and trigger an event Now my event is on button button code

<button onclick="myFunction()">Watch</button>
<script>
    function myFunction() {
        RC_STARTGATE();
    }
</script>  

Edit: Button is temporary solution. I would like to remove button and something like this: Video starts=> after 15 seconds it pauses=> and triggers same event as button did RC_STARTGATE().

Edit 2: Great! now i need to get button removed and start timeout when video starts.

var vid = document.getElementById("myVideo");

function myFunction(){
    vid.play();

    setTimeout(function(){
        vid.pause();
    }, 15000); //

setTimeout(function(){
        RC_STARTGATE();
    }, 15000); //
}
Share Improve this question edited Dec 3, 2013 at 15:26 user3061894 asked Dec 3, 2013 at 14:50 user3061894user3061894 231 gold badge1 silver badge3 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 2

When the button is clicked, the video starts playing, and after 15 seconds you want it stopped?

var vid = document.getElementById("myvideo");

function myFunction(){
    vid.play();

    setTimeout(function(){
        vid.pause();
    }, 15000); //15 second timeout in milliseconds
}

EDIT 2

To remove the button, add an id (<button id="mybtn">) so you can reference and remove it like this:

var btn = document.getElementById("mybtn");
btn.parentElement.removeChild(btn);
发布评论

评论列表(0)

  1. 暂无评论