Skip to content

Commit

Permalink
docs(player): add info on player view
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Oct 23, 2023
1 parent d03c906 commit 3960f2b
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ your [dashboard](https://dashboard.api.video).

## Usage

The api.video Android player will help you to play the HLS video from api.video. It also generates
analytics of [your viewers usage](https://api.video/product/video-analytics/).
The api.video Android player will help you to play the HLS video from api.video. It also generates
analytics of [your viewers usage](https://api.video/product/video-analytics/).

1. Add a `ApiVideoExoPlayerView` to your Activity/Fragment layout:

Expand All @@ -80,7 +80,8 @@ analytics of [your viewers usage](https://api.video/product/video-analytics/).
app:show_subtitles="true" />
```

You can also use an ExoPlayer `StyledPlayerView` or a `SurfaceView` according to your customisation level.
You can also use an ExoPlayer `StyledPlayerView` or a `SurfaceView` according to your customisation
level.

2. Implements the `ApiVideoPlayerController.Listener` interface:

Expand All @@ -102,22 +103,27 @@ val playerView = findViewById<ApiVideoExoPlayerView>(R.id.playerView)

val player = ApiVideoPlayerController(
applicationContext,
VideoOptions("YOUR_VIDEO_ID", VideoType.VOD), // For private video: VideoOptions("YOUR_VIDEO_ID", VideoType.VOD, "YOUR_PRIVATE_VIDEO_TOKEN")
VideoOptions(
"YOUR_VIDEO_ID",
VideoType.VOD
), // For private video: VideoOptions("YOUR_VIDEO_ID", VideoType.VOD, "YOUR_PRIVATE_VIDEO_TOKEN")
playerListener,
playerView
)
```

4. Fullscreen video

If you requires a fullscreen video. You will have to implement the `ApiVideoPlayerController.ViewListener` interface.
If you requires a fullscreen video. You will have to implement
the `ApiVideoPlayerController.ViewListener` interface.
Check out for the implementation in the [Sample application](#sample-application).

## Play your api.video video with ExoPlayer

If you want to use the ExoPlayer directly, you can use the api.video Android extensions:

1. Create a video

```kotlin
val videoOptions = VideoOptions("YOUR_VIDEO_ID", VideoType.VOD)
```
Expand All @@ -131,13 +137,26 @@ exoplayer.addMediaSource(videoOptions)
exoplayer.setMediaSource(videoOptions)
```

## Player views

The api.video Android player comes with a specific view `ApiVideoExoPlayerView` to display the video
and its controller. If you require a customization of the view such as changing a button color,...,
you can contact [us](https://github.com/apivideo/api.video-android-player/issues).
Otherwise, you can also directly use the ExoPlayer views
from `media3`: [`PlayerView`](https://developer.android.com/reference/androidx/media3/ui/PlayerView).
The `ApiVideoPlayerController` also supports other type of views such
as [`SurfaceView`](https://developer.android.com/reference/android/view/SurfaceView)
and [`Surface`](https://developer.android.com/reference/android/view/Surface) but it requires far
more work.

# Sample application

A demo application demonstrates how to use player.
See [`/example`](https://github.com/apivideo/api.video-android-player/tree/main/example)
folder.

On the first run, you will have to set your video Id:

1. Click on the FloatingActionButton -> Settings
2. Replace the video Id with your own video Id

Expand All @@ -156,5 +175,5 @@ We are using external library

# FAQ

If you have any questions, ask us here: [https://community.api.video](https://community.api.video).
Or use [Issues].
If you have any questions, ask us in the [community](https://community.api.video) or
use [issues](https://github.com/apivideo/api.video-android-player/issues).

0 comments on commit 3960f2b

Please sign in to comment.