Play music as long as button is pressed

I want to play a music only for as long as the mouse-button is pressed.

I tried :

using UnityEngine;
using System.Collections;

public class MagicSpell : MonoBehaviour {
    public AudioClip spell;
    // Use this for initialization
    void Start () {
  
    }
  
    // Update is called once per frame
    void Update () {
        if (Input.GetButton("Fire1"))
            audio.PlayOneShot(spell);
        //else spell=null;
    }
}

The problem is if the clip is 5 sec long, and I release my mouse button after just, say - 2 sec, still the entire clip is played for the remaining 3 seconds even though I’ve released the mouse button. I don’t want the music to complete itself and play for the remaining 3 seconds…so basically pause the music right when I release the mouse-button…Please suggest a solution…

Input.GetButtonDown and Input.GetButtonUp are what you want to use. Play the clip upon your “Down” call, and stop the clip upon your “Up” call.