- Home /
Play and Pause button
Hello its been an hour and still i cannot figure out the right code for playing and pausing the audio source in a single button click. Here is my Code
ButtonAction.GetComponent().onClick.AddListener(delegate
{
if (soundTarget.isPlaying)
{
soundTarget.Pause();
}
else if(!soundTarget.isPlaying)
{
soundTarget.Play();
playSound("sounds/English");
}
});
note : by default it is not playing because if i play it by default it will just loop around. it is somehow working but i need to click the button multiple times before it play or pause help me.
Have you tried to put a simple Debug.Log(soundTarget.isPlaying)
to check if the action is triggered?
Your answer
Follow this Question
Related Questions
What does the numSamples parameter in GetOutputData actually mean? 1 Answer
AudioClips automatically fastforwarding at beginning of scenes 0 Answers
audiosources not playing after object destruction 0 Answers
Add animation for volume of BGM audiosource 0 Answers
Audio Clip duration not getting updated 0 Answers