iOS video player for trailer. You can customize layout for the control panel. Support PiP and DRM.
https://user-images.githubusercontent.com/1064039/136514197-452bfecd-fe68-465d-9621-781056485286.mov
Icons by Icons8 (https://icons8.com)
Add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter repository URL https://github.com/AbeWang/TrailerPlayer
.
Then import import TrailerPlayer
.
Add a pod entry to your Podfile :
target 'YourApp' do
pod 'TrailerPlayer', '~> 1.4.8'
...
Install pods
$ pod install
And then import import TrailerPlayer
.
Add TrailerPlayer to your Cartfile :
github "AbeWang/TrailerPlayer" ~> 1.4.8
Run carthage update
$ carthage update --use-xcframeworks
Add the TrailerPlayer xcframework to your project. (XCFramework will not require the usage of the carthage copy-frameworks script anymore.)
let playerView = TrailerPlayerView()
let item = TrailerPlayerItem(
url: URL(string: "..."),
thumbnailUrl: URL(string: "..."))
playerView.playbackDelegate = self
playerView.set(item: item)
required public init(url: URL? = nil,
thumbnailUrl: URL? = nil,
thumbnailImage: UIImage? = nil,
autoPlay: Bool = true,
autoReplay: Bool = false,
mute: Bool = true,
isDRMContent: Bool = false)
func trailerPlayer(_ player: TrailerPlayer, didUpdatePlaybackTime time: TimeInterval)
func trailerPlayer(_ player: TrailerPlayer, didChangePlaybackStatus status: TrailerPlayerPlaybackStatus)
func trailerPlayerPlaybackReady(_ player: TrailerPlayer)
func trailerPlayer(_ player: TrailerPlayer, playbackDidFailed error: TrailerPlayerPlaybackError)
let item = TrailerPlayerItem(
url: URL(string: "..."),
thumbnailUrl: URL(string: "..."),
autoPlay: false)
playerView.set(item: item)
playerView.manualPlayButton = ... // your custom button
playerView.enablePictureInPicture = true
let controlPanel: UIView = ... // your custom control panel
playerView.addControlPanel(controlPanel)
let replayPanel: UIView = ... // your custom replay panel
playerView.addReplayPanel(replayPanel)
let playerView = TrailerPlayerView()
playerView.enableDebugView = true
let playerView = TrailerPlayerView()
let item = TrailerPlayerItem(
url: URL(string: "..."),
thumbnailUrl: URL(string: "..."),
isDRMContent: true)
playerView.playbackDelegate = self
playerView.DRMDelegate = self
playerView.set(item: item)
// DRM Delegate
extension ViewController: TrailerPlayerDRMDelegate {
func certUrl(for player: TrailerPlayer) -> URL {
return URL(string: ...) // your certificate url
}
func ckcUrl(for player: TrailerPlayer) -> URL {
return URL(string: ...) // your ckc url
}
}
// CKC(Content Key Context) URL
func ckcUrl(for player: TrailerPlayer) -> URL
// Certificate URL
func certUrl(for player: TrailerPlayer) -> URL
// Optional: content Id for SPC(Server Playback Context) message
func contentId(for player: TrailerPlayer) -> String?
// Optional: HTTP header fields for CKC request
func ckcRequestHeaderFields(for player: TrailerPlayer) -> [(headerField: String, value: String)]?
A more detailed example can be found here https://github.com/AbeWang/TrailerPlayer/tree/main/Example, or open TrailerPlayer.xcodeproj
link |
Stars: 13 |
Last commit: 1 year ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics