Follow

Enable selectively the "Override iPod Music" player option from code

Symptoms

  • We want to allow music from other apps if the user has the music turned off in our game and Unity API does not give access to "Override iPod Music".

Cause

  • "Override iPod Music" is not accessible from code.

Resolution

Using the native API from iOS, you can change the music source application:

<extern "C" {
    #import <AVFoundation/AVFoundation.h>
    #import <AudioToolbox/AudioToolbox.h>
    bool _IsMusicPlaying (){ 
        if ([[AVAudioSession sharedInstance] isOtherAudioPlaying ]){ 
            return true; 
        } 
        return false; 
    }
}

More Information

This article applies to Unity versions 5.0+

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.