TTMSNativeAVPlayerViewController
Usage
A TMSNativeAVPlayerViewController
displays the video content of an AVPlayer
object along with system-supplied playback controls. When you use a player view controller, the system makes its media content available for the user to play on the screen of the playback device or on a second screen such as Apple TV. Starting in iOS 9, supported iPad models also provide Picture in Picture playback from a player view controller.
Methods
Methods name | Description |
---|---|
Hide | When the ShowInView property is set to False, the PlayerViewController can be presented fullscreen with the Show method. The Hide method will hide the presented PlayerViewController . |
InitializePlayback | Initializes audio, airplay and picture in picture (iOS 9) support. |
Pause | Pauses the audio or video. |
Play | Plays the audio or video. |
Player | Returns a native reference to the AVPlayer , automatically created when using an AVPlayerViewController . |
PlayerViewController | Returns a native reference to the AVPlayerViewController that holds a reference to the AVPlayer instance. |
ReadyForDisplay: Boolean; | Returns a Boolean whether the audio/video is ready to be displayed. |
Show | When the ShowInView property is set to False, the PlayerViewController can be presented fullscreen with this method. |
Stop | Stops playing the audio or video. |
VideoBounds: TRectF; | Returns the current video rectangle used inside the PlayerViewController . |
Properties
Properties name | Description |
---|---|
AllowsPictureInPicturePlayback | Sets a Boolean whether picture in picture is supported (iOS 9). |
Location | The location of the local video / audio file. |
ShowInView | Shows the player in the view controller (default). When set to False, the player can be shown full screen when using the Show method. |
ShowPlaybackControls | Sets a Boolean whether the playback controls are visible or not. |
URL | The URL of the remove video / audio file. |
VideoGravity | The aspect ratio of the video inside the view controller. |
Events
Events name | Description |
---|---|
OnDidStartPictureInPicture | Event called when picture in picture is started. |
OnDidStopPictureInPicture | Event called when picture in picture is stopped. |
OnRestoreUserInterfaceForPictureInPictureStop | Event called when picture in picture is stopping and is restored to the original user interface. |
OnShouldAutomaticallyDismissAtPictureAndPictureStart | Event called when picture in picture is starting and asks if the player view controller should automatically dismiss. |
OnWillStartPictureInPicture | Event called when picture in picture will start. |
OnWillStopPictureInPicture | Event called when picture in picture will stop. |
Picture in Picture (iOS 9)
To support picture in picture, there are 2 additional steps that need to be taken.
-
An additional entry is needed inside the plist. The
UIBackgroundModes
property in the Project Options -> Version Info needs to contain the audio entry.When building the application, the audio entry will be added and the application will then be able to support picture in picture playback mode.
-
Additionally, the audio/video session needs to be initialized with the playback category, needed to support picture in picture. The
TTMSFMXNativeAVPlayerViewController
exposes a class function that needs to be called in the constructor of the form:
When these steps are successfully executed, the button in the right corner will allow you to display the video outside of the application as demonstrated in the following sample:
When closing the application, the player will remain on top. The left button in the picture in picture view will allow you to return to the application.