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 265lutab · Jul 20, 2016 at 11:18 PM · iosaudioplayermusic

Set audio session to media in IOS.

I'm trying to make an app that plays music and I want to to continue playing when the phone is set to silent or if the phone is put to sleep. (these may need two separate solutions.) The main important thing is to get it to play sounds while the phone is on silent just link music plays on the iPhone. I think the answer may be something to do with Audio Sessions. I found this article, but couldn't figure out how to make it work. (might be that this technique doesn't work anymore) http://forum.unity3d.com/threads/setting-mediaplayback-audio-session-category.206958/

They said to do something like this AVAudioSession *session = [AVAudioSession sharedInstance];

 NSError *setCategoryError = nil;
 if (![session setCategory:AVAudioSessionCategoryPlayback
          withOptions:AVAudioSessionCategoryOptionMixWithOthers
          error:&setCategoryError]) {
     // handle error
 }

or OSStatus propertySetError = 0; UInt32 allowMixing = true;

 propertySetError = AudioSessionSetProperty (
                        kAudioSessionProperty_OverrideCategoryMixWithOthers,  // 1
                        sizeof (allowMixing),                                 // 2
                        &allowMixing                                          // 3
                    );

Though I wasn't sure where to put this code or what else would need to be done. Thanks for the help

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 265lutab · Jul 20, 2016 at 11:23 PM

One of the problems I'm having right now which I'm hoping this will fix is a bug where I can only hear sound from headphones. I think that the tester might have the game volume all the way down. I'm not sure, but I was hoping that this would fix the problem.

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 LisaDreams · Jul 20, 2016 at 11:33 PM

Hi, just to be clear you want to play sounds even when the user sets the sounds to off? I'm asking, because it seems to me that if the user has their sounds off they wouldn't want to hear any sounds.

If you want to have your sounds continue to play when the lock screen comes on, you can add an audio key in the UIBackgroundModes in the plist that will let the audio continue to play.

Good luck!!

Comment
Add comment · Show 1 · 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 265lutab · Jul 27, 2016 at 08:59 PM 0
Share

When you play music or videos it will make sound even if you have it switched to silent. I did solve the problem. I used the plugin from the post I mentioned. I had not been using it correctly at first, but it's working now.

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

86 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

Related Questions

Designate unity audio as music. Play in background and when phone is on silent. IOS 0 Answers

Music Player 0 Answers

iOS Audio Skipping Tracks 0 Answers

Music drags / lags while loading things 1 Answer

Playing Audio Source with controls (Keys) 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