teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

変更

2019/01/21 03:36

投稿

hahum
hahum

スコア65

title CHANGED
File without changes
body CHANGED
@@ -1,2 +1,23 @@
1
1
  他のアプリで音楽を聴きながら自分のアプリでも音楽を同時再生できる方法を探しています。
2
+ > https://qiita.com/kazuman519/items/a3c61dd67193ea8c3933
3
+
4
+ > https://stackoverflow.com/questions/51010390/avaudiosession-setcategory-swift-4-2-ios-12-play-sound-on-silent
5
+
6
+
7
+
8
+ を参考にして以下のようにしたのですが、他のアプリで音楽が鳴ったまま、自分のアプリの音楽を再生しても二つ同時に再生できませんでした。
9
+
10
+
11
+ AppDelegete.swift
12
+ ```swift
13
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2
- やり方がわかる方は教えていただきたいす。
14
+ //バックグラウンド音楽再生
15
+ do {
16
+ try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
17
+ try AVAudioSession.sharedInstance().setActive(true)
18
+ } catch {
19
+ print(error)
20
+ }
21
+ return true
22
+ }
23
+ ```