Shareplay for custom video controls playback

Hi

We are trying to implement Group watching feature with the help of Group Activities available in iOS 15 onwards

We can share the session across the user, and the proper content is launched in the Player. Now we need to coordinate the player activity. We are using custom video controls over AVPlayer and it seems by default calling the below line of code does not seems to be work.

player?.playbackCoordinator.coordinateWithSession(session)

Now we are stuck with coordinating player activity.

The example mentions default controls with AVPlayer, but in our case, we have custom video controls on top of AVPlayer.

https://developer.apple.com/videos/play/wwdc2021/10225/

So will the player automatically coordinate with the group session, or do we need to implement AVDelegatingPlaybackCoordinator for the same.

Please help!

Replies

For what it's worth, I am able to get SharePlay to work with a AVPlayer based system (custom controls). The logic is that after we receive the activity, we create our player and during the process of configuring the player, if there is a group session we attach it to the playbackCoordinator. Hope that helps.

    if #available(iOS 15, *) {
      if let session = CoordinationManager.shared.groupSession {
        player.playbackCoordinator.coordinateWithSession(session)
      }
    }
  • Does custom controls, like play, pause and seek automatically coordinate and changes, or do we need to do any specific handling apart from player.playbackCoordinator.coordinateWithSession(session)

  • Yes; their actions are coordinated. If user A and B are in a SharePlay session and user A seeks forward user B will see their video seek forward as well. Your player UI should already be monitoring for changes in player state (play/pause, playback position, buffering, etc.) and update the UI accordingly. But even if you don't, you should still see one user affecting the other users player.

Add a Comment