AudioSource.isPlaying

Switch to Manual
public bool isPlaying;

Description

Returns whether the AudioSource is currently playing a clip (Read Only).

AudioSource.isPlaying returns true if the AudioSource is playing any clip. This includes if you use PlayOneShot() or if you play a video or timeline track through the AudioSource.

Note: AudioSource.isPlaying returns false when AudioSource.Pause() is called. If you use AudioSource.Play() back again, it returns true.

Note: If you use AudioSource.PlayDelayed to play your clip, AudioSource.isPlaying returns true during the delay.

// When the audio component has stopped playing, play otherClip.
// Remember to assign an AudioClip in the Inspector.

using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { public AudioClip otherClip; AudioSource audioSource;

void Start() { audioSource = GetComponent<AudioSource>(); }

void Update() { if (!audioSource.isPlaying) { audioSource.clip = otherClip; audioSource.Play(); } } }

Did you find this page useful? Please give it a rating: