Version: 5.4 beta (switch to 5.3)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Obsolete
Use AudioClip.loadState instead to get more detailed information about the loading process.

AudioClip.isReadyToPlay

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var isReadyToPlay: bool;
public bool isReadyToPlay;

Description

Returns true if the AudioClip is ready to play (read-only).

This applies to any type of AudioClip, regardless whether they load all data at startup, dynamically in the background or streamed from disk or web. In the first case the property will be true when the whole clip has been loaded, while in the streamed cases it will be true when enough data is buffered to start playback.

	var source: AudioSource;
	
	function Start () {
		var www : WWW = new WWW("www.example.com");
		source = GetComponent.<AudioSource>();
		source.clip = www.audioClip;
	}

function Update () { if(!source.isPlaying && source.clip.isReadyToPlay) source.Play(); }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public AudioSource source; void Start() { WWW www = new WWW("www.example.com"); source = GetComponent<AudioSource>(); source.clip = www.audioClip; } void Update() { if (!source.isPlaying && source.clip.isReadyToPlay) source.Play(); } }