Skip to content

Commit

Permalink
docs(README): add info on how to use other views
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Oct 24, 2023
1 parent e2b85db commit 59bbd47
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ your app.
- [Retrieve your video Id](#retrieve-your-video-id)
- [Usage](#usage)
- [Remote control](#remote-control)
- [Supported player views](#supported-player-views)
- [Play an api.video video in your AVPlayer](#play-an-apivideo-video-in-your-avplayer)
- [Sample application](#sample-application)
- [Documentation](#documentation)
Expand Down Expand Up @@ -198,6 +199,39 @@ When you have to remove it set `enableRemoteControl` to false

By default the remote control is hidden.

### Supported player views

The api.video Swift player comes with a specific view `ApiVideoPlayerView` to display the video
and its controller. If you require a customization of this view such as changing a button color,...,
you can contact [us](https://github.com/apivideo/api.video-swift-player/issues).

Otherwise, in the `ApiVideoPlayerController`, you can also use the following views:

- [`AVPlayerViewController`](https://developer.apple.com/documentation/avkit/avplayerviewcontroller): AVKit view

```swift
// Create the api.video controller
let controller = ApiVideoPlayerController(
videoOptions: VideoOptions(videoId: "vi77Dgk0F8eLwaFOtC5870yn", videoType: .vod),
delegates: [],
autoplay: false
)
// Create the AVKit AVPlayerViewController
let viewController = AVPlayerViewController()

/// Pass the api.video controller to the AVKit AVPlayerViewController
viewController.setApiVideoPlayerController(controller)
// Prepare the view
self.addChild(viewController)
view.addSubview(viewController.view)
// Set the AVKit AVPlayerViewController frame size according to your needs (here it's the whole screen)
viewController.view.frame = self.view.frame
// Do what you want with the video controller (play, pause, seek,...)
controller.play()
```

- [`AVPlayerLayer`](https://developer.apple.com/documentation/avfoundation/avplayerlayer). A view that only display the video. It requires more work to be used.

## Play an api.video video in your AVPlayer

If you are using AVPlayer directly, you can use the api.video Swift extensions:
Expand Down

0 comments on commit 59bbd47

Please sign in to comment.