0

On my website, I'd like to be able to stop the video loading. Can I do it with jquery? What're my options?

The need is that my website has many videos, when a user with a limited internet connection wanna see a one-hour video then decides that he wants quit the video page (ajax only is performed), the video continues its loading anyway, so if does this with two or three videos his browser will freeze to death. So unless he refreshes the page, the video loading goes on til it's done.

Given that my web's based on apache2, symfony2/php5, projekktor/jquery

smarber
  • 4,829
  • 7
  • 37
  • 78
  • What are you using to play your videos? Youtube, JWPlayer, Brightcove? Normally these players provide a JavaScript API that you can talk to that controls the video – Carlton May 07 '15 at 10:12
  • Oh I'm using projekktor http://www.projekktor.com/ – smarber May 07 '15 at 10:19
  • Sometimes you're able to specify whether you want the video to autoplay, you might want to turn autoplay off – Carlton May 07 '15 at 10:19
  • Yes I know that I can do that with `projekktor`, however this is not what my clients need to be done – smarber May 07 '15 at 10:26

3 Answers3

1

Check this answer - HTML5 Video: Force abort of buffering

Apparently removing the value of the src attribute will cause the video to stop loading/buffering

The OP also suggested stopping the video first to prevent any errors in the Browser console

Community
  • 1
  • 1
Carlton
  • 5,533
  • 4
  • 54
  • 73
  • The only thing that I think may stop *loading* the video is to destroy the player element, and reinsert it at a certain cue point? – Carlton May 07 '15 at 10:29
  • 1
    This post may help http://stackoverflow.com/questions/4071872/html5-video-force-abort-of-buffering, I believe altering the src of the element will cause it to stop loading? – Carlton May 07 '15 at 10:32
  • Actually I've tried to remove the the HTML tag ` – smarber May 07 '15 at 10:36
  • you were right, removing the `src` content will cause it to stop loading/buffering, but I had to stop the player before if I don't won't to see a javascript error into my console. Thx a lot, you should add an answer so that I accept it :) – smarber May 07 '15 at 10:56
0

One way would be to split the page into multiple single video pages. It still doesn't solve the problem completely but at least user's resources are used in to a smaller extent.

Another idea that I've had is to set the source of the video to an empty string when the user stops the video. As far as I've read online it frees up the space and leaves the video blank. There should also be a button to set the source to the original path should the user want to play the video once again.

The second idea provokes minor issues such as being unable to continue the video from the moment the user stopped it but I recon it's still better than taking up user's connection to load it.

Voreny
  • 765
  • 6
  • 13
0

Why don't you use the API to play&pause the video: API

player.setPlayPause():Boolean   

Sets the player to pause if its playing or vis versa.

Ore one of these:

player.setPlay():Boolean

Sets the player to play. If its already playing no changes apply.

player.setPause():Boolean

Sets the player to pause . If its already paused no changes apply.

player.setStop():Boolean

Sets the player to stop . Will cause the playback component to stop immediately and displays the current item´s poster image. Furthermore the start-button shows up.

Marcus Rommel
  • 1,266
  • 1
  • 12
  • 17
  • None of the API méthod of projekktors can get the video **loading** to stop – smarber May 07 '15 at 10:34
  • Then use player.reset() or player.selfDestruct() . or just change the autoplay option. Shouldn't this prevent it from preloading? – Marcus Rommel May 07 '15 at 10:37
  • I'm not trying to prevent preloading, I'm trying to stop video buffering/loading after the user quits it. Sorry if my post title is misleading – smarber May 07 '15 at 10:43
  • I think the only way to do this through the api would be to destroy the instance and re-initiate it. – Marcus Rommel May 07 '15 at 11:13