1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Flutter】iOSでバックグラウンドオーディオがうまく機能しない

Posted at

audioplayers0.20.1 を使ってオーディオをバックグランドで再生しようとすると、iOSでうまく機能しない。
解決策が見つかったので書き残します。

info.plist
<key>UIBackgroundModes</key>
	<array>
		<string>audio</string>
	</array>

info.plistに上記を追加します。

AppDelegate.swift
import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    UIApplication.shared.beginReceivingRemoteControlEvents() //この一行を追加する
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

僕の場合はこれでバックグラウンドで機能しました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?