Results 1 to 4 of 4

Thread: Using HTML 5 to stop a video before complete

  1. #1
    Join Date
    Feb 2009
    Posts
    48
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default Using HTML 5 to stop a video before complete

    Working on an iPad app where I'm calling a video with an HTML5 tag as seen below. The video is set to start upon page load. Question is, I want to have the video stop automatically about 90% of the way through the video. Is there a way using HTML 5 or even Javascript to automatically stop a video at a certain point or after a specific percentage of the video has already played?? Thanks in advance....


    <video name="vid2" id="vid2" style="width:1024px; height:550px" loop poster="images/postervid.png" autoplay="autoplay">
    <source src="videos/testvideo.mp4" preload="auto" />
    </video>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I know that on iPhone, the video will not autoplay. I think iPad is the same, but perhpas not. Have you tested that part out, does it autoplay on iPad?

    If so, you can gain a javascript reference to the tag and perhaps monitor its on progress index as a divisor of its total length. When that's less than or equal to 0.1, 90% will have played and you can issue a stop command. All of these are available in the HTML 5 video javascript and HTML api:

    https://developer.mozilla.org/en/Usi...udio_and_video

    is a good place to start and there are references at the bottom for further exploration. On that page it suggests using the #t= parameter to set the start and end times. That's a completely HTML solution to your question - that is if you know how long the video is. But it might or might not work on the iPad:

    https://developer.mozilla.org/en/Usi...playback_range

    You can also Google:

    html5 video javascript api

    However, not all aspects of the video tag and its javascript api are supported in all browsers or on all platforms. Generally you can Google that as well if you know what feature you want and what browser/platform combo you want to run it on.

    Another approach is to use a plugin like jqplayer:

    http://jqplayer.vebersol.net/

    or jplayer:

    http://jplayer.org/
    Last edited by jscheuer1; 05-28-2012 at 08:46 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2012
    Location
    California
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes, it’s possible to stop video at any particular time through java script into HTML 5. For this, you have to include “var” data type as “var endtime = 90”. After this add if condition as “if (this.currentTime >= endtime)” then “this.pause();” This is simple coding for pause video at anytime.

  4. #4
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by jscheuer1 View Post
    I know that on iPhone, the video will not autoplay. I think iPad is the same, but perhpas not. Have you tested that part out, does it autoplay on iPad?
    If it help, I'm on an iPad now and I can check

Bookmarks

Posting Permissions

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