Listen to events (iOS SDK)

Work with events to capture user interactions with the Player and trigger custom actions.


To listen to events triggered by the Player, you need to implement the following delegate protocols: 

  • DMPlayerDelegate 
  • DMVideoDelegate 
  • DMAdDelegate 

Recommended: Pass delegates during Player creation

Pass the delegate protocols in the createPlayer method:

Dailymotion.createPlayer(playerId: "PLAYER_ID",playerDelegate: self, videoDelegate: self, adDelegate: self , completion: { [weak self] (dmPlayer, error) in
      // Create Player Done
})

Alternative: Assign delegates after Player creation

Pass the delegate protocols after Player creation, to the created DMPlayerView instance:

Dailymotion.createPlayer(playerId: "PLAYER_ID", completion: { [weak self] (dmPlayer, error) in
      // Create Player Done
      dmPlayer?.playerDelegate = self
      dmPlayer?.videoDelegate = self
      dmPlayer?.adDelegate = self
})
👍

Best practice

To ensure all events are caught by your delegates, we recommend using the first approach with passing the delegates in the createPlayer() method.

➡️

Learn more

Find all available events in the iOS SDK Reference.