GCKUIMediaController Class

GCKUIMediaController Class Reference

Overview

A controller for UI views that are used to control or display the status of media playback on a Cast receiver.

The calling application registers its media-related UI controls with the controller by setting the appropriate properties. The controller then responds to touch events on the controls by issuing the appropriate media commands to the receiver, and updates the controls based on status information and media metadata received from the receiver. The controller automatically enables and disables the UI controls as appropriate for the current session and media player state. It additionally disables all of the controls while a request is in progress.

See GCKUIMediaControllerDelegate for the delegate protocol.

Since
3.0

Inherits NSObject.

Instance Method Summary

(instancetype) - init
 Initializes an instance. More...
 
(void) - bindLabel:toMetadataKey:
 Binds a UILabel to a metadata key. More...
 
(void) - bindLabel:toMetadataKey:withFormatter:
 Binds a UILabel to a metadata key. More...
 
(void) - bindTextView:toMetadataKey:
 Binds a UITextView to a metadata key. More...
 
(void) - bindTextView:toMetadataKey:withFormatter:
 Binds a UITextView to a metadata key. More...
 
(void) - bindImageView:toImageHints:
 Binds a UIImageView to a GCKUIImageHints instance. More...
 
(void) - bindControlView:toRewindForTime:
 Binds a UIControl to rewind playback of the current item by the passed value as seconds. More...
 
(void) - bindControlView:toForwardForTime:
 Binds a UIControl to forward playback of the current item by the passed value as seconds. More...
 
(void) - unbindView:
 Unbinds the specified view. More...
 
(void) - unbindAllViews
 Unbinds all bound views. More...
 
(GCKMediaRepeatMode- cycleRepeatMode
 Changes the repeat mode for the queue to the next mode in the cycle: More...
 
(void) - selectTracks
 A convenience method for displaying the media track selection UI. More...
 
(void) - skipAd
 Sends and monitors the skip ad request. More...
 

Property Summary

id< GCKUIMediaControllerDelegatedelegate
 The delegate for receiving notificatiosn from the GCKUIMediaController. More...
 
GCKSessionsession
 The session that is associated with this controller. More...
 
BOOL mediaLoaded
 Whether there is media currently loaded (or loading) on the receiver. More...
 
BOOL hasCurrentQueueItem
 Whether there is a current item in the queue. More...
 
BOOL hasLoadingQueueItem
 Whether there is an item being preloaded in the queue. More...
 
GCKMediaPlayerState lastKnownPlayerState
 The latest known media player state. More...
 
NSTimeInterval lastKnownStreamPosition
 The latest known media stream position. More...
 
UIButton * playButton
 A "play" button. More...
 
UIButton * pauseButton
 A "pause" button. More...
 
GCKUIMultistateButtonplayPauseToggleButton
 A "play/pause" toggle button. More...
 
GCKUIPlayPauseToggleControllerplayPauseToggleController
 A "play/pause" toggle controller. More...
 
UIButton * stopButton
 A "stop" button. More...
 
UIButton * forward30SecondsButton
 A button for seeking 30 seconds forward in the currently playing media item. More...
 
UIButton * rewind30SecondsButton
 A button for seeking 30 seconds back in the currently playing media item. More...
 
UIButton * pauseQueueButton
 A button for pausing queue playback once the current item finishes playing. More...
 
UIButton * nextButton
 A "next" button. More...
 
UIButton * previousButton
 A "previous" button. More...
 
GCKUIMultistateButtonrepeatModeButton
 A button for cycling through the available queue repeat modes. More...
 
UISlider * streamPositionSlider
 A slider for displaying and changing the current stream position. More...
 
UIProgressView * streamProgressView
 A view for displaying the current stream progress. More...
 
UILabel * streamPositionLabel
 A label for displaying the current stream position, in minutes and seconds. More...
 
UILabel * streamDurationLabel
 A label for displaying the current stream duration, in minutes and seconds. More...
 
UILabel * streamTimeRemainingLabel
 A label for displaying the remaining stream time (the duration minus the position), in minutes and seconds. More...
 
GCKUIStreamPositionControllerstreamPositionController
 A stream posdition controller. More...
 
GCKUIPlaybackRateControllerplaybackRateController
 A stream playback rate controller. More...
 
BOOL displayTimeRemainingAsNegativeValue
 Whether remaining stream time will be displayed as a negative value, for example, "-1:23:45". More...
 
BOOL hideStreamPositionControlsForLiveContent
 Whether stream position controls (including the stream position slider, the stream position label, the stream duration label, and the stream progress view) should be hidden for live content. More...
 
UIButton * tracksButton
 A button for selecting audio tracks and/or closed captions or subtitles. More...
 
UILabel * smartSubtitleLabel
 A label for displaying a subtitle for the currently loaded media. More...
 
UIActivityIndicatorView * mediaLoadingIndicator
 An activity indicator view for indicating that the media is in a loading state. More...
 
UILabel * skipAdLabel
 A label for displaying the amount of time left until the ad can be skipped. More...
 
UIButton * skipAdButton
 A button for skipping the current ad. More...
 

Method Detail

- (instancetype) init

Initializes an instance.

- (void) bindLabel: (UILabel *)  label
toMetadataKey: (NSString *)  key 

Binds a UILabel to a metadata key.

The view will display the current value of the corresponding metadata field.

See GCKMediaMetadata for a list of predefined metadata keys.

Parameters
labelThe UILabel that will display the value.
keyThe metadata key.
- (void) bindLabel: (UILabel *)  label
toMetadataKey: (NSString *)  key
withFormatter: (GCKUIValueFormatter formatter 

Binds a UILabel to a metadata key.

The view will display the current value of the corresponding metadata field.

See GCKMediaMetadata for a list of predefined metadata keys.

Parameters
labelThe UILabel that will display the value.
keyThe metadata key.
formatterA block that will produce the desired string representation of the value.
- (void) bindTextView: (UITextView *)  textView
toMetadataKey: (NSString *)  key 

Binds a UITextView to a metadata key.

The view will display the current value of the corresponding metadata field.

See GCKMediaMetadata for a list of predefined metadata keys.

Parameters
textViewThe UITextView that will display the value.
keyThe metadata key.
- (void) bindTextView: (UITextView *)  textView
toMetadataKey: (NSString *)  key
withFormatter: (GCKUIValueFormatter formatter 

Binds a UITextView to a metadata key.

The view will display the current value of the corresponding metadata field.

See GCKMediaMetadata for a list of predefined metadata keys.

Parameters
textViewThe UITextView that will display the value.
keyThe metadata key.
formatterA block that will produce the desired string representation of the value.
- (void) bindImageView: (UIImageView *)  imageView
toImageHints: (GCKUIImageHints *)  imageHints 

Binds a UIImageView to a GCKUIImageHints instance.

The currently installed GCKUIImagePicker will be used to select an image from the metadata for the view.

Parameters
imageViewThe UIImageView that will display the selected image.
imageHintsThe image hints.
- (void) bindControlView: (UIControl *)  control
toRewindForTime: (NSTimeInterval)  rewindSeconds 

Binds a UIControl to rewind playback of the current item by the passed value as seconds.

The view will be updated based on GCKCastSession state, the remote playback state and whether it is a livestream. A target is also added to the UIControl to capture UIControlEventTouchUpInside event. Do not add target of this type on the UIControl. To capture the event use the GCKUIMediaControllerDelegate methods instead.

Parameters
controlThe UI element that the user interacts with. Typically this would be an instance of UIButton.
rewindSecondsThe number of seconds to rewind the media.
- (void) bindControlView: (UIControl *)  control
toForwardForTime: (NSTimeInterval)  forwardSeconds 

Binds a UIControl to forward playback of the current item by the passed value as seconds.

The view will be updated based on GCKCastSession state, the remote playback state and whether it is a livestream. A target is also added to the UIControl to capture UIControlEventTouchUpInside event. Do not add target of this type on the UIControl. To capture the event use the GCKUIMediaControllerDelegate methods instead.

Parameters
controlThe UI element that the user interacts with. Typically this would be an instance of UIButton.
forwardSecondsThe number of seconds to skip the media.
- (void) unbindView: (UIView *)  view

Unbinds the specified view.

Parameters
viewThe view to unbind.
- (void) unbindAllViews

Unbinds all bound views.

- (GCKMediaRepeatMode) cycleRepeatMode

Changes the repeat mode for the queue to the next mode in the cycle:

GCKMediaRepeatModeOffGCKMediaRepeatModeAllGCKMediaRepeatModeSingleGCKMediaRepeatModeAllAndShuffle

Returns
The new repeat mode.
- (void) selectTracks

A convenience method for displaying the media track selection UI.

- (void) skipAd

Sends and monitors the skip ad request.

Since
4.3

Property Detail

- (id<GCKUIMediaControllerDelegate>) delegate
readwritenonatomicweak

The delegate for receiving notificatiosn from the GCKUIMediaController.

- (GCKSession*) session
readnonatomicstrong

The session that is associated with this controller.

- (BOOL) mediaLoaded
readnonatomicassign

Whether there is media currently loaded (or loading) on the receiver.

If no Cast session is active, this will be NO.

- (BOOL) hasCurrentQueueItem
readnonatomicassign

Whether there is a current item in the queue.

- (BOOL) hasLoadingQueueItem
readnonatomicassign

Whether there is an item being preloaded in the queue.

- (GCKMediaPlayerState) lastKnownPlayerState
readnonatomicassign

The latest known media player state.

If no Cast session is active, this will be player state just before the last session ended. If there was no prior session, this will be GCKMediaPlayerStateUnknown.

- (NSTimeInterval) lastKnownStreamPosition
readnonatomicassign

The latest known media stream position.

If no Cast session is active, this will be the stream position of the media just before the last session ended. If there was no prior session, this will be kGCKInvalidTimeInterval.

- (UIButton*) playButton
readwritenonatomicweak

A "play" button.

When the button is tapped, playback of the currently loaded media is started or resumed on the receiver. The button will be disabled if playback is already in progress, or if there is no media currently loaded, or if there is no Cast session currently active.

- (UIButton*) pauseButton
readwritenonatomicweak

A "pause" button.

When the button is tapped, playback of the currently loaded media is paused on the receiver. The button will be disabled if the currently loaded media does not support pausing, or if playback is not currently in progress, or if there is no media currently loaded, or if there is no Cast session currently active.

- (GCKUIMultistateButton*) playPauseToggleButton
readwritenonatomicweak

A "play/pause" toggle button.

The caller should set appropriate icons for the button's GCKUIButtonStatePlay, GCKUIButtonStatePlayLive, and GCKUIButtonStatePause button states, namely, a "pause" icon for the play state, a "stop" icon for the play-live state, and a "play" icon for the pause state. The button state is automatically updated to reflect the current playback state on the receiver. When the button is tapped, playback of the currently loaded media is paused or resumed on the receiver. The button will be disabled if the currently loaded media does not support pausing, or if playback is not currently in progress or paused, or if there is no media currently loaded, or if there is no Cast session currently active.

- (GCKUIPlayPauseToggleController*) playPauseToggleController
readwritenonatomicstrong

A "play/pause" toggle controller.

Used as a stand-in for a custom, application-supplied play/pause toggle UI. See GCKUIPlayPauseToggleController for details.

Since
3.4
- (UIButton*) stopButton
readwritenonatomicweak

A "stop" button.

When the button is tapped, playback of the currently loaded media is stopped on the receiver. The button will be disabled if there is no media currently loaded, or if there is no Cast session currently active.

- (UIButton*) forward30SecondsButton
readwritenonatomicweak

A button for seeking 30 seconds forward in the currently playing media item.

The button will be disabled if there is no media currently loaded, or if there is no Cast session currently active.

- (UIButton*) rewind30SecondsButton
readwritenonatomicweak

A button for seeking 30 seconds back in the currently playing media item.

The button will be disabled if there is no media currently loaded, or if there is no Cast session currently active.

- (UIButton*) pauseQueueButton
readwritenonatomicweak

A button for pausing queue playback once the current item finishes playing.

- (UIButton*) nextButton
readwritenonatomicweak

A "next" button.

When the button is tapped, playback moves to the next media item in the queue. The button will be disabled if the operation is not supported, or if there is no media currently loaded, or if there is no Cast session currently active.

- (UIButton*) previousButton
readwritenonatomicweak

A "previous" button.

When the button is tapped, playback moves to the previous media item in the queue. The button will be disabled if the operation is not supported, or if there is no media currently loaded, or if there is no Cast session currently active.

- (GCKUIMultistateButton*) repeatModeButton
readwritenonatomicweak

A button for cycling through the available queue repeat modes.

(See GCKMediaRepeatMode.) The caller should set appropriate icons for the button's GCKUIButtonStateRepeatOff, GCKUIButtonStateRepeatSingle, GCKUIButtonStateRepeatAll, and GCKUIButtonStateShuffle button states. The button state is automatically updated to reflect the current queue repeat mode on the receiver. Tapping on the button cycles to the next repeat mode, in the order:

GCKMediaRepeatModeOffGCKMediaRepeatModeAllGCKMediaRepeatModeSingleGCKMediaRepeatModeAllAndShuffle

The button will be disabled if there is no Cast session currently active.

- (UISlider*) streamPositionSlider
readwritenonatomicweak

A slider for displaying and changing the current stream position.

When the slider's value is changed by the user, the stream position of the currently loaded media is updated on the receiver. While playback of media is in progress on the receiver, the slider's value is updated in realtime to reflect the current stream position. The slider will be disabled if the currently loaded media does not support seeking, or if there is no media currently loaded, or if there is no Cast session currently active.

- (UIProgressView*) streamProgressView
readwritenonatomicweak

A view for displaying the current stream progress.

While playback of media is in progress on the receiver, the views's value is updated in realtime to reflect the current stream position. The view will be disabled if the currently loaded media is a live stream, or if there is no media currently loaded, or if there is no Cast session currently active.

- (UILabel*) streamPositionLabel
readwritenonatomicweak

A label for displaying the current stream position, in minutes and seconds.

If there is no media currently loaded, or if there is no Cast session currently active, the label displays a localized form of "--:--".

- (UILabel*) streamDurationLabel
readwritenonatomicweak

A label for displaying the current stream duration, in minutes and seconds.

If the currently loaded media does not have a duration (for example, if it is a live stream), or if there is no media currently loaded, or if there is no Cast session currently active, the label displays a localized form of "--:--".

- (UILabel*) streamTimeRemainingLabel
readwritenonatomicweak

A label for displaying the remaining stream time (the duration minus the position), in minutes and seconds.

If the currently loaded media does not have a duration (for example, if it is a live stream), or if there is no media currently loaded, or if there is no Cast session currently active, the label displays a localized form of "--:--".

- (GCKUIStreamPositionController*) streamPositionController
readwritenonatomicstrong

A stream posdition controller.

Used as a stand-in for a custom, application-supplied stream position and/or seek UI. See GCKUIStreamPositionController for details.

Since
3.4
- (GCKUIPlaybackRateController*) playbackRateController
readwritenonatomicstrong

A stream playback rate controller.

See GCKUIPlaybackRateController for details.

Since
4.0
- (BOOL) displayTimeRemainingAsNegativeValue
readwritenonatomicassign

Whether remaining stream time will be displayed as a negative value, for example, "-1:23:45".

By default this property is set to YES.

- (BOOL) hideStreamPositionControlsForLiveContent
readwritenonatomicassign

Whether stream position controls (including the stream position slider, the stream position label, the stream duration label, and the stream progress view) should be hidden for live content.

The default value is NO.

Since
4.0
- (UIButton*) tracksButton
readwritenonatomicweak

A button for selecting audio tracks and/or closed captions or subtitles.

When the button is tapped, the media tracks selection UI is displayed to the user. The button will be disabled if the currently loaded media does not have any selectable media tracks, or if there is no media currently loaded, or if there is no Cast session currently active.

- (UILabel*) smartSubtitleLabel
readwritenonatomicweak

A label for displaying a subtitle for the currently loaded media.

If there is no subtitle field explicitly set in the metadata, the label will display the most appropriate metadata field based on the media type, for example the studio name for a movie or the artist name for a music track.

- (UIActivityIndicatorView*) mediaLoadingIndicator
readwritenonatomicweak

An activity indicator view for indicating that the media is in a loading state.

- (UILabel*) skipAdLabel
readwritenonatomicweak

A label for displaying the amount of time left until the ad can be skipped.

Since
4.3
- (UIButton*) skipAdButton
readwritenonatomicweak

A button for skipping the current ad.

Since
4.3