UI Slider to Match Audio Clip Duration

OK there does not seem to be a easy method of getting the New UI sliders to match audio clip duration. How can I code a script in C# that will do the trick?
The answer down below is a good start but NOT a solution??
I have tried some variations on the script below but so far no luck getting a slider to maths the duration of the audio file. I’m a little disappointed that this type of thing is not built in.??

This should point you in the right direction.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class AudioSlider : MonoBehaviour {

    public Slider audioSlider;

	// Use this for initialization
	void Start () {
        audioSlider.direction = Slider.Direction.LeftToRight;
        audioSlider.minValue = 0;
        audioSlider.maxValue = audio.clip.length;
        audio.Play();
	}
	
	// Update is called once per frame
	void Update () {
        audioSlider.value = audio.time;
	}
}