Files
engine/docs/en/audio/component.mdx

29 lines
1.4 KiB
Plaintext

---
order: 2
title: Audio Component
type: Audio
label: Audio
---
The Audio Component is a core component in Galacean used to add audio playback functionality to entities. Through the audio component, developers can control the playback, pausing, stopping, and volume adjustment of audio files.
## Adding the Audio Component
Developers can follow these steps to add the audio component to an entity:
1. **Select the Target Entity**: Choose the [Entity](/en/docs/core/entity) where you want to add the audio component.
2. **Access the Inspector Panel**: Navigate to the Inspector panel for the selected entity.
3. **Add the Component**: At the bottom of the Inspector panel, click on "Add Component" and select "AudioSource".
<video src="https://gw.alipayobjects.com/v/huamei_edbbqz/afts/video/JJ5QSKZKhzgAAAAAAAAAAAAADoY9AQFr" autoPlay loop muted />
## Adjusting Volume and Mute
The audio component provides features to adjust the volume and mute the audio. Developers can control these properties either through scripts or directly in the Inspector panel.
<video src="https://gw.alipayobjects.com/v/huamei_edbbqz/afts/video/lDyIRbwv5nAAAAAAAAAAAAAADoY9AQFr" autoPlay loop muted />
## Controlling Playback Timing
The audio component allows developers to precisely control the timing of audio playback. By using scripts, developers can invoke methods to play, pause, and stop audio files as needed.