PSPDFMediaPlayerController
Objective-C
@interface PSPDFMediaPlayerController : NSObject
Swift
class MediaPlayerController : NSObject
A simple media player used for video playback.
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_EMPTY_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_EMPTY_INIT_UNAVAILABLE
-
Initialize the player controller with the URL of the media file.
Declaration
Objective-C
- (nonnull instancetype)initWithContentURL:(nonnull NSURL *)contentURL;
Swift
init(contentURL: URL)
-
The content URL of the item that the player plays.
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSURL *_Nonnull contentURL;
Swift
var contentURL: URL { get }
-
If an error occurred while preparing the content for playback, this will bet set.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSError *contentError;
Swift
var contentError: Error? { get }
-
Starts playing the media.
-
Pauses all instances of this class.
-
Seek to
time
. -
Indicates if the player did finish playing the entire video.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL didFinishPlaying;
Swift
var didFinishPlaying: Bool { get }
-
If the media is currently playing, this returns YES.
Declaration
Objective-C
@property (nonatomic, readonly, getter=isPlaying) BOOL playing;
Swift
var isPlaying: Bool { get }
-
Indicates if the player uses external playback.
Declaration
Objective-C
@property (nonatomic, readonly, getter=isExternalPlaybackActive) BOOL externalPlaybackActive;
Swift
var isExternalPlaybackActive: Bool { get }
-
The current state of the content.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFMediaPlayerControllerContentState contentState;
Swift
var contentState: MediaPlayerController.ContentState { get }
-
The cover mode.
Declaration
Objective-C
@property (nonatomic) PSPDFMediaPlayerCoverMode coverMode;
Swift
var coverMode: MediaPlayerController.CoverMode { get set }
-
The URL of the cover image to be displayed. Only effective if
coverMode
is set toPSPDFMediaPlayerCoverModeCustom
.Declaration
Objective-C
@property (nonatomic, nullable) NSURL *coverImageURL;
Swift
var coverImageURL: URL? { get set }
-
The time in the video at which the image for the cover is captured. Only effective if
coverMode
is set toPSPDFMediaPlayerCoverModePreview
. Defaults to 2 seconds.Declaration
Objective-C
@property (nonatomic) CMTime coverImagePreviewCaptureTime;
Swift
var coverImagePreviewCaptureTime: CMTime { get set }
-
The player’s delegate.
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFMediaPlayerControllerDelegate> _Nullable delegate;
Swift
@IBOutlet weak var delegate: MediaPlayerControllerDelegate? { get set }
-
Set this to YES if you want to hide the toolbar. This property might be ignored if it is set to NO in case the
PSPDFMediaPlayerCoverView
is visible. Use view.toolbar.hidden to access the actual visibility state of the toolbar. Normally you don’t need to change this property yourself becausePSPDFMediaPlayerController
handles it for you. Defaults to YES.Declaration
Objective-C
@property (nonatomic) BOOL shouldHideToolbar;
Swift
var shouldHideToolbar: Bool { get set }
-
Set this to YES if you want to hide the toolbar. This might be ignored if it is set to NO in case the
PSPDFMediaPlayerCoverView
is visible. Use view.toolbar.hidden to access the actual visibility state of the toolbar. Normally you don’t need to change this property yourself becausePSPDFMediaPlayerController
handles it for you.Declaration
Objective-C
- (void)setShouldHideToolbar:(BOOL)shouldHideToolbar animated:(BOOL)animated;
Swift
func setShouldHideToolbar(_ shouldHideToolbar: Bool, animated: Bool)
Parameters
animated
BOOL
indicating whether to hide the toolbar animated. -
Indicates that the player has started playing, although it might not be playing right now. Defaults to NO.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL didStartPlaying;
Swift
var didStartPlaying: Bool { get }
-
The tap gesture recognizer used for toggling the toolbar.
Declaration
Objective-C
@property (nonatomic, readonly) UITapGestureRecognizer *_Nonnull tapGestureRecognizer;
Swift
var tapGestureRecognizer: UITapGestureRecognizer { get }
-
Enables playback looping. Defaults to
false
.Declaration
Objective-C
@property (nonatomic) BOOL loopEnabled;
Swift
var loopEnabled: Bool { get set }
-
Uses external playback automatically while an external screen is active. Defaults to
true
.Declaration
Objective-C
@property (nonatomic) BOOL usesExternalPlaybackWhileExternalScreenIsActive;
Swift
var usesExternalPlaybackWhileExternalScreenIsActive: Bool { get set }
-
The control style of the media player. Defaults to
PSPDFMediaPlayerControlStyleDefault
.Declaration
Objective-C
@property (nonatomic) PSPDFMediaPlayerControlStyle controlStyle;
Swift
var controlStyle: MediaPlayerController.ControlStyle { get set }
-
The range of the video that should be played. You can use this property to truncate parts of the video at the start or at the end. Defaults to a range with start
kCMTimeZero
, and durationkCMTimeIndefinite
, which means that the entire video will be played from start to end.Note
You must set this property before playback starts, otherwise it will have no effect.Declaration
Objective-C
@property (nonatomic) CMTimeRange playableRange;
Swift
var playableRange: CMTimeRange { get set }
-
The internally used player. The
AVPlayer
in use might change during the lifecycle of anPSPDFMediaPlayerController
! Use with caution!Declaration
Objective-C
@property (nonatomic, readonly, nullable) AVPlayer *internalPlayer;
Swift
var internalPlayer: AVPlayer? { get }