Download Audioclip from youtube URL with WWW

Hello, im currently trying to make a script where players can select their own music.

I made a script that works with .ogg links, but i cant seem to make youtube links works since unity does not recognize the audio source in the link.


@script RequireComponent (AudioSource)

var url = "";

var native_width : float = 1920;
var native_height : float = 1080;

function OnMouseDown () {
var www : WWW = new WWW (url);  // start a download of the given URL
audio.clip = www.GetAudioClip(false, true); // 2D, streaming

function Update() {

   if (!audio.isPlaying && audio.clip.isReadyToPlay)

    	Debug.Log("waiting - isplaying : " + audio.isPlaying + " isreadyToPlay : " + audio.clip.isReadyToPlay);


function OnGUI () {

	var rx : float = Screen.width / native_width;
    var ry : float = Screen.height / native_height;
    GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (rx, ry, 1)); 
	url = GUI.TextField (Rect (1300, 700, 300, 70), url, 100);


Error Code:

Unable to determine the audio type from the URL (R3hab & Deorro - Flashlight - YouTube) . Please specify the type.
UnityEngine.WWW:GetAudioClip(Boolean, Boolean)

Im pretty sure i just can’t download the Audiofile from a youtube link it self, but i need a direct link to the video instead. Does anyone know how to do that? Without making the players having to lots of stuff themselves, such as downloading then converting etc?

Im very new to WWW and usually just mess around with GUI and Physics.
If there is any more information you need dont hesitate asking me.

Thanks in advance ^^

I am Use Mp3xd online youtube converter website for using Download Any video on youtube. because it’s fast, secure and easy to use.

All those who are fond of music must have heard about because a number of users rely on this astonishing downloader to save their favorite media file.
Follow this Step:-

  1. Just paste your favorite youtube video URL.
  2. Select Format.
  3. Click the download button.