美文网首页
后台播放音乐

后台播放音乐

作者: 太平洋_cfd2 | 来源:发表于2023-08-06 11:32 被阅读0次

https://developer.aliyun.com/article/364896

1 //后台播放音频设置
2 AVAudioSession *session = [AVAudioSession sharedInstance];
3 [session setActive:YES error:nil];
4 [session setCategory:AVAudioSessionCategoryPlayback error:nil];

https://developer.apple.com/documentation/xcode/configuring-background-execution-modes

### [指定您的应用程序所需的背景模式](https://developer.apple.com/documentation/xcode/configuring-background-execution-modes#Specify-the-background-modes-your-app-requires)

在您的应用程序可以利用一种或多种后台执行模式之前,您需要通过执行以下操作来声明它所需的模式:

1.  在 Xcode 的项目导航器中选择您的项目。

2.  在目标列表中选择应用程序的目标。

3.  单击项目编辑器中的“签名和功能”选项卡。

4.  找到背景模式功能。

5.  使用相应的复选框选择一种或多种后台执行模式。

6.  对于 watchOS 应用程序,从弹出菜单中选择适当的会话类型。有关详细信息,请参阅[使用扩展运行时会话](https://developer.apple.com/documentation/watchkit/using_extended_runtime_sessions)。

相关文章

网友评论

      本文标题:后台播放音乐

      本文链接:https://www.haomeiwen.com/subject/izaipdtx.html