Get Playback Position
What it does: Returns the current playback position of the given sound in seconds and returns an AudioError (see Possible Errors), showing wheter and how getting the current playback position of the sound failed.
- DOES_NOT_EXIST
- MISSING_WRAPPER
- MISSING_SOURCE
- MISSING_CLIP
How to call it:
SoundName
is thename
we have given the sound we want to get the playback position ofTime
is thevariable
the playback position in seconds will be copied intofloat.NaN
on failureChild
is theChildType
that we want to call this method on
string soundName = "SoundName";
float time = float.NaN;
ChildType child = ChildType.PARENT;
AudioError error = am.GetPlaybackPosition(soundName, out time, child);
if (error != AudioError.OK) {
Debug.Log("Getting playBackPosition of the sound called: " + soundName + " failed with error id: " + error);
}
else {
Debug.Log("Getting playBackPosition of the sound called: " + soundName + " with the position being: " + time.ToString("0.00") + " succesfull");
}
Alternatively you can call the methods with less paramters as some of them have default arguments.
string soundName = "SoundName";
float time = float.NaN;
AudioError error = am.GetPlaybackPosition(soundName, out time);
if (error != AudioError.OK) {
Debug.Log("Getting playBackPosition of the sound called: " + soundName + " failed with error id: " + error);
}
else {
Debug.Log("Getting playBackPosition of the sound called: " + soundName + " with the position being: " + time.ToString("0.00") + " succesfull");
}
When to use it: When you want to get the time the current amount of time the sound has been playing already.