VideoPlayer
@MainActor
open class VideoPlayer : UIViewController
Video Player, simple way to play and stream media
-
Player delegate.
Declaration
Swift
open nonisolated weak var playerDelegate: VideoPlayerDelegate? { get set }
-
Playback delegate.
Declaration
Swift
open nonisolated weak var playbackDelegate: VideoPlayerPlaybackDelegate? { get set }
-
Local or remote URL for the file asset to be played. URL of the asset.
Declaration
Swift
@MainActor open var url: URL? { get set }
-
For setting up with AVAsset instead of URL Note: This will reset the
url
property. (cannot set both)Declaration
Swift
@MainActor open var asset: AVAsset? { get set }
-
Specifies how the video is displayed within a player layer’s bounds. The default value is
AVLayerVideoGravityResizeAspect
. SeePlayerFillMode
.Declaration
Swift
@MainActor open var fillMode: AVLayerVideoGravity { get set }
-
Determines if the video should autoplay when streaming a URL.
Declaration
Swift
@MainActor open var autoplay: Bool
-
Mutes audio playback when true.
Declaration
Swift
@MainActor open var muted: Bool { get set }
-
Volume for the player, ranging from 0.0 to 1.0 on a linear scale.
Declaration
Swift
@MainActor open var volume: Float { get set }
-
Rate at which the video should play once it loads
Declaration
Swift
@MainActor open var rate: Float { get set }
-
Pauses playback automatically when resigning active.
Declaration
Swift
@MainActor open var playbackPausesWhenResigningActive: Bool
-
Pauses playback automatically when backgrounded.
Declaration
Swift
@MainActor open var playbackPausesWhenBackgrounded: Bool
-
Resumes playback when became active.
Declaration
Swift
@MainActor open var playbackResumesWhenBecameActive: Bool
-
Resumes playback when entering foreground.
Declaration
Swift
@MainActor open var playbackResumesWhenEnteringForeground: Bool
-
Whether is playing video.
Declaration
Swift
@MainActor open var isPlayingVideo: Bool { get }
-
Playback automatically loops continuously when true.
Declaration
Swift
@MainActor open var playbackLoops: Bool { get set }
-
Playback freezes on last frame frame when true and does not reset seek position timestamp..
Declaration
Swift
@MainActor open var playbackFreezesAtEnd: Bool
-
Current playback state of the Player.
Declaration
Swift
open nonisolated var playbackState: VideoPlayerPlaybackState { get set }
-
Current buffering state of the Player.
Declaration
Swift
open nonisolated var bufferingState: VideoPlayerBufferingState { get set }
-
Playback buffering size in seconds.
Declaration
Swift
open nonisolated var bufferSizeInSeconds: Double { get set }
-
Playback is not automatically triggered from state changes when true.
Declaration
Swift
open nonisolated var playbackEdgeTriggered: Bool { get set }
-
Maximum duration of playback.
Declaration
Swift
open nonisolated var maximumDuration: TimeInterval { get }
-
Media playback’s current time interval in seconds.
Declaration
Swift
open nonisolated var currentTimeInterval: TimeInterval { get }
-
Media playback’s current time.
Declaration
Swift
open nonisolated var currentTime: CMTime { get }
-
The natural dimensions of the media.
Declaration
Swift
@MainActor open var naturalSize: CGSize { get }
-
Undocumented
Declaration
Swift
@MainActor open var player: AVPlayer { get }
-
Undocumented
Declaration
Swift
@MainActor open lazy var playerView: VideoPlayerView { get set }
-
Return the av player layer for consumption by things such as Picture in Picture
Declaration
Swift
@MainActor open func playerLayer() -> AVPlayerLayer?
-
Indicates the desired limit of network bandwidth consumption for this item.
Declaration
Swift
open nonisolated var preferredPeakBitRate: Double { get set }
-
Indicates a preferred upper limit on the resolution of the video to be downloaded.
Declaration
Swift
open nonisolated var preferredMaximumResolution: CGSize { get set }
-
Undocumented
Declaration
Swift
@MainActor override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?)
-
Undocumented
Declaration
Swift
@MainActor public required init?(coder aDecoder: NSCoder)
-
Undocumented
Declaration
Swift
@MainActor override open func loadView()
-
Undocumented
Declaration
Swift
@MainActor override open func viewDidLoad()
-
Undocumented
Declaration
Swift
@MainActor override open func viewDidDisappear(_ animated: Bool)
-
Total time spent playing.
Declaration
Swift
@MainActor public var totalDurationWatched: TimeInterval { get }
-
Begins playback of the media from the beginning.
Declaration
Swift
@MainActor open func playFromBeginning()
-
Begins playback of the media from the current time.
Declaration
Swift
@MainActor open func playFromCurrentTime()
-
Pauses playback of the media.
Declaration
Swift
@MainActor open func pause()
-
Stops playback of the media.
Declaration
Swift
@MainActor open func stop()
-
Updates playback to the specified time.
Declaration
Swift
open nonisolated func seek(to time: CMTime, completionHandler: (@Sendable (Bool) -> Void)? = nil)
Parameters
time
The time to switch to move the playback.
completionHandler
Call block handler after seeking/
-
Updates the playback time to the specified time bound.
Declaration
Swift
@MainActor open func seekToTime(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime, completionHandler: (@Sendable (Bool) -> Void)? = nil)
Parameters
time
The time to switch to move the playback.
toleranceBefore
The tolerance allowed before time.
toleranceAfter
The tolerance allowed after time.
completionHandler
call block handler after seeking
-
Captures a snapshot of the current Player asset.
Declaration
Swift
@MainActor open func takeSnapshot(completionHandler: (@MainActor @Sendable (_ image: UIImage?, _ error: Error?) -> Void)?)
Parameters
completionHandler
Returns a UIImage of the requested video frame. (Great for thumbnails!)