Skip to content

Commit

Permalink
docs(README): add info on AVPlayer extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Oct 24, 2023
1 parent 817b596 commit 768da01
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
  [![badge](https://img.shields.io/github/stars/apivideo/api.video-swift-player?style=social)](https://github.com/apivideo/api.video-swift-player)
  [![badge](https://img.shields.io/discourse/topics?server=https%3A%2F%2Fcommunity.api.video)](https://community.api.video)
![](https://github.com/apivideo/.github/blob/main/assets/apivideo_banner.png)

<h1 align="center">api.video Swift player</h1>

[api.video](https://api.video) is the video infrastructure for product builders. Lightning fast
Expand All @@ -13,13 +14,17 @@ your app.
- [Table of contents](#table-of-contents)
- [Project description](#project-description)
- [Getting started](#getting-started)
- [Installation](#installation)
- [Swift Package Manager](#swift-package-manager)
- [Cocoapods](#cocoapods)
- [Retrieve your video Id](#retrieve-your-video-id)
- [Installation](#installation)
- [Swift Package Manager](#swift-package-manager)
- [Cocoapods](#cocoapods)
- [Retrieve your video Id](#retrieve-your-video-id)
- [Usage](#usage)
- [Remote control](#remote-control)
- [Play an api.video video in your AVPlayer](#play-an-apivideo-video-in-your-avplayer)
- [Sample application](#sample-application)
- [Documentation](#documentation)
- [Dependencies](#dependencies)
- [FAQ](#faq)

# Project description

Expand Down Expand Up @@ -77,8 +82,7 @@ a video Id to use this component and play a video from api.video. To get yours,
Alternatively, you can find your video Id in the video details of
your [dashboard](https://dashboard.api.video).


## Code sample
## Usage

1. Imports the library

Expand Down Expand Up @@ -181,17 +185,37 @@ override func viewDidAppear(_ animated: Bool) {

### Remote control

If you want to enable the remote control do the following:
If you want to enable the remote control do the following:

```swift
override func viewDidLoad() {
...
self.playerView.enableRemoteControl = true
}
```

When you have to remove it set `enableRemoteControl` to false

By default the remote control is hidden.

## Play an api.video video in your AVPlayer

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

1. Create a video

```swift
let videoOptions = VideoOptions(videoId: "YOUR_VIDEO_ID", videoType: .vod))
// for private video VideoOptions(videoId: "YOUR_VIDEO_ID", videoType: .vod, token: "YOUR_PRIVATE_VIDEO_TOKEN")
```

2. Pass it to your AVPlayer

```swift
val player = AVPlayer() // You already have that in your code
avPlayer.replaceCurrentItem(withHls: videoOptions)
```

# Sample application

A demo application demonstrates how to use player.
Expand All @@ -204,15 +228,15 @@ On the first run, you will have to set your video Id:

# Documentation

* [Player documentation](https://apivideo.github.io/api.video-swift-player/documentation/apivideoplayer/)
* [api.video documentation](https://docs.api.video)
- [Player documentation](https://apivideo.github.io/api.video-swift-player/documentation/apivideoplayer/)
- [api.video documentation](https://docs.api.video)

# Dependencies

We are using external library

| Plugin | README |
|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| Plugin | README |
| --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [ApiVideoPlayerAnalytics](https://github.com/apivideo/api.video-swift-player-analytics) | [README.md](https://github.com/apivideo/api.video-swift-player-analytics#readme) |

# FAQ
Expand Down

0 comments on commit 768da01

Please sign in to comment.