Skip to main content
TeacherDanny
Up and Coming
December 3, 2025
Question

CodeBlockEvents.OnAudioCompleted not working.

  • December 3, 2025
  • 4 replies
  • 80 views

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
Honored Contributor
December 3, 2025

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.

 

GitHub: https://github.com/Gausroth/HorizonWorldsTutorials.git Discord: https://discord.gg/hNyDQwdw4N YouTube: https://www.youtube.com/@GausRothTutorials
SeeingBlue
Honored Contributor
December 4, 2025

I wonder if the source of the audio makes a difference.

Upcoming Events : Performance Pro - UI Unleashed - Building Responsive & Performant Interfaces Thursday June 19th 5:00 PM PT - Register June Programming Calendar
gausroth
Honored Contributor
December 4, 2025

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.

GitHub: https://github.com/Gausroth/HorizonWorldsTutorials.git Discord: https://discord.gg/hNyDQwdw4N YouTube: https://www.youtube.com/@GausRothTutorials
TeacherDanny
Up and Coming
December 8, 2025

'Send Audio Complete' button was the solution. Thanks a lot.