AmpChromecastManager

open class AmpChromecastManager : NSObject, PlayerEventObserver, GCKDeviceScannerListener, GCKDeviceManagerDelegate, GCKMediaControlChannelDelegate

Class in charge of managing Chromecast device scanning, connections and casts.

  • AmpPlayer’s UI manager.

    Declaration

    Swift

    open let ampPlayer: AmpPlayer
  • Chromecast’s receiver app ID.

    Declaration

    Swift

    open let receiverAppID: String
  • Chromecast’s device scanner.

    Declaration

    Swift

    open var deviceScanner: GCKDeviceScanner
  • Chromecast’s device manager.

    Declaration

    Swift

    open var deviceManager: GCKDeviceManager?
  • Chromecast’s media control channel.

    Declaration

    Swift

    open var mediaControlChannel: GCKMediaControlChannel?
  • The current state of the video playback

    Declaration

    Swift

    open var playbackState: PlaybackState
  • The current time of the video being cast.

    Declaration

    Swift

    open var currentTime: Double
  • Initializes a new AmpChromecastManager with the parameters provided.

    Declaration

    Swift

    public init(ampPlayer: AmpPlayer, receiverAppID: String = kGCKMediaDefaultReceiverApplicationID, autoScan: Bool = true, autoCast: Bool = true)

    Parameters

    ampPlayer

    The player linked to this AmpChromecastManager instance.

    receiverAppID

    The Chromecast receiver app ID. Default: kGCKMediaDefaultReceiverApplicationID

    autoScan

    Whether this instance should start scanning for devices right away. Default: true

    autoCast

    Whether this instance should cast the video using the default behavior automatically. Default: true

    Return Value

    A configured instance of an AmpChromecastManager.

  • The devices that the chromecast has scanned so far.

    Declaration

    Swift

    open func devices() -> [GCKDevice]

    Return Value

    The list of devices that the chromecast has scanned so far, an empty list otherwise.

  • Start scanning for devices.

    Declaration

    Swift

    open func scan()
  • Shows the menu for choosing scanned Chromecast devices.

    Declaration

    Swift

    open func showDevicesMenu(alertTitle: String = "Connect to Device", noDevicesTitle: String = "No Devices Found", cancelTitle: String = "Cancel")
  • Attempts to connect to a chromecast device.

    Declaration

    Swift

    open func connect(toDevice device: GCKDevice)

    Parameters

    device

    The device you intend to connect to.

  • Attempts to disconnect to the current connected device.

    Declaration

    Swift

    open func disconnect()
  • Sets the active tracks. Request will fail if there is no current media status.

    Declaration

    Swift

    open func activateTracks(_ tracks: [Int])
  • Unsets the active tracks.

    Declaration

    Swift

    open func deactivateTracks()
  • Attempts to cast a video to the connected Chromecast device.

    Declaration

    Swift

    open func castVideo(_ autoplay: Bool = true,
                                metadata: GCKMediaMetadata? = nil,
                                mediaTracks: [AnyObject] = [],
                                textTrackStyle: GCKMediaTextTrackStyle? = nil,
                                customData: [AnyObject]? = nil) -> Bool

    Parameters

    autoplay

    Whether playback should start immediately. Default: true

    metadata

    Metadata related to the playback. Default: nil

    mediaTracks

    Media tracks related to the playback. Default: []

    textTrackStyle

    Text style tracks related to the playback. Default: nil

    customData

    The custom application-specific data. Default: nil

    Return Value

    Whether the media was loaded or not

  • Play or resume the video and sets the respective playback state.

    Declaration

    Swift

    open func play()
  • Pause the video and sets the respective playback state.

    Declaration

    Swift

    open func pause()
  • Seek video.

    Declaration

    Swift

    open func seek(toSeconds time: Double)

    Parameters

    time

    Time to seek in seconds.

  • Set volum of Chromecast device.

    Declaration

    Swift

    open func setVolume(_ volume: Float)

    Parameters

    volume

    The new volume, in the range [0.0, 1.0]. Out of range values will be silently clipped.

  • Registers an observer.

    Declaration

    Swift

    open func registerObserver(_ observer: AmpChromecastObserver) -> Int

    Parameters

    observer

    The observer to be registered.

    Return Value

    The id of the registered observer.

  • Removes a registered observer.

    Declaration

    Swift

    open func removeObserver(_ id: Int)

    Parameters

    id

    The id of the observer to be removed.

  • Stops the entire module.

    Declaration

    Swift

    open func stop()