Custom fullscreen implementation (iOS SDK)
Custom fullscreen implementation for advanced needs.
For more control over how fullscreen is handled, you can create your own fullscreen experience starting from SDK version 1.1.0. following the below steps:
- Implement
DMPlayerDelegateandplayerWillPresentFullscreenViewControllerfunction where you have to returnnilinstead of aUIViewController. This will disable the out-of-the-box feature. - Implement
playerDidRequestFullscreenandplayerDidExitFullScreendelegates to handle "enter fullscreen" and "exit fullscreen" modes. - Call
notifyFullscreenChanged()after each fullscreen state change to allow the Player to update accordingly.
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Dailymotion.createPlayer(playerId: "PlayerID", playerDelegate: self) { playerView, error in
}
}
}
extension ViewController: DMPlayerDelegate {
func playerWillPresentFullscreenViewController(_ player: DMPlayerView) -> UIViewController? {
return nil
}
func playerDidRequestFullscreen(_ player: DMPlayerView) {
// Move the player in fullscreen State
// Call notifyFullscreenChanged() the player will update his state
player.notifyFullscreenChanged()
}
func playerDidExitFullScreen(_ player: DMPlayerView) {
// Move the player in initial State
// Call notifyFullscreenChanged() the player will update his state
player.notifyFullscreenChanged()
}
}
Important:Always call
player.notifyFullscreenChanged()after updating the Player state to eitherinlineorfullscreen. Not calling it might affect monetisation and certain Player functionalities.
Updated 24 days ago
