求助unity在安卓平台上的streamingAssets文件读取
想瑠 2016-06-13 02:10:06 已经有一个功能load(“xxx.MP4”)能播放streamingAssets文件夹里指定的视频
我想试一下www加载streamingAssets文件中具体一个MP4然后返回文件名 后续功能会需要
我这样写了个代码
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
public class GetName : MonoBehaviour {
public MediaPlayerCtrl scrMedia;
public bool m_bFinish = false;
private string _result;
// Use this for initialization
void Start () {
StartCoroutine(GetFileName());
}
// Update is called once per frame
void Update () {
}
IEnumerator GetFileName(){
string url = Application.streamingAssetsPath +"/fengjing.mp4";
WWW www = new WWW(url);
yield return www;
_result = www.text;
}
void OnGUI() {
if( GUI.Button(new Rect(50,50,100,100),"Load"))
{
scrMedia.Load(_result);
m_bFinish = false;
}
}
}
然而播放不成功 如果是直接 scrMedia.Load(“fengjing.mp4”);的话倒是能播放
应该是_result并不是返回的文件名吧 应该怎么修改呢 先谢谢了