Skip to main content

AudioPlayer

Namespace: MonineEngine.Audio

A component that plays an AudioClip on demand, with the attached as the source position.

public class AudioPlayer : MonineEngine.Core.Component

Inheritance Object → Component → AudioPlayer
Attributes NullableContextAttribute, NullableAttribute

Properties

Clip

The AudioClip for the player to play.

public AudioClip Clip { get; set; }

Property Value

AudioClip

Instance

The AudioInstance of the clip for playing the audio.

public AudioInstance Instance { get; }

Property Value

AudioInstance

Volume

The volume of the player. Defaults to 1, ranges from 0 to 1.

public float Volume { get; set; }

Property Value

Single

Pitch

The pitch of the player. Defaults to 0, ranges from -1 to 1.

public float Pitch { get; set; }

Property Value

Single

Pan

The pan of the player. Defaults to 0, ranges from -1 to 1.

public float Pan { get; set; }

Property Value

Single

Loop

Whether the player loops upon finishing clip playback.

public bool Loop { get; set; }

Property Value

Boolean

Enabled

public bool Enabled { get; set; }

Property Value

Boolean

Entity

public Entity Entity { get; internal set; }

Property Value

Entity

Parent

public Entity Parent { get; }

Property Value

Entity

Transform

public Transform Transform { get; }

Property Value

Transform

Camera

public Camera2D Camera { get; }

Property Value

Camera2D

Constructors

AudioPlayer(AudioClip, Boolean, Single, Single, Single, Boolean)

Constructs an AudioPlayer component.

public AudioPlayer(AudioClip clip, bool playOnInit, float volume, float pitch, float pan, bool loop)

Parameters

clip AudioClip
The clip to play.

playOnInit Boolean
Whether the audio should play on initialization, or only plays manually.

volume Single
The volume of the player. Defaults to 1, ranges from 0 to 1.

pitch Single
The pitch of the player. Defaults to 0, ranges from -1 to 1.

pan Single
The pan of the player. Defaults to 0, ranges from -1 to 1.

loop Boolean
Whether the audio should loop.

Methods

Play()

Plays the AudioPlayer.Clip audio.

public void Play()