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 HDX13 · Aug 11, 2017 at 12:48 AM · c#androidaudiosourceaudioclipapk

Music is not playing after build to APK

I have tested my game in the Editor and everything seems to be working fine. But after I build it into APK, the music won't load and the game got stuck on the main game scene. I believe there's something to do with my Main.cs script and some others. Note: I'm trying to load the audio on runtime because I'm using a music selection system.

Main.cs

 public int CurrentBeat = 0;
 public float BPM;
 public bool RespawnNote = true;
 public Scoring ScoreSystem;
 public MusicData MusicData;
 public int Difficulty = 1;
 public int Speed = 4;
 private float FallTime;
 public AudioSource Music;
 private AudioClip music2Play;
 public GameHandler GameData;

 void Awake(){
     try
     {
         #region FromStart
         // preparing objects
         GameData = FindObjectOfType<GameHandler>(); // if this fails, go to catch line
         music2Play = FindObjectOfType<AudioClip>();
         
         // preparing data
         MusicData = GameData.GetCurrentMusic();
         FallTime = 16f / GameData.GameSpeed;
         Difficulty = GameData.Difficulty;
         Speed = GameData.GameSpeed;
         isTest = false;
         LoadAudio();

         // set the clip to the AudioSource
         Music.clip = music2Play;
         #endregion
     }
     catch (System.Exception)
     {
         #region TestTrack
         // this will be a test script
         // so you don't need to start
         // all the way from the beginning
         // PS: I've set a track as default, so
         // no more FileName on MusicData
         isTest = true;
         MusicData = new MusicData() { Title = "TestTrack", Artist = "<unknown/>", 
             BPM = 120, Offset = testOffset, TrackBeats = TestTrackBeats };
         FallTime = 16f / Speed;
         #endregion
     }
     finally
     {
         //these lines will be executed no matter what
         ScoreSystem = FindObjectOfType<Scoring>();
         cache = FindObjectOfType<ObjectPool>();
          // preparing latency
         lateStart = MusicData.Offset > FallTime; 
     }
 }

 void LoadAudio()
 {
     // load the audio file
     // note: ignore extension
     music2Play = Resources.Load<AudioClip>(GameData.RawPath + MusicData.FileNameNoExt);
     music2Play.LoadAudioData();
 }

 IEnumerator Play()
 {
     if (!lateStart)
         yield return new WaitForSeconds(FallTime + MusicData.Offset);

     Music.Play();
 }

I used Start() to call the coroutine Play()

Please, I need a quick solution to this issue. I need to get it finished in a week or two.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Komayo · Aug 11, 2017 at 01:44 AM

Iam not entirely a expert on sound matter, but this behaviour you are getting,

  • Seems a wrong format to play on android. Mobile systems are sometimes very strict and specific to some extensions/plugins types. Same on videos also.

  • Check also a few options of the file, compressions, bitrates, etc... a sound expert may give you a help in that

  • In the worst case, your android system runs out of resources to load the file, or not loading it quick enought to be readable by unity engine

Maybe this helps somehow.

Comment
Add comment · Show 2 · 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 HDX13 · Aug 12, 2017 at 07:07 AM 0
Share

I have tried a small project to load my resources on the fly. And all the audio files are loaded and worked perfectly. Even on AP$$anonymous$$.
$$anonymous$$y audio settings (for this one) are:

  • 320kbps $$anonymous$$P3 file

  • Vorbis compression, 40% quality

  • Preload Audio Data = false

  • Load in Background = true

  • Load Type = Decompress on load

Again, I use Resources.Load<AudioClip>(path); to load the audio.

UPDATE: It's still not working. After implementing a log writer, turns out it's IsolatedStorageException. Android thinks that my resources is inside the AP$$anonymous$$, but there was nothing (I checked the built AP$$anonymous$$, and there was "res" ins$$anonymous$$d of "Resources").

In the given link, the errors were for text files (txt, json, xml). But I believe this could also happen on my audio files too. Or maybe anything that is inside the "Resources" folder.

avatar image Komayo HDX13 · Aug 12, 2017 at 07:23 AM 0
Share

There was a issue a few releases ago, with decompressed audio not working very well. Can you try to change Load Type to Compressed/Not Decompress and test again if it works.

avatar image
0

Answer by MaxQuinonesSantander · Jun 16, 2021 at 06:19 AM

try change build to 64x in other settings =) works for me.

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

401 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Distribute terrain in zones 3 Answers

How can I play audio clips depending on the players movement 0 Answers

Audio playing not in right time when calling from script 1 Answer

I have a shooting script. I have a problem: when firing bursts, my sound of a shot breaks. How to make the sound produced to the end. 0 Answers

Audio/c#/unity Can i control the duration by time ? 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