已經有一個功能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并不是回傳的檔案名吧 應該怎么修改呢 先謝謝了
uj5u.com熱心網友回復:
直接用可以的方法做,為何非要用WWWW呢uj5u.com熱心網友回復:
我這里只是在測驗 正式用的時候是不知道檔案名的
uj5u.com熱心網友回復:
android下不使用用ndk方式,只能通過www讀該目錄
uj5u.com熱心網友回復:
System.IO.Path.Combine(xxx,yyy )你可以試試這個,這個是將倆個字串合并到一起的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/67509.html
標籤:Unity3D
下一篇:二狗的胡思亂想
