jquery-pjax icon indicating copy to clipboard operation
jquery-pjax copied to clipboard

HTML5 video reload

Open theamnesic opened this issue 11 years ago • 10 comments

Hi!

When you come from a page that contains a <video>, the browser still reloads the video several times.

An example here : http://gmorisseau.com/pjax/ Here the files : http://cl.ly/01172i2N2Y0T

Thanks for your help!

theamnesic avatar Nov 06 '14 17:11 theamnesic

A temporary fix (CoffeeScript) :

$(document).on "pjax:beforeSend", ->
 $("video").each ->
   @pause()
   @src = ""
   @load = ""

theamnesic avatar Nov 13 '14 14:11 theamnesic

You're right; good catch. Looks like nasty browser bug (I tested in Chrome; not sure about other browsers). We should try to apply some workaround like you suggested, but restore the src when the <video> tags get restored from pjax cache on popstate.

mislav avatar Nov 30 '14 08:11 mislav

Hi Mislav,

Apparently Firefox reloads several times too. It's invisible in the Network panel, but you can hear the sound of the video play again and again : http://gmorisseau.com/pjax/ .

You're right about the src, I just realize my temporary fix doesn't work with the prev/next button ...

theamnesic avatar Nov 30 '14 19:11 theamnesic

Hello

Problem is here (content is cloned to be put in cache) : https://github.com/defunkt/jquery-pjax/blob/master/jquery.pjax.js#L367

Tried without this line and it works. I didn't take time to dig more but it should be possible to store only strings in cache and create nodes when needed ?

klevron avatar Dec 06 '14 18:12 klevron

Juste tried (strings in cache), it works. Is there any reason to keep jquery objects in cache ?

Strings in cache will consume less memory :-) but it could be a bc break for pjax:beforeReplace.

klevron avatar Dec 06 '14 22:12 klevron

I'm having the same issue. I've tried the strings in cache approach, and it doesn't work with Firefox. However, using a CDN stops the reloading, for some odd reason.

Edit: The strings in cache approach works. I was just having some weird issues with Firebug.

I'd love it if there was an official solution though.

BrokenChair avatar Feb 24 '15 11:02 BrokenChair

Hi guys,

I've just updated my test page with the latest version of pjax and the bug is back.

In the past, this fix worked for me but I can't find a solution with the new version of pjax.

Any idea?

Thanks!

theamnesic avatar Jun 01 '16 12:06 theamnesic

I've just hit the same problem. Previously temp hack fix works. In standard JS + jQuery:

$pjaxContainer.on('pjax:beforeSend', () => {
  $('video').each(function() {
    this.pause();
    this.src = '';
    this.load = '';
  });
});

or instead of setting these attributes just removing videos works too

$(this).remove();

chodorowicz avatar Jun 16 '16 12:06 chodorowicz

Hello! Would you tell me when this bug is resolved?

venzersiz avatar Feb 27 '18 02:02 venzersiz

Any further thoughts? Or is it time to move on?

richgcook avatar Feb 15 '19 17:02 richgcook