Hi,
I have files under sub-folders StreamingAssets folder in WebGL build, the directory and files are detecting and working fine in Editor (WebGL) when we took build and run - the files are not get detected and playing. What is the correct method to have details of directories in a path.
Thanks in advance.
Find sample test script for reference.
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class WebGLTest : MonoBehaviour
{
public RenderHeads.Media.AVProVideo.MediaPlayer videoPlayer;
string path;
string mainPath;
string result;
DirectoryInfo dir;
public Text pathDisplayTxt;
void Start ()
{
mainPath = Path.Combine(Application.streamingAssetsPath, "Main");
if (mainPath.Contains("://") || mainPath.Contains(":///"))
{
//WWW www = new WWW(mainPath);
//yield return www;
//result = www.text;
//dir = new DirectoryInfo(result);
//Debug.Log(result);
StartCoroutine(SendRequest(mainPath));
}
else
{
dir = new DirectoryInfo(mainPath);
if (!dir.Exists)
{
Debug.Log("Directory not available");
pathDisplayTxt.text = "Directory not available : " + dir;
}
else
{
path = Application.streamingAssetsPath + "/Main/test.mp4";
pathDisplayTxt.text = "Directory available : " + path;
videoPlayer.OpenVideoFromFile(RenderHeads.Media.AVProVideo.MediaPlayer.FileLocation.AbsolutePathOrURL, path, true);
}
}
}
private IEnumerator SendRequest(string url)
{
using (UnityWebRequest request = UnityWebRequest.Get(url))
{
yield return request.SendWebRequest();
dir = new DirectoryInfo(request.url);
Debug.Log(request.url);
if (!dir.Exists)
{
Debug.Log("Directory not available");
pathDisplayTxt.text = "Directory not available WebGL : "+ request.url;
}
else
{
path = request.url + "/test.mp4";
pathDisplayTxt.text = "Directory available WebGL : " + path;
videoPlayer.OpenVideoFromFile(RenderHeads.Media.AVProVideo.MediaPlayer.FileLocation.AbsolutePathOrURL, path, true);
}
}
}
}
Regards,
Ben
↧