Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by ben06feb · Jan 09, 2019 at 12:08 PM · webplayerwebglsystem.iofilesystem

System.IO - DirectoryInfo not working in WebGL

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Marco-Trivellato · Feb 21, 2019 at 05:53 PM

You can't access the local file system when running in the browser.

Once UnityWebRequest succeeds, you can get the downloaded asset using the downloadHandler. However, if you need to play a video you may want to consider the VideoPlayer API.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

176 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Uncaught RuntimeError: Memory access out of bounds,Uncaught RuntimeError: Memory access out of bounds. 0 Answers

WebPlayer and WebGL wont work 1 Answer

WebGl on google sites? 0 Answers

Still Receiving Gzip Compression Message after Nginx Configuration 1 Answer

Web Game Database 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges