LoginSignup
5
6

More than 3 years have passed since last update.

バックグラウンド処理・再生の優良記事まとめ[Swift]

Last updated at Posted at 2019-08-03

基本

【Swift】mp3をバックグラウンド再生する - しめ鯖日記
→とりあえず形だけでもやりたい人向け
Swift でミュージックを取り込むアプリを作る時のノウハウ 5 つ - Qiita
→バックグラウンドだけでなく音楽ファイルを扱う時のポイントがまとまっている
[Swift] iOSのバックグラウンド処理について - Qiita
→180秒程度の処理であればUIApplication.shared.beginBackgroundTaskとかでうまくやるといけるらしい

アプリの状態の取得

[Swift]アプリのフォアグラウンドに特定の処理を行う。 | RE:ENGINES

【Swift4】アプリがバックグラウンド状態かアクティブ状態か調べる方法【Objective-C】 | ニートに憧れるプログラム日記
→これでいけますよという話

if (UIApplication.shared.applicationState == .active) {
    print("Active");
} else if (UIApplication.shared.applicationState == .inactive)  {
    print("Inactive");
} else if (UIApplication.shared.applicationState == .background)  {
    print("Background");
}

【Swift4】アプリがバックグラウンド状態かアクティブ状態か調べる方法【Objective-C】 | ニートに憧れるプログラム日記

Rx

swift4でRxSwiftを使用して、ViewControllerからアプリのバックグラウンド、復帰のイベントを取得する - Qiita

UserNotifications

【Swift】この時期だから見直すiOS10の新機能 UserNotificationsとNotification Content ExtensionとNotification Service Extension - Qiita
iOS 10 User Notifications Framework実装まとめ - Qiita
[iOS] ローカル通知について | DevelopersIO
[iOS 10] User Notifications framework! フォアグラウンド時も通知バナー表示 | DevelopersIO

MPRemoteCommand

[iOS][Swift]リモートコマンドイベントに対応する – nackpan Blog
MPRemoteCommandCenterでオーディオファイル再生時のロック画面とコントロールセンターでの操作に対応する - Qiita

[iOS]電話がかかってきたとき、ヘッドホンジャックが抜かれたときの対応 – nackpan Blog
Swiftで中断した後に音声を再開する方法 - コードログ
→割り込み時の処理について

iOS7から画面ロック中の音楽再生/停止ボタンのイベントはUIEventSubtypeRemoteControlTogglePlayPauseではありません - Qiita
ios – MPRemoteCommandCenterの一時停止/再生ボタンが切り替わらない - コードログ
ios – MPRemoteCommandCenterを使用するとPlay / Pauseコールバックが呼び出されない - コードログ
→ありがちなエラー系。MPRemoteCommandが標準機能みたいな感じなので一部だけエラー起こされると意外に難しい、、、(この辺の記事理解できれば中身もきちっとわかったことになるのかな)

5
6
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
5
6