GCKCastContext Class

GCKCastContext Class Reference

Overview

A class containing global objects and state for the framework.

The context must be initialized early in the application's lifecycle via a call to setSharedInstanceWithOptions: (GCKCastContext).

Since
3.0

Inherits NSObject.

Instance Method Summary

(void) - registerDeviceProvider:
 Registers a device provider, which adds support for a new type of (non-Cast) device. More...
 
(void) - unregisterDeviceProviderForCategory:
 Unregisters the device provider for a given device category. More...
 
(void) - setLaunchCredentialsData:
 Sets the credentials data of the current user. More...
 
(void) - presentCastDialog
 Displays the Cast dialog. More...
 
(GCKUICastContainerViewController *) - createCastContainerControllerForViewController:
 Constructs a GCKUICastContainerViewController that embeds the given view controller. More...
 
(GCKUIMiniMediaControlsViewController *) - createMiniMediaControlsViewController
 Constructs a GCKUIMiniMediaControlsViewController. More...
 
(BOOL) - presentCastInstructionsViewControllerOnce
 If it has not been shown before, presents a fullscreen modal view controller that calls attention to the Cast button and displays some brief instructional text about its use. More...
 
(BOOL) - presentCastInstructionsViewControllerOnceWithCastButton:
 If it has not been shown before, presents a fullscreen modal view controller that calls attention to the Cast button, whose view is passed in, and displays some brief instructional text about its use. More...
 
(void) - clearCastInstructionsShownFlag
 Clears the persistent flag that tracks whether the Cast instructions modal view controller has been shown. More...
 
(void) - presentDefaultExpandedMediaControls
 Displays the default Cast expanded media controls. More...
 

Class Method Summary

(void) + setSharedInstanceWithOptions:
 Sets the shared instance, supplying a Cast options object. More...
 
(BOOL) + setSharedInstanceWithOptions:error:
 Sets the shared instance, supplying a Cast options object. More...
 
(instancetype) + sharedInstance
 Returns the singleton instance. More...
 
(BOOL) + isSharedInstanceInitialized
 Tests if the singleton instance has been initialized yet. More...
 

Public Attributes

NSString *const kGCKNotificationKeyCastState
 The userInfo key for the new Cast state in a Cast state change notification. More...
 
NSString *const kGCKCastStateDidChangeNotification
 The name of the notification that will be published when the Cast state changes. More...
 
NSString *const kGCKExpandedMediaControlsTriggeredNotification
 The name of the notification that will be published when the expanded media controls should be presented to users. More...
 
NSString *const kGCKUICastDialogWillShowNotification
 The name of the notification that will be published when the Cast dialog is about to be shown. More...
 
NSString *const kGCKUICastDialogDidHideNotification
 The name of the notification that will be published when the Cast dialog has been dismissed. More...
 

Property Summary

GCKCastState castState
 The current casting state for the application. More...
 
GCKDiscoveryManagerdiscoveryManager
 The discovery manager. More...
 
GCKSessionManagersessionManager
 The session manager. More...
 
id< GCKUIImageCacheimageCache
 The image cache implementation that will be used by the framework to fetch images that are referenced in media metadata. More...
 
id< GCKUIImagePickerimagePicker
 The image picker implementation that will be used to select an image for a specific purpose. More...
 
BOOL useDefaultExpandedMediaControls
 Configures the behavior of the framework when there's a user action that should result in the presentation of the expanded controls. More...
 
GCKUIExpandedMediaControlsViewControllerdefaultExpandedMediaControlsViewController
 The instance of the default Cast expanded media controls view controller. More...
 

Method Detail

+ (void) setSharedInstanceWithOptions: (GCKCastOptions *)  options

Sets the shared instance, supplying a Cast options object.

If the shared instance is already initialized, an exception will be thrown.

Parameters
optionsThe Cast options.
+ (BOOL) setSharedInstanceWithOptions: (GCKCastOptions *)  options
error: (GCKError *_Nullable *_Nullable)  error 

Sets the shared instance, supplying a Cast options object.

The call will fail if the context is already initialized. This method must be called on the main thread.

Parameters
optionsThe Cast options.
errorA pointer at which to store the error in case of a failure.
Returns
YES on success, NO on failure.
Since
4.0
+ (instancetype) sharedInstance

Returns the singleton instance.

If a shared instance has not yet been initialized, an exception will be thrown.

+ (BOOL) isSharedInstanceInitialized

Tests if the singleton instance has been initialized yet.

Since
3.5.4
- (void) registerDeviceProvider: (GCKDeviceProvider *)  deviceProvider

Registers a device provider, which adds support for a new type of (non-Cast) device.

Parameters
deviceProviderAn instance of a GCKDeviceProvider subclass for managing the devices.
- (void) unregisterDeviceProviderForCategory: (NSString *)  category

Unregisters the device provider for a given device category.

Parameters
categoryA string that uniquely identifies the type of device.
- (void) setLaunchCredentialsData: (GCKCredentialsData *_Nullable)  credentialsData

Sets the credentials data of the current user.

You should call this API with the current user information before starting a cast session and whenever user account is changed.

The credentials data will be embedded in the launch request. If it is to launch an Android TV app, the app can use the credentials data to determine if the app supports this specific user. If not, the cast app will be launched instead.

If an Android TV app is launched, the credential data will be passed to the app, within the launch intent. The app can use this data to personalize the user experience.

Parameters
credentialsDataAn instance of GCKCredentialsData. May be nil.
- (void) presentCastDialog

Displays the Cast dialog.

Provided by category GCKCastContext(UI).

- (GCKUICastContainerViewController *) createCastContainerControllerForViewController: (UIViewController *)  viewController

Constructs a GCKUICastContainerViewController that embeds the given view controller.

Provided by category GCKCastContext(UI).

- (GCKUIMiniMediaControlsViewController *) createMiniMediaControlsViewController

Constructs a GCKUIMiniMediaControlsViewController.

Provided by category GCKCastContext(UI).

- (BOOL) presentCastInstructionsViewControllerOnce

If it has not been shown before, presents a fullscreen modal view controller that calls attention to the Cast button and displays some brief instructional text about its use.

Returns
YES if the view controller was shown, NO if it was not shown because it had already been shown before. Since version 4.1, NO is also returned if the Cast Button was not found.
Deprecated:
Use presentCastInstructionsViewControllerOnceWithCastButton:.

Provided by category GCKCastContext(UI).

- (BOOL) presentCastInstructionsViewControllerOnceWithCastButton: (GCKUICastButton *)  castButton

If it has not been shown before, presents a fullscreen modal view controller that calls attention to the Cast button, whose view is passed in, and displays some brief instructional text about its use.

Returns
YES if the view controller was shown, NO if it was not shown because it had already been shown before. NO is also returned if the Cast Button was not found.
Since
4.1

Provided by category GCKCastContext(UI).

- (void) clearCastInstructionsShownFlag

Clears the persistent flag that tracks whether the Cast instructions modal view controller has been shown.

Provided by category GCKCastContext(UI).

- (void) presentDefaultExpandedMediaControls

Displays the default Cast expanded media controls.

Provided by category GCKCastContext(UI).

Member Data Documentation

- (NSString* const) kGCKNotificationKeyCastState

The userInfo key for the new Cast state in a Cast state change notification.

- (NSString* const) kGCKCastStateDidChangeNotification

The name of the notification that will be published when the Cast state changes.

- (NSString* const) kGCKExpandedMediaControlsTriggeredNotification

The name of the notification that will be published when the expanded media controls should be presented to users.

- (NSString* const) kGCKUICastDialogWillShowNotification

The name of the notification that will be published when the Cast dialog is about to be shown.

Since
3.4
- (NSString* const) kGCKUICastDialogDidHideNotification

The name of the notification that will be published when the Cast dialog has been dismissed.

Since
3.4

Property Detail

- (GCKCastState) castState
readnonatomicassign

The current casting state for the application.

Changes to this property can be monitored with KVO or by listening for kGCKCastStateDidChangeNotification notifications.

- (GCKDiscoveryManager*) discoveryManager
readnonatomicstrong

The discovery manager.

This object handles the discovery of receiver devices.

- (GCKSessionManager*) sessionManager
readnonatomicstrong

The session manager.

This object manages the interaction with receiver devices.

- (id<GCKUIImageCache>) imageCache
readwritenonatomicstrong

The image cache implementation that will be used by the framework to fetch images that are referenced in media metadata.

A default implementation will be used if one is not provided by the application. May be set to nil to reinstate the default image cache.

Provided by category GCKCastContext(UI).

- (id<GCKUIImagePicker>) imagePicker
readwritenonatomicstrong

The image picker implementation that will be used to select an image for a specific purpose.

A default implementation will be used if one is not provided by the application. May be set to nil to reinstate the default image picker.

Provided by category GCKCastContext(UI).

- (BOOL) useDefaultExpandedMediaControls
readwritenonatomicassign

Configures the behavior of the framework when there's a user action that should result in the presentation of the expanded controls.

If YES, the framework will present the default expaned controls view. If NO, the framework will just trigger a GCKCastContext::kGCKExpandedMediaControlsTriggeredNotification.

Provided by category GCKCastContext(UI).

- (GCKUIExpandedMediaControlsViewController*) defaultExpandedMediaControlsViewController
readnonatomicstrong

The instance of the default Cast expanded media controls view controller.

Provided by category GCKCastContext(UI).