Skip to content

Commit

Permalink
iphone app allow background music to continue to play (#713)
Browse files Browse the repository at this point in the history
* iphone app allow background music to continue to play

Issue description:
https://stackoverflow.com/questions/14122363/iphone-app-allow-background-music-to-continue-to-play

On older ios nme app can cancel background music when you open it, on new ios it will stop music when you close app.

* Update UIStageView.mm

---------

Co-authored-by: Thomas Uster <[email protected]>
  • Loading branch information
codeservice and thomasuster authored Sep 27, 2023
1 parent 9d12e22 commit 34c6673
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion templates/ios/UIStageView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import <QuartzCore/CADisplayLink.h>
#import <CoreMotion/CMMotionManager.h>
#import <MediaPlayer/MediaPlayer.h>

#import <AVFoundation/AVFoundation.h>

::if NME_METAL::
#define NME_METAL
Expand Down Expand Up @@ -2266,6 +2266,10 @@ @implementation NMEAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
APP_LOG(@"application start");

//audio from other apps mixes with your audio
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];

UIWindow *win = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window = win;
[window makeKeyAndVisible];
Expand Down

0 comments on commit 34c6673

Please sign in to comment.