Search code examples
videoaframe

A-frame <a-video> autoplay


With A-Frame I'm not able to get autoplay="false" or loop="false" to work. The video plays automatically and loops anyway. I also tried the 'repeat' attribute from documentation, but that did not seem to work either: https://aframe.io/docs/0.4.0/primitives/a-video.html#attributes_repeat

How to get a video to not autoplay or loop in A-Frame?

<a-video position="0 3 -5" autoplay="false" loop="false"
         src="./assets2/video/Space-Cats-Magic-Fly.mp4"
         material="shader:flat; side:double; transparent:true;"
         geometry="mergeTo:null; primitive:circle; radius:3.0;">
</a-video>

Solution

  • https://aframe.io/docs/0.4.0/guides/#using-the-asset-management-system

    Create a separate video element without autoplay/loop and reference it using an ID selector:

    <a-scene>
      <a-assets>
        <video id="vid" src="a.mp4"></video>
      </a-assets>
    
      <a-video src="#vid"></a-video>
    </a-scene>