Multiple targets

Here is my code. With this the Final_Paul,mp4 does not load at all anymore and the Oscar_Wilde_-_Made_with_Clipchamp_1.mp4 opens but freezes on the first frame.

import * as ecs from ‘@8thwall/ecs’

ecs.registerComponent({
name: ‘video_Autoplay’,
schema: {},
schemaDefaults: {},
data: {},
stateMachine: ({world, eid}) => {
ecs
.defineState(‘setup’)
.initial()
.onEvent(world.events.globalId, ‘reality.imageloaded’, () => {
// This state ensures our component is ready to handle imagefound events
// after the reality engine has fully initialized.
ecs.VideoControls.set(world, eid, {
paused: false,
})
})
.listen(world.events.globalId, ‘reality.imagefound’, (e: {detail: {name: string}}) => {
try {
const imageName: string = e.detail.name

      let videoSrc: string | null = null
      if (imageName === 'paulverlainestill.jpg') {
        videoSrc = 'Final_Paul.mp4'
      } else if (imageName === 'Wilde.jpg') {
        videoSrc = 'Oscar_Wilde_-_Made_with_Clipchamp_1.mp4'
      }

      if (videoSrc) {
        ecs.VideoControls.set(world, eid, {
          paused: false,
          src: videoSrc,
        })
      }
    } catch (error) {
      // You may want to handle this error in a way that doesn't use console.error
    }
  })
  .listen(world.events.globalId, 'reality.imagelost', (e) => {
    // Pause when image is lost (optional, keeps position so resume works)
    ecs.VideoControls.set(world, eid, {
      paused: true,
    })
  })

},
})

Have you tried adding assets/ to the start of the src file paths? For example: assets/Final_Paul.mp4. I’d also suggest removing the try/catch block for now and using console.log(imageName) to see exactly what it’s returning.

I made both adjustments and now the audio from one of the video plays without the video and the images don’t trigger any video.

Now that you’ve made the changes, could you please land them and share the project with the support workspace?