Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2012
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    html5 video currentFrame playback

    Hi!

    What I need is pretty simple:

    When user clicks on a button, seek to a specific frame in html5 video and keep playing from there.

    But my code here doesn't work. Instead of continuing playback from the new time (currentFrame) it will start from the beginning. How can I jump to a frame in my video and keep playing forward from there?

    Here is my feeble attempt:

    Code:
    <div id="buttons">
    <img class="choice01" src="btn_piano.jpg" onclick="jumpToTime();"/>
    </div><!-- end buttons -->
    
    <video id="videoclip"> <source src="video/testi.mp4"> your browser does not support the video tag</video>
    Code:
    function jumpToTime(){
       document.getElementById("videoclip").currentTime = 160;
       document.getElementById("videoclip").play();
    };

  • #2
    New Coder
    Join Date
    May 2012
    Posts
    30
    Thanks
    9
    Thanked 0 Times in 0 Posts
    How about trying this. Not sure if it will work.
    Code:
    function jumpToTime(){
       document.getElementById("videoclip").currentTime = 160;
       document.getElementById("videoclip").currentTime;
    };
    So what your doing is setting the currentTime property to 160. Then your returning the currentTime property to the video element.

    Actually you may not even need the second line. So if the above doesn't work, try deleting the second line.
    Last edited by FutureWebDev; 05-25-2012 at 10:19 PM.

  • #3
    New Coder
    Join Date
    Apr 2012
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts
    The problem with that is that the playback gets stopped. And if I try to continue playback with

    Code:
    function jumpToTime(){
       document.getElementById("videoclip").currentTime = 160;
       document.getElementById("videoclip").currentTime;
       document.getElementById("videoclip").play();
    };
    then the playback always jumps to the beginning of the video..


  •  

    Posting Permissions

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