MediaPlayer
public class MediaPlayer
Undocumented
-
Determines if the media should autoplay
Declaration
Swift
open var autoplay: Bool
-
The audio playback volume for the player.
Declaration
Swift
open var volume: Float { get set }
-
A Boolean value that indicates whether the audio output of the player is muted.
Declaration
Swift
open var isMuted: Bool { get set }
-
A boolean value that indicates whether media playback is playing
Declaration
Swift
open var isPlaying: Bool { get set }
-
The current playback rate
Declaration
Swift
open var rate: Float { get set }
-
The action to perform when the current player item has finished playing.
Declaration
Swift
open var actionAtEnd: Richi.EndAction
-
Controls if playback is paused when the application is no longer active. This is because of temporary interruptions such as incoming phone calls, messages or when the app is backgrounded by the user.
Declaration
Swift
open var pauseWhenResigningActive: Bool
-
Controls if playback is paused when the application enters the background. This is triggered by the user sending the app to the background or locking the device.
Declaration
Swift
open var pauseWhenEnteringBackground: Bool
-
Controls if playback is resumed when the application has become active. Playback will be resumed only if the player was paused because of some temporary interruption.
Declaration
Swift
open var resumeWhenBecomingActive: Bool
-
Controls if playback is resumed when the application is about to enter the foreground
Declaration
Swift
open var resumeWhenEnteringForeground: Bool
-
The current asset
Declaration
Swift
open var asset: Richi.Asset? { get set }
-
Current playback state of the Player
Declaration
Swift
open internal(set) var playbackState: Richi.PlaybackState { get set }
-
Current buffering state of the Player
Declaration
Swift
open internal(set) var bufferingState: Richi.BufferingState { get set }
-
Maximum duration of playback.
Declaration
Swift
open var duration: TimeInterval { get }
-
Media playback’s current time.
Declaration
Swift
open var currentTime: CMTime { get }
-
Indicates the desired limit of network bandwidth consumption for this item.
Declaration
Swift
open var preferredPeakBitRate: Double { get set }
-
Media playback’s current time interval in seconds.
Declaration
Swift
open var currentDuration: TimeInterval { get }
-
The object that acts as the time delegate of the audio player view
Declaration
Swift
open weak var timeDelegate: MediaPlayerTimeDelegate? { get set }
-
The time interval at which time observers should notify the progress of the player’s current time.
Declaration
Swift
open var timeObserverInterval: TimeInterval { get set }
-
The underlying AVPlayer object
Declaration
Swift
open var player: AVPlayer { get set }
-
The underlying AVPlayerItem object currently playing
Declaration
Swift
open internal(set) var playerItem: AVPlayerItem? { get set }
-
Initializes and returns a newly allocated media player object.
Declaration
Swift
public init()
-
Creates a publisher that emits an event when specified times are traversed during normal playback.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, *) open func boundaryTimePublisher(forTimes times: [CMTime]) -> AnyPublisher<Void, Never>
Parameters
times
An array of CMTime values representing the times at which to emit events.
Return Value
A publisher that emits events when traversing specific times.
-
Creates a publisher that periodically emits the changing time of the current playback.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, *) open func periodicTimePublisher(forInterval interval: CMTime) -> AnyPublisher<CMTime, Never>
Parameters
interval
The time interval at which the system invokes the block during normal playback, according to progress of the player’s current time.
Return Value
A publisher that emits the changing time.
-
Loads the given asset and prepares the player. With autoplay enabled, the asset will be played automatically as soon as the player is ready.
Declaration
Swift
open func load(asset: Richi.Asset)
Parameters
asset
The asset to be played
-
Plays the current asset from the beginning
Declaration
Swift
open func playFromBeginning()
-
Continues playing the current asset if
shouldPlay
istrue
, pauses playback otherwise.Declaration
Swift
open func play(_ shouldPlay: Bool = true)
Parameters
shouldPlay
Indicates if the player should play or pause
-
Pauses playback of the current asset
Declaration
Swift
open func pause()
-
Stops playback of the current asset.
Declaration
Swift
open func stop()
-
Sets the current playback time to the specified time and executes the specified block when the seek operation completes or is interrupted.
Declaration
Swift
open func seek(to time: CMTime, completionHandler: ((Bool) -> Void)? = nil)
Parameters
time
The time to which to seek.
completionHandler
The block to invoke when the seek operation has either been completed or been interrupted.
-
Sets the current playback time within a specified time bound and invokes the specified block when the seek operation completes or is interrupted.
Declaration
Swift
open func seek( to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime, completionHandler: ((Bool) -> Void)? = nil )
Parameters
time
The time to which to seek.
toleranceBefore
The tolerance allowed before time.
toleranceAfter
The tolerance allowed after time.
completionHandler
The block to invoke when the seek operation has either been completed or been interrupted.
-
Requests the invocation of a block when specified times are traversed during normal playback.
Declaration
Swift
open func addBoundaryTimeObserver( forTimes times: [CMTime], queue: DispatchQueue? = nil, using block: @escaping () -> Void ) -> Any
Parameters
times
An array of CMTime values representing the times at which to invoke block.
queue
A serial queue onto which block should be enqueued. Passing a concurrent queue is not supported and will result in undefined behavior. If you pass nil, the main queue is used.
block
The block to be invoked when any of the times in times is crossed during normal playback.
Return Value
An opaque object that you pass as the argument to removeTimeObserver(_:) to stop observation.
-
Requests the periodic invocation of a given block during playback to report changing time.
Declaration
Swift
open func addPeriodicTimeObserver( forInterval interval: CMTime, queue: DispatchQueue? = nil, using block: @escaping (CMTime) -> Void ) -> Any
Parameters
interval
The time interval at which the system invokes the block during normal playback, according to progress of the player’s current time.
queue
The dispatch queue on which the system calls the block. Passing a concurrent queue isn’t supported and results in undefined behavior. If you pass nil, the system uses the main queue.
block
The block that the system periodically invokes.
Return Value
An opaque object that you pass as the argument to removeTimeObserver(_:) to cancel observation.
-
Cancels a previously registered periodic or boundary time observer.
Declaration
Swift
open func removeTimeObserver(_ observer: Any)
Parameters
observer
An object returned by a previous call to addPeriodicTimeObserver(forInterval:queue:using:) or addBoundaryTimeObserver(forTimes:queue:using:).