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 /
avatar image
0
Question by IRALTA · Nov 21, 2017 at 12:03 PM · androidaudiofacebookstreamingassets

Can't get path to StreamingAssets in Android

Hello,

I'm trying to use Facebook SDK 360 for ambisonic sound. At Mac it works fine, but when I try to play at Android devices doesn't works. Now I know that the problem is the path for load the audio. Facebook 360 SDK use StreamingAssets to save there a .tbe archive, and Unity has little problems to load StreamingAssets as PC/Mac. The default code is this

 private string resolvePath(string path, PathType type)
         {
             if (type == PathType.STREAMING_ASSETS)
             {
                 string streamingAssetsPath = Path.Combine(Application.streamingAssetsPath, path);
                 if (streamingAssetsPath.Contains("apk!") && Application.platform == RuntimePlatform.Android)
                 {
                     return "asset:///" + Path.GetFileName(streamingAssetsPath);
                 }
                 return streamingAssetsPath;
             }
             
             return path;
         }

I try to use WWW as Unity say and I made this another code:

  private string resolvePath(string path, PathType type)
             {
                 Debug.Log("WWWWWQW!");
                     string streamingAssetsPath = Path.Combine(Application.streamingAssetsPath, path);
     
                    if(!Application.isEditor)
                    {
                        
                        string dbPath;
     
     
     
                       WWW reader = new WWW(streamingAssetsPath);
                        while (!reader.isDone) 
                        {
                            
                        }
     
                        string realPath = Application.persistentDataPath + path;
                        System.IO.File.WriteAllBytes(realPath,reader.bytes);
     
                        dbPath = realPath;
                        streamingAssetsPath = dbPath;
                    }
     
                     return streamingAssetsPath;
     
             }

It worked once, but now the app doesn't load nothing T.T

Does anyone have any suggestion to make it work?

Thanks in advance :)

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 IRALTA · Nov 23, 2017 at 06:07 PM

This is my code now and still not working private void resolvePath(string path) {

             if (!Application.isEditor)
             {
                 StartCoroutine(CargarAudio(path));
             }
             else
             {
                 pathStreamingAssets = Path.Combine(Application.streamingAssetsPath, path);
                 //text = GameObject.Find("welcome").GetComponent<Text>();
                 //text.text = pathStreamingAssets;
             }
         
                 
         }
         IEnumerator CargarAudio(string path)
         {
             string streamingAssetsPath = Path.Combine(Application.streamingAssetsPath, path);
             if(!Application.isEditor)
                {
                   string dbPath;
                   WWW reader = new WWW(streamingAssetsPath);
                    while (!reader.isDone) 
                    {
                      yield return null;
                    }
 
                    string realPath = Application.persistentDataPath + path;
                    System.IO.File.WriteAllBytes(realPath,reader.bytes);
 
                    dbPath = realPath;
                    streamingAssetsPath = dbPath;
                    pathStreamingAssets= streamingAssetsPath;
                    text = GameObject.Find("welcome").GetComponent<Text>();
                 text.text = pathStreamingAssets;
                 //The 
                 ///storage/emulated/0/Android/data/com.Iralta.SecuritasVideo80/filesVoiceDirections.tbe
                }
         }

The device display this (/storage/emulated/0/Android/data/com.Iralta.SecuritasVideo80/filesVoiceDirections.tbe) url to get the audio (VoiceDirections.tbe is the name of the audio), but still not working. It's seems like its something wrong when get files and the name of audio without / or the name of the folder

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

168 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

Related Questions

Assets/scripts/fbLogin.cs(60,52): error CS1501: No overload for method `API' takes `3' arguments 1 Answer

Which android debug hash key to add in Facebook Application ? 0 Answers

Problems with audio (audio popping / crackling) and Wi-Fi 4 Answers

Audio playing at inappropriate times on Android due to OnApplicationPause 1 Answer

When exporting android project to an eclipse project the music doesn't export 0 Answers


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