www.webdeveloper.com
Results 1 to 4 of 4

Thread: pause video when a button clicked

  1. #1
    Join Date
    Apr 2013
    Posts
    44

    Question pause video when a button clicked

    hi,

    my website is:http://http://www.terranartworks.com...sv1/index.html

    the video begins automatically.i want to pause the video,when user clicks one of three buttons on bottom of page.i use anything slider jquery for this.
    how can i do this?

  2. #2
    Join Date
    Jun 2008
    Posts
    106
    Code:
    function pause() {
        document.getElementById('video').pause();
    }
    then you will need to call this function when a button is pressed. You could add an 'onclick' attribute to the button if you want.

    Code:
    <a href='foo' onclick='pause()'>bar</a>

  3. #3
    Join Date
    Apr 2013
    Posts
    44
    thank you.i used below code and it worked.

    Code:
    var button1,button2,button3;
    function initializePlayer()
    	{
                    button1=document.getElementById("button1");
    		button2=document.getElementById("button2");
    		button3=document.getElementById("button3");
                    button1.addEventListener("click",buttonClick,false);
    		button2.addEventListener("click",buttonClick,false);
    		button3.addEventListener("click",buttonClick,false);
    }
    window.onload=initializePlayer;
    function buttonClick()
    		{
    			if(!vid.paused){vid.pause();}
    		}

  4. #4
    Join Date
    Jun 2008
    Posts
    106
    You're welcome Glad it worked.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles