aframe icon indicating copy to clipboard operation
aframe copied to clipboard

<a-image> keeps running videos after changing src

Open greggman opened this issue 7 years ago • 5 comments

setting the src to an <a-image> at runtime to a video and then later to an image the image is loaded but the video keeps playing in the background

  • A-Frame Version: 0.8.0
  • Platform / Device: All
  • Reproducible Code Snippet or URL: https://jsfiddle.net/greggman/jLmz2gpz/

greggman avatar Jun 03 '18 18:06 greggman

Hi i tried experimenting with this: as a result i got a branch which:

The video elements are created and cached in src/system/material.js i couldn't grab the reference to whats the source when its being changed - so i've kept them in the shader component + added the necessary logic (pause when changing sources, reload when re-using a cached video).

Should i make it into a PR, or wait for some feedback regarding the branch ?

gftruj avatar Aug 17 '18 20:08 gftruj

My two cents:

If you mean using a video by selector reference, you have to stop the video yourself, when you change the src, a-image should stop using it but does not manipulate it (since it doesn't really own it)

If you mean by src, then since a video element is created to use it, really a-image should stop and discard the video when src changed (assuming there is no other reference to it) which it probably doesn't (and I would consider a bug)

machenmusik avatar Aug 22 '18 02:08 machenmusik

@machenmusik here its the second case, where the <a-entity> creates the <video> element as i mentioned (here). After its creation the reference is being passed to a callback, but the callback function doesn't use it at all.

gftruj avatar Aug 22 '18 06:08 gftruj

The main repo still has this issue. @gftruj ( Hi from years and years in the future) any chance you still have a branch with a working fix? The link is now dead and the fiddles have the same issue when using the most recent aframe version.

pdbeard avatar Feb 08 '22 19:02 pdbeard

@pdbeard I have no clue what happened to the branch, and I'm afraid I'm a bit too busy to re-create it, but I can offer a workaround, which should be working properly if you wait for a video to load before switching (because even if an old one is cached, the new one will be created and play in the background ).

You could also load the videos in threejs, omitting the material system at all.

gftruj avatar Feb 10 '22 23:02 gftruj