unity打包ios真机测试应用切换后背景音乐的消失问题

初始打开关闭背景音乐添加代码:
unity打包好ios,导入xcode打开找到main.mm文件添加代码

	//添加头文件
	#include 
	//添加代码片段
 	NSError *setCategoryErr = nil;
    NSError *activationErr  = nil;
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:&setCategoryErr];
    [[AVAudioSession sharedInstance] setActive:YES error:&activationErr];

unity打包ios真机测试应用切换后背景音乐的消失问题_第1张图片

unity打包后切入切出的时候背景音乐的处理在xcode找到UnityAppController.mm添加代码

	//添加头文件
	#include 
	//添加代码片段
 	NSError *setCategoryErr = nil;
    NSError *activationErr  = nil;
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategorySoloAmbient  error:&setCategoryErr];
    [[AVAudioSession sharedInstance] setActive:YES error:&activationErr];

unity打包ios真机测试应用切换后背景音乐的消失问题_第2张图片
AVAudioSession 类的实例及类型

纪录一下,更新于2020.05.11。

你可能感兴趣的:(unity打包ios真机测试应用切换后背景音乐的消失问题)