SharePlayApi
@objc(BMPSharePlayApi)
public class SharePlayApi : NSObject
The Obj-C version of the SharePlay API. It is empty on purpose as SharePlay can only be used from Swift.
-
Describes why the player is currently not able to participate in group playback.
If the list of reasons is non-empty, the player will not react to any changes of group playback state.
Declaration
Swift
var suspensionReasons: [SharePlaySuspension.Reason] { get }
Return Value
List of reasons why the player is currently not able to participate in group playback.
-
Describes whether the player is currently in group playback.
Declaration
Swift
var isInGroupSession: Bool { get }
Return Value
true
when thePlayer
is within a Group Session. -
Describes whether the player is currently suspended and not able to participate in group playback.
Declaration
Swift
var isSuspended: Bool { get }
Return Value
true
when the participant does not react to any changes in group playback. -
Attaches a group session to the player to synchronize playback of media assets across multiple devices.
Call this method to associate the player with a specific
GroupSession
object. When creating a shared movie-watching experience, aGroupSession
provides a communication channel to the devices of other participants in the session.Note
Any active casting session will be stopped when calling this method.
Declaration
Swift
func coordinate<T>(with groupSession: GroupSession<T>) where T : GroupActivity
Parameters
session
The session associated with a shared group activity. When the user engages a group activity, the system creates a
GroupSession
object for that activity. -
Informs the player that its playback object is detached from the group for some reason and should not receive any playback commands from the session.
Use this to tell the player it cannot, or should not, participate in coordinated group playback temporarily. The player will not respond to playback commands coming from the group and it will also not send any commands to the group. To resume in group playback, end a suspension by calling one of the
endSuspension(_:)
methods onSharePlayApi
.Declaration
Swift
func beginSuspension( for suspensionReason: SharePlaySuspension.Reason ) -> SharePlaySuspension
Parameters
suspensionReason
Indicates the reason for the suspension that is shared with other participants. Can be a system-defined reason (see
SharePlaySuspension.Reason
) or a custom string.Return Value
Suspension object to represent a temporary break in participation.
-
Ends the suspension.
If this is the last suspension, the player will adjust timing of the playback to match the group. Also see
endSuspension(_:proposingNewTime:)
for a way to end a suspension and simultaneously proposing a new time to the group.Declaration
Swift
func endSuspension(_ suspension: SharePlaySuspension)
Parameters
suspension
Suspension object returned by
beginSuspension(for: )
. -
Ends the suspension and proposes a new time that everyone should seek to.
If this is the last suspension, the player will propose the new time to the group without changing the groups playback rate. If this is not the last suspension, the time will be ignored.
Declaration
Swift
func endSuspension(_ suspension: SharePlaySuspension, proposingNewTime newTime: TimeInterval)
Parameters
suspension
Suspension object returned by
beginSuspension(for: )
.newTime
Proposed new playback time that everyone should seek to.