javascript - Html 5 video stop event - Stack Overflow

Im green with JS, bit i would like to implement to my website html 5 video.video code looks like this&l

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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745139588a4613366.html

相关推荐

  • javascript - Html 5 video stop event - Stack Overflow

    Im green with JS, bit i would like to implement to my website html 5 video.video code looks like this&l

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信