-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep player alive enough in background to play next content (#228)
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
import Foundation | ||
import MediaPlayer | ||
|
||
// Magic subscription handler to presumably make iOS keep the player alive so we can continuously play audio in the background. | ||
final class RemoteCommandCenter: NSObject { | ||
@objc static func activateRatingCommand() { | ||
MPRemoteCommandCenter.shared().ratingCommand.addTarget(self, action: #selector(Self.doNothing)) | ||
} | ||
|
||
@objc private static func doNothing() -> MPRemoteCommandHandlerStatus { | ||
.success | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters