JWCastController

@objcMembers
public class JWCastController : NSObject

Controller that enables casting using a JWPlayer instance.

  • Delegate that will receive casting-related callbacks.

    Declaration

    Swift

    public weak var delegate: JWCastDelegate? { get set }
  • The casting device that is currently connected.

    Declaration

    Swift

    public var connectedDevice: JWCastingDevice? { get }
  • List of casting devices that are currently online.

    Note

    startDiscovery must be called in order to start updating the available devices.

    Declaration

    Swift

    public var availableDevices: [JWCastingDevice] { get }
  • Initialize the JWCastController with a player. If the Google Cast SDK is not linked, it will return nil.

    Declaration

    Swift

    public init?(player: JWPlayer)

    Parameters

    player

    JWPlayer object currently in use.

  • Starts the discovery process. After calling this method, the availableDevices array will be updated with any devices that are discovered.

    Note

    Before calling startDiscovery(), make sure you have initialized the GCKCastContext, typically in your AppDelegate. GCKCastContext is a global singleton object that is part of the Cast framework. It coordinates all of the framework’s activities. For more information, see Initialize the Cast context.

    Declaration

    Swift

    public func startDiscovery()
  • Stops the discovery process. After calling this method, device discovery will stop, and the availableDevices array not be updated.

    Declaration

    Swift

    public func stopDiscovery()
  • Connects to the casting device.

    Note

    To get an array of all available devices, used availableDevices.

    Declaration

    Swift

    public func connectToDevice(_ device: JWCastingDevice)

    Parameters

    device

    The casting device to connect to.

  • Disconnects from the currently connected casting device.

    Declaration

    Swift

    public func disconnect()
  • Casts the current item that is being used by the JWPlayer instance.

    Note

    You must be connected to a casting device in order to cast.

    Declaration

    Swift

    public func cast()
  • Stops the casting and resumes the JWPlayer instance.

    Note

    Calling this method does not disconnect from the casting device.

    Declaration

    Swift

    public func stopCasting()