Forum Discussion

TeacherDanny's avatar
1 month ago

CodeBlockEvents.OnAudioCompleted not working.

Is anyone else having issues with CodeBlockEvents.OnAudiocompleted not firing? Even if you don't have a solution please let me know if it's just not working for you. It's not even working on scripts that used to work. I'm not sure why. I know I've been doing it right. The following is an example of a script that I attached directly to the audio gizmo. The song plays on world start but does not do the console.log(). 

 

 

import {  Component,  AudioGizmo,  CodeBlockEvents } from 'horizon/core'

class practiceTrack extends Component<typeof practiceTrack> {

  static propsDefinition = {};

  start() {

    this.connectCodeBlockEvent(
        this.entity.as(AudioGizmo),
        CodeBlockEvents.OnAudioCompleted,
        ( ) => {  console.log('Audio completed')  }
    );
    this.entity.as(AudioGizmo).play()
  }
}
Component.register(practiceTrack);

4 Replies

    • gausroth's avatar
      gausroth
      Mentor

      What do you mean? Like a recorder gizmo? I don't think those have the send audio complete on them, do they? I know not all of them do.

  • Make sure Send Audio Complete is on in the properties panel for the audio gizmo. I tested your code and it worked for me so your code is good.