AudioSource.Play

function Play (delay : UInt64 = 0) : void

Parameters

NameDescription
delay Delay in number of samples, assuming a 44100Hz sample rate (meaning that Play(44100) will delay the playing by exactly 1 sec).

Description

Plays the clip with a certain delay

Note: To obtain sample accuracy with an AudioClip with a different samplerate (than 44.1 khz) you have to do the math yourselves. Delaying an audiosource with an attached AudioClip with samplerate of, say, 32 khz, with 16k samples(.5 sec) is done by Play(22050). ((44100/32000) * 16000 = 22050).

JavaScript
@script RequireComponent(AudioSource)
function Start() {
audio.Play();
// Delay a clip by 1 sec (44100 samples)
audio.Play(44100);
}

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(AudioSource))]
public class example : MonoBehaviour {
void Start() {
audio.Play();
audio.Play(44100);
}
}

import UnityEngine
import System.Collections

[RequireComponent(AudioSource)]
class example(MonoBehaviour):

def Start():
audio.Play()
audio.Play(44100)

See Also: Stop, Pause, clip functions.