Class: MPMoviePlayerController

Inherits:
NSObject show all

Overview

A movie player (of type MPMoviePlayerController) manages the playback of a movie from a file or a network stream. Playback occurs in a view owned by the movie player and takes place either fullscreen or inline. You can incorporate a movie player’s view into a view hierarchy owned by your app, or use an MPMoviePlayerViewController object to manage the presentation for you.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- ( (nonatomic, readonly) MPMovieAccessLog ) accessLog (readonly)

A snapshot of the network playback log for the movie player if it is playing a network stream. Can be nil. For information about movie access logs, refer to MPMovieAccessLog Class Reference.

Returns:

- (Object) airPlayVideoActive (readonly)

Indicates whether the movie player is currently playing video via AirPlay. You can query this property after receiving an MPMoviePlayerIsAirPlayVideoActiveDidChangeNotification notification to find out whether the AirPlay video started or stopped.

Returns:

- ( (nonatomic) BOOL ) allowsAirPlay

Specifies whether the movie player allows AirPlay movie playback. A movie player supports wireless movie playback to AirPlay-enabled hardware. By default, this property’s value is YES.To disable AirPlay movie playback, set this property’s value to NO. The movie player then presents a control that allows the user to choose AirPlay-enabled hardware for playback when such hardware is in range.

Returns:

  • ( (nonatomic) BOOL )

- ( (nonatomic, readonly) UIView ) backgroundView (readonly)

A customizable view that is displayed behind the movie content. (read-only) This view provides the backing content, on top of which the movie content is displayed. You can add subviews to the background view if you want to display custom background content.This view is part of the view hierarchy returned by the view property.

Returns:

  • ( (nonatomic, readonly) UIView )

- ( (nonatomic, copy) NSURL ) contentURL

The URL that points to the movie file. If you set this property while a movie is playing, that movie pauses and the new movie begins loading. The new movie starts playing at the beginning.

Returns:

  • ( (nonatomic, copy) NSURL )

- ( (nonatomic) MPMovieControlStyle ) controlStyle

The style of the playback controls. The default value of this property is MPMovieControlStyleDefault. You can change the value of this property to change the style of the controls or to hide the controls altogether. For a list of available control styles, see “MPMovieControlStyle.”

Returns:

  • ( (nonatomic) MPMovieControlStyle )

- ( (nonatomic, readonly) NSTimeInterval ) duration (readonly)

The duration of the movie, measured in seconds. (read-only) If the duration of the movie is not known, the value in this property is 0.0. If the duration is subsequently determined, this property is updated and a MPMovieDurationAvailableNotification notification is posted.

Returns:

  • ( (nonatomic, readonly) NSTimeInterval )

- ( (nonatomic) NSTimeInterval ) endPlaybackTime

The end time (measured in seconds) for playback of the movie. The default value of this property is -1, which indicates the natural end time of the movie. This property is not applicable for streamed content.

Returns:

  • ( (nonatomic) NSTimeInterval )

- ( (nonatomic, readonly) MPMovieErrorLog ) errorLog (readonly)

A snapshot of the playback failure error log for the movie player if it is playing a network stream. Can be nil. For information about movie error logs, refer to MPMovieErrorLog Class Reference.

Returns:

- ( (nonatomic, getter=isFullscreen) BOOL ) fullscreen

A Boolean that indicates whether the movie player is in full-screen mode. The default value of this property is NO. Changing the value of this property causes the movie player to enter or exit full-screen mode immediately. If you want to animate the transition to full-screen mode, use the setFullscreen:animated: method instead.Whenever the movie player enters or exits full-screen mode, it posts appropriate notifications to reflect the change. For example, upon entering full-screen mode, it posts MPMoviePlayerWillEnterFullscreenNotification and MPMoviePlayerDidEnterFullscreenNotification notifications. Upon exiting from full-screen mode, it posts MPMoviePlayerWillExitFullscreenNotification and MPMoviePlayerDidExitFullscreenNotification notifications.The value of this property may also change as a result of the user interacting with the movie player controls.

Returns:

  • ( (nonatomic, getter=isFullscreen) BOOL )

- ( (nonatomic) NSTimeInterval ) initialPlaybackTime

The time, specified in seconds within the video timeline, when playback should start. For progressively downloaded content, playback starts at the closest key frame prior to the provided time. For video-on-demand content, playback starts at the nearest segment boundary to the provided time. For live video streams, the playback start time is measured from the start of the current playlist and is rounded to the nearest segment boundary. The default value of this property is -1, which indicates the natural start time of the movie.

Returns:

  • ( (nonatomic) NSTimeInterval )

- ( (nonatomic, readonly) MPMovieLoadState ) loadState (readonly)

The network load state of the movie player. (read-only) See the “MPMovieLoadState” enumeration for possible values of this property. To be notified of changes to the load state of a movie player, register for the MPMoviePlayerLoadStateDidChangeNotification notification.

Returns:

  • ( (nonatomic, readonly) MPMovieLoadState )

- ( (nonatomic, readonly) MPMovieMediaTypeMask ) movieMediaTypes (readonly)

The types of media available in the movie. (read-only) Movies can contain a combination of audio, video, or a combination of the two. The default value of this property is MPMovieMediaTypeMaskNone. See the “MPMovieMediaTypeMask” enumeration for possible values of this property.

Returns:

  • ( (nonatomic, readonly) MPMovieMediaTypeMask )

- ( (nonatomic) MPMovieSourceType ) movieSourceType

The playback type of the movie. The default value of this property is MPMovieSourceTypeUnknown. This property provides a clue to the playback system as to how it should download and buffer the movie content. If you know the source type of the movie, setting the value of this property before playback begins can improve the load times for the movie content. If you do not set the source type explicitly before playback, the movie player controller must gather this information, which might delay playback.

Returns:

  • ( (nonatomic) MPMovieSourceType )

- ( (nonatomic, readonly) CGSize ) naturalSize (readonly)

The width and height of the movie frame. (read-only) This property reports the clean aperture of the video in square pixels. Thus, the reported dimensions take into account anamorphic content and aperture modes.It is possible for the natural size of a movie to change during playback. This typically happens when the bit-rate of streaming content changes or when playback toggles between audio-only and a combination of audio and video.

Returns:

  • ( (nonatomic, readonly) CGSize )

- ( (nonatomic, readonly) NSTimeInterval ) playableDuration (readonly)

The amount of currently playable content. (read-only) For progressively downloaded network content, this property reflects the amount of content that can be played now.

Returns:

  • ( (nonatomic, readonly) NSTimeInterval )

- ( (nonatomic, readonly) MPMoviePlaybackState ) playbackState (readonly)

The current playback state of the movie player. (read-only) The playback state is affected by programmatic calls to play, pause, or stop the movie player. It can also be affected by user interactions or by the network, in cases where streaming content cannot be buffered fast enough.See the “MPMoviePlaybackState” enumeration for possible values of this property. To be notified of changes to the playback state of a movie player, register for the MPMoviePlayerPlaybackStateDidChangeNotification notification.

Returns:

  • ( (nonatomic, readonly) MPMoviePlaybackState )

- (Boolean) readyForDisplay (readonly)

A Boolean that indicates whether the first video frame of the movie is ready to be displayed. The default value of this property is NO. This property returns YES if the first video frame is ready to be displayed and returns NO if there are no video tracks associated. When the value of this property changes to YES, a MPMoviePlayerReadyForDisplayDidChangeNotification is sent.

Returns:

  • (Boolean)

- ( (nonatomic) MPMovieRepeatMode ) repeatMode

Determines how the movie player repeats the playback of the movie. The default value of this property is MPMovieRepeatModeNone. For a list of available repeat modes, see “MPMovieRepeatMode.”

Returns:

  • ( (nonatomic) MPMovieRepeatMode )

- ( (nonatomic) MPMovieScalingMode ) scalingMode

The scaling mode to use when displaying the movie. Changing this property while the movie player is visible causes the current movie to animate to the new scaling mode.The default value of this property is MPMovieScalingModeAspectFit. For a list of available scaling modes, see “MPMovieScalingMode.”

Returns:

- ( (nonatomic) BOOL ) shouldAutoplay

A Boolean that indicates whether a movie should begin playback automatically. The default value of this property is YES. This property determines whether the playback of network-based content begins automatically when there is enough buffered data to ensure uninterrupted playback.

Returns:

  • ( (nonatomic) BOOL )

- ( (nonatomic, readonly) UIView ) view (readonly)

The view containing the movie content and controls. (read-only) This property contains the view used for presenting the video content. This view incorporates all the background, content, and controls needed to display movies. You can incorporate this view into your own view hierarchies or present it by itself using a view controller.To embed the view into your own view hierarchies, add it as a subview to one of your existing views. A good place to do this is in the loadView or viewDidLoad method of the custom view controller that presents your view hierarchy. You are free to change the view’s frame rectangle to accommodate the space available in your view hierarchy. The movie player uses the value in the scalingMode property to scale the movie content to match the frame you specify.If you want to present the view by itself—that is, without embedding it in an existing view hierarchy—you can use an instance of the MPMoviePlayerViewController class to manage the presentation of the view. That class works directly with the movie player controller to present the view by itself.You can add subviews to the view in this property. You might do this in cases where you want to display custom playback controls or add other custom content that is relevant to your app.

Returns:

  • ( (nonatomic, readonly) UIView )

Instance Method Details

- (Object) cancelAllThumbnailImageRequests

Cancels all pending asynchronous thumbnail image requests. This method cancels only requests made using the requestThumbnailImagesAtTimes:timeOption: method. It does not cancel requests made synchronously using the thumbnailImageAtTime:timeOption: method.

Returns:

- (Object) initWithContentURL(url)

Returns a MPMoviePlayerController object initialized with the movie at the specified URL. This method initializes a movie player, but does not prepare it for playback. To prepare a new movie player for playback, call the prepareToPlay method, described in MPMediaPlayback Protocol Reference.To be notified when a new movie player is ready to play, register for the MPMoviePlayerLoadStateDidChangeNotification notification. You can then check load state by accessing the loadState property.To check for errors in URL loading, register for the MPMoviePlayerPlaybackDidFinishNotification notification. On error, this notification contains an NSError object available using the @“error” key in the notification’s userInfo dictionary.

Parameters:

  • url (NSURL)

    The location of the movie file. This file must be located either in your app directory or on a remote server.

Returns:

  • (Object)

    The movie player object.

- (Object) requestThumbnailImagesAtTimes(playbackTimes, timeOption:option)

Captures one or more thumbnail images asynchronously from the current movie. This method processes each thumbnail request separately and asynchronously. When the results for a single image arrive, the movie player posts a MPMoviePlayerThumbnailImageRequestDidFinishNotification notification with the results for that image. Notifications are posted regardless of whether the image capture was successful or failed. You should register for this notification prior to calling this method.

Parameters:

  • playbackTimes (Array)

    An array of NSNumber objects containing the times at which to capture the thumbnail images. Each time value represents the number of seconds from the beginning of the current movie.

  • option (MPMovieTimeOption)

    The option to use when determining which specific frame to use for each thumbnail image. For a list of possible values, see “MPMovieTimeOption.”

Returns:

- (Object) setFullscreen(fullscreen, animated:animated)

Causes the movie player to enter or exit full-screen mode.

Parameters:

  • fullscreen (Boolean)

    Specify YES to enter full-screen mode or NO to exit full-screen mode.

  • animated (Boolean)

    Specify YES to animate the transition between modes or NO to switch immediately to the new mode.

Returns:

- (UIImage) thumbnailImageAtTime(playbackTime, timeOption:option)

Captures and returns a thumbnail image from the current movie. This method captures the thumbnail image synchronously from the current movie (which is accessible from the MPMovieSourceTypeUnknown property).

Parameters:

  • playbackTime (NSTimeInterval)

    The time at which to capture the thumbnail image. The time value represents the number of seconds from the beginning of the current movie.

  • option (MPMovieTimeOption)

    The option to use when determining which specific frame to use for the thumbnail image. For a list of possible values, see “MPMovieTimeOption.”

Returns:

  • (UIImage)

    An image object containing the image from the movie or nil if the thumbnail could not be captured.

- (Array) timedMetadata

Obtains the most recent time-based metadata provided by the streamed movie.

Returns: