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...
Binds a UILabel to a metadata key. More...
Binds a UILabel to a metadata key. More...
Binds a UITextView to a metadata key. More...
Binds a UITextView to a metadata key. More...
Binds a UIImageView to a GCKUIImageHints instance. More...
Binds a UIControl to rewind playback of the current item by the passed value as seconds. More...
Binds a UIControl to forward playback of the current item by the passed value as seconds. More...
(void) 
Unbinds the specified view. More...
(void) 
Unbinds all bound views. More...
Changes the repeat mode for the queue to the next mode in the cycle: More...
(void) 
A convenience method for displaying the media track selection UI. More...
(void) 
Sends and monitors the skip ad request. More...

Property Summary

The delegate for receiving notificatiosn from the GCKUIMediaController . More...
The session that is associated with this controller. More...
BOOL 
Whether there is media currently loaded (or loading) on the receiver. More...
Whether there is a current item in the queue. More...
Whether there is an item being preloaded in the queue. More...
GCKMediaPlayerState 
The latest known media player state. More...
NSTimeInterval 
The latest known media stream position. More...
UIButton * 
A "play" button. More...
UIButton * 
A "pause" button. More...
A "play/pause" toggle button. More...
A "play/pause" toggle controller. More...
UIButton * 
A "stop" button. More...
UIButton * 
A button for seeking 30 seconds forward in the currently playing media item. More...
UIButton * 
A button for seeking 30 seconds back in the currently playing media item. More...
UIButton * 
A button for pausing queue playback once the current item finishes playing. More...
UIButton * 
A "next" button. More...
UIButton * 
A "previous" button. More...
A button for cycling through the available queue repeat modes. More...
UISlider * 
A slider for displaying and changing the current stream position. More...
UIProgressView * 
A view for displaying the current stream progress. More...
UILabel * 
A label for displaying the current stream position, in minutes and seconds. More...
UILabel * 
A label for displaying the current stream duration, in minutes and seconds. More...
A label for displaying the remaining stream time (the duration minus the position), in minutes and seconds. More...
A stream posdition controller. More...
A stream playback rate controller. More...
Whether remaining stream time will be displayed as a negative value, for example, "-1:23:45". More...
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 * 
A button for selecting audio tracks and/or closed captions or subtitles. More...
UILabel * 
A label for displaying a subtitle for the currently loaded media. More...
UIActivityIndicatorView * 
An activity indicator view for indicating that the media is in a loading state. More...
UILabel * 
A label for displaying the amount of time left until the ad can be skipped. More...
UIButton * 
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
label The UILabel that will display the value.
key The 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
label The UILabel that will display the value.
key The metadata key.
formatter A 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
textView The UITextView that will display the value.
key The 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
textView The UITextView that will display the value.
key The metadata key.
formatter A 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
imageView The UIImageView that will display the selected image.
imageHints The 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
control The UI element that the user interacts with. Typically this would be an instance of UIButton .
rewindSeconds The 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
control The UI element that the user interacts with. Typically this would be an instance of UIButton .
forwardSeconds The number of seconds to skip the media.
- (void) unbindView: (UIView *)  view

Unbinds the specified view.

Parameters
view
The 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:

GCKMediaRepeatModeOff GCKMediaRepeatModeAll GCKMediaRepeatModeSingle GCKMediaRepeatModeAllAndShuffle

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
read write nonatomic weak

The delegate for receiving notificatiosn from the GCKUIMediaController .

- ( GCKSession *) session
read nonatomic strong

The session that is associated with this controller.

- (BOOL) mediaLoaded
read nonatomic assign

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

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

- (BOOL) hasCurrentQueueItem
read nonatomic assign

Whether there is a current item in the queue.

- (BOOL) hasLoadingQueueItem
read nonatomic assign

Whether there is an item being preloaded in the queue.

- (GCKMediaPlayerState) lastKnownPlayerState
read nonatomic assign

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
read nonatomic assign

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
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic strong

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
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic weak

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

- (UIButton*) nextButton
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic weak

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:

GCKMediaRepeatModeOff GCKMediaRepeatModeAll GCKMediaRepeatModeSingle GCKMediaRepeatModeAllAndShuffle

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

- (UISlider*) streamPositionSlider
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic strong

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
read write nonatomic strong

A stream playback rate controller.

See GCKUIPlaybackRateController for details.

Since
4.0
- (BOOL) displayTimeRemainingAsNegativeValue
read write nonatomic assign

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
read write nonatomic assign

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
read write nonatomic weak

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
read write nonatomic weak

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
read write nonatomic weak

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

- (UILabel*) skipAdLabel
read write nonatomic weak

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

Since
4.3
- (UIButton*) skipAdButton
read write nonatomic weak

A button for skipping the current ad.

Since
4.3
Create a Mobile Website
View Site in Mobile | Classic
Share by: