Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 artfish · Oct 29, 2014 at 09:44 PM · iosaudiowwwclasswav

Trying to load and play saved .wav from /Documents iOS

Hey everybody. I'm using UniFileBrowser plugin which returns a file and the path name. All I want to do is use this path to load and play a wav file on iOS. I've been working on this for 18hrs straight, googling www class, posting in other forums, etc. I am desperate for help. Can someone please show me the correct way to write this? It's not returning any errors, but it's also not loading and playing the file...

 void OpenFile (string pathToFile) { //OpenFile is apublic funtion of UniFileBrowser
         var fileIndex = pathToFile.LastIndexOf (pathChar);
         message = "You selected file: " + pathToFile.Substring (fileIndex+1, pathToFile.Length-fileIndex-1);
         Fade();
         WWW AudioToLoadPath = new WWW("file://" +pathToFile);
         Camera.main.audio.clip = AudioToLoadPath.audioClip;
         Camera.main.audio.Play();
     }


Once I select the file, it returns the name of the file I selected, so that part is working great. I just need help with the correct syntax or how to actually load and play the .wav using the pathToFile. Thanks all!

Comment
Add comment · Show 1
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
avatar image renezuidhof · Mar 27, 2015 at 03:46 PM 0
Share

What do you pass to 'pathToFile'? I am also trying trying to load a wav in iOS but i can't get it to work.

I am giving the FullName of the FileInfo of the wav-file (something like: /var/mobile/.../file.wav)

It's quite an old thread but i'll give it a try :)

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by artfish · Oct 30, 2014 at 11:52 PM

I was able to achieve this by using the following: using System.IO;

 private WWW musicFile;
 public AudioSource musicPlayer;
 
 And to play it, I use
 
 void OpenFile (string pathToFile) {
 var fileIndex = pathToFile.LastIndexOf (pathChar);
 message = "You selected file: " + pathToFile.Substring (fileIndex+1, pathToFile.Length-fileIndex-1);
 Fade();
 
 musicFile = new WWW("file:///" + pathToFile);
 audio.clip = musicFile.GetAudioClip(false, false);
 
 musicPlayer.audio.Play ();
 
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
avatar image
0

Answer by Ludopathic · Jan 04, 2017 at 04:02 PM

You won't need "file:///" + - if you add this you will end up having the filepath twice over when using UniFileBrowser. You should read the documentation, it's pretty self-explanatory.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why local WWW audio stream not working on iOS? 1 Answer

Speed of WWW 1 Answer

How do I reduce the CPU load spike caused by playing an audio clip? 1 Answer

Generate Chart with Data 0 Answers

Issues with iPad Audio 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