Movie

public class Movie: View

This document describes the Movie class. You use a Movie object to implement the playback of video files, it encapulates an AVQueuePlayer object which handles the loading and control of assets.

The Movie class is meant to simplify the addition of videos to your application. It is also a subclass of View, and so has all the common animation, interaction and notification capabilities.

A C4Movie’s resizing behaviour is to map itself to the edges of its visible frame. This functionality implicitly uses AVLayerVideoGravityResize as its layer’s default gravity. You can change the frame of the movie from an arbitrary shape back to its original proportion by using its originalSize, originalRatio, or by independently setting either its width or height properties.

  • Assigning a value of true to this property will cause the receiver to loop at the end of playback.

    The default value of this property is true.

    Declaration

    Swift

    public var loops: Bool = true
  • Mute/Unmute the audio track.

    The default value of this property is false.

    Declaration

    Swift

    public var muted: Bool
  • A variable that provides access to the width of the receiver. Animatable. The default value of this property is defined by the movie being created. Assigning a value to this property causes the receiver to change the width of its frame. If the receiver’s contrainsProportions variable is set to true the receiver’s height will change to match the new width.

    Declaration

    Swift

    public override var width: Double
  • A variable that provides access to the height of the receiver. Animatable. The default value of this property is defined by the movie being created. Assigning a value to this property causes the receiver to change the height of its frame. If the receiver’s contrainsProportions variable is set to true the receiver’s width will change to match the new height.

    Declaration

    Swift

    public override var height: Double
  • Assigning a value of true to this property will cause the receiver to scale its entire frame whenever its width or height variables are set. The default value of this property is true.

    Declaration

    Swift

    public var constrainsProportions: Bool = true
  • The original size of the receiver when it was initialized.

    Declaration

    Swift

    public internal(set) var originalSize: Size = Size(1, 1)
  • The original width/height ratio of the receiver when it was initialized.

    Declaration

    Swift

    public var originalRatio: Double
  • The current rotation value of the view. Animatable. - returns: A Double value representing the cumulative rotation of the view, measured in Radians.

    Declaration

    Swift

    public override var rotation: Double

    Return Value

    A Double value representing the cumulative rotation of the view, measured in Radians.

  • Initializes a new Movie using the specified filename from the bundle (i.e. your project).

    Declaration

    Swift

    public convenience init?(_ filename: String)

    Parameters

    filename

    The name of the movie file included in your project.

  • Initializes a new Movie using the specified frame.

    Declaration

    Swift

    public override init(frame: Rect)

    Parameters

    frame

    The frame of the new movie object.

  • Undocumented

    Declaration

    Swift

    public class Movie: View
  • Begins playback of the current item.

    This is the same as setting rate to 1.0.

    Declaration

    Swift

    public func play()
  • Pauses playback.

    This is the same as setting rate to 0.0.

    Declaration

    Swift

    public func pause()
  • Stops playback.

    This is the same as setting rate to 0.0 and resetting the current time to 0.

    Declaration

    Swift

    public func stop()
  • The action to perform at the end of playback.

    Declaration

    Swift

    public func reachedEnd(action: ()->())

    Parameters

    action

    A block of code to execute at the end of playback.