I am tring to stream musics from a file directory. But it is not working.
function Start () {
var www : WWW = new WWW("E:
m2.ogg");
audio.clip = www.GetAudioClip(true,true);
}
function Update () {
if(!audio.isPlaying && audio.clip.isReadyToPlay)
audio.Play();
}
Effect on AudioSource component
Debug log of GetAudioClip().name is not loging any output
Hi i solved problem on PC but i need to run this on Android platform too.
my code is this and its not working on android.
using UnityEngine;
using System.IO;
using System.Collections;
public class Filebrowser : MonoBehaviour {
FileInfo[] info;
DirectoryInfo dir;
string aaa = "/mnt/sdcard/music";
// Use this for initialization
void Start () {
dir = new DirectoryInfo(aaa);
info = dir.GetFiles("*.mp3");
foreach (FileInfo f in info) ;
}
// Update is called once per frame
void Update () {
}
public int k = 0;
void OnGUI()
{
GUI.Button(new Rect(10,60,400,30),Application.dataPath);
for (int i=0;i<=info.Length-1; i++)
{
if (GUI.Button(new Rect(10,10+40*i,200,30),info*.Name))*
_ WWW mus = new WWW(“file:///” + info*.FullName);*_
* audio.clip = mus.GetAudioClip(true,true);*
_ Debug.Log( “file://” + info*.FullName);
audio.Play();
k=i;
}*_
* }*
* GUI.TextField(new Rect(100,400,600,40), “file:///” + info[k].FullName);*
* }*
}
Thanks
Better format
using UnityEngine;
using System.IO;
using System.Collections;
public class Filebrowser : MonoBehaviour {
private FileInfo[] info;
private DirectoryInfo dir;
private string aaa = "/mnt/sdcard/music";
void Start ()
{
dir = new DirectoryInfo(aaa);
info = dir.GetFiles("*.mp3");
foreach (FileInfo f in info) ;
}
public int k = 0;
void OnGUI()
{
GUI.Button(new Rect(10,60,400,30),Application.dataPath);
for (int i=0;i<=info.Length-1; i++)
{
if (GUI.Button(new Rect(10,10+40*i,200,30),info*.Name))*
_ WWW mus = new WWW(“file:///” + info*.FullName);_
_ audio.clip = mus.GetAudioClip(true,true);_
_ Debug.Log( “file://” + info.FullName);
audio.Play();
k=i;
}
}*_
* GUI.TextField(new Rect(100,400,600,40), “file:///” + info[k].FullName);*
* }*
}