Pause audio clip and resume the audio clip

How to pause the audio clip and continue the pasued audio clip?

You need to access the Audio Source and pause it.

i.e:

using UnityEngine;

public class Pause_Audio : MonoBehaviour {

    public AudioSource aSource;

    void Start()
    {
   
    }
    Void Update()
    {
        if(Input.GetKeyDown(KeyCode.P))
        {
            aSource.Pause();
        }
        else if(Input.GetKeyDown(KeyCode.P) && !aSource.isPlaying)
        {
            aSource.Play();
        }
    }
}
1 Like