-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Expose DRM APIs (#36) * Support content key session operations Co-authored-by: Emily Dixon <[email protected]> Co-authored-by: AJ Lauer Barinov <[email protected]>
- Loading branch information
1 parent
ffc6b34
commit 83bf223
Showing
24 changed files
with
2,420 additions
and
201 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
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
113 changes: 113 additions & 0 deletions
113
Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/DRMExampleViewController.swift
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,113 @@ | ||
// | ||
// DRMExampleViewController.swift | ||
// MuxPlayerSwiftExample | ||
// | ||
|
||
import AVKit | ||
import UIKit | ||
|
||
import MuxPlayerSwift | ||
|
||
class DRMExampleViewController: UIViewController { | ||
|
||
// MARK: Player View Controller | ||
|
||
lazy var playerViewController = AVPlayerViewController( | ||
playbackID: playbackID, | ||
playbackOptions: PlaybackOptions( | ||
playbackToken: playbackToken, | ||
drmToken: drmToken, | ||
customDomain: customDomain | ||
) | ||
) | ||
|
||
// MARK: Mux Data Monitoring Parameters | ||
|
||
var playerName: String = "MuxPlayerSwift-DRMExample" | ||
|
||
var environmentKey: String? { | ||
ProcessInfo.processInfo.environmentKey | ||
} | ||
|
||
// MARK: Mux Video Playback Parameters | ||
|
||
var playbackID: String { | ||
ProcessInfo.processInfo.playbackID ?? "qxb01i6T202018GFS02vp9RIe01icTcDCjVzQpmaB00CUisJ4" | ||
} | ||
|
||
// TODO: Display error alert if ProcessInfo returns nil | ||
var playbackToken: String { | ||
ProcessInfo.processInfo.playbackToken ?? "" | ||
} | ||
|
||
// TODO: Display error alert if ProcessInfo returns nil | ||
var drmToken: String { | ||
ProcessInfo.processInfo.drmToken ?? "" | ||
} | ||
|
||
// TODO: Display error alert if ProcessInfo returns nil | ||
var customDomain: String? { | ||
ProcessInfo.processInfo.customDomain ?? nil | ||
} | ||
|
||
// MARK: Status Bar Appearance | ||
|
||
override var childForStatusBarStyle: UIViewController? { | ||
playerViewController | ||
} | ||
|
||
// MARK: View Controller Lifecycle | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
view.backgroundColor = .black | ||
|
||
playerViewController.delegate = self | ||
playerViewController.allowsPictureInPicturePlayback = true | ||
playerViewController.canStartPictureInPictureAutomaticallyFromInline = true | ||
|
||
displayPlayerViewController() | ||
} | ||
|
||
// MARK: Player Lifecycle | ||
|
||
func displayPlayerViewController() { | ||
playerViewController.willMove(toParent: self) | ||
addChild(playerViewController) | ||
view.addSubview(playerViewController.view) | ||
playerViewController.didMove(toParent: self) | ||
playerViewController | ||
.view | ||
.translatesAutoresizingMaskIntoConstraints = false | ||
view.addConstraints([ | ||
playerViewController.view.leadingAnchor.constraint( | ||
equalTo: view.leadingAnchor | ||
), | ||
playerViewController.view.trailingAnchor.constraint( | ||
equalTo: view.trailingAnchor | ||
), | ||
playerViewController.view.layoutMarginsGuide.topAnchor.constraint( | ||
equalTo: view.topAnchor | ||
), | ||
playerViewController.view.layoutMarginsGuide.bottomAnchor | ||
.constraint(equalTo: view.bottomAnchor), | ||
]) | ||
} | ||
|
||
func hidePlayerViewController() { | ||
playerViewController.willMove(toParent: nil) | ||
playerViewController.view.removeFromSuperview() | ||
playerViewController.removeFromParent() | ||
} | ||
|
||
} | ||
|
||
extension DRMExampleViewController: AVPlayerViewControllerDelegate{ | ||
func playerViewController( | ||
_ playerViewController: AVPlayerViewController, | ||
restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void | ||
) { | ||
completionHandler(true) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -21,5 +21,9 @@ | |
</array> | ||
</dict> | ||
</dict> | ||
<key>UIBackgroundModes</key> | ||
<array> | ||
<string>audio</string> | ||
</array> | ||
</dict> | ||
</plist> |
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 |
---|---|---|
|
@@ -4,6 +4,10 @@ A collection of helpful utilities for using AVKit and AVFoundation to stream vid | |
|
||
We'd love to hear your feedback, shoot us a note at [email protected] with any feature requests, API feedback, or to tell us about what you'd like to build. | ||
|
||
#### Mux Video DRM Beta | ||
|
||
This SDK supports Mux Video's DRM feature, which is currently in closed beta. If you are interested in using our DRM features, please sign up on our [beta page](https://www.mux.com/beta/drm) | ||
|
||
## Installation | ||
|
||
### Installing in Xcode using Swift Package Manager | ||
|
Oops, something went wrong.