Skip to content

Commit

Permalink
Merge pull request #334 from apivideo/documentation-flutter-player
Browse files Browse the repository at this point in the history
[SDK README - api.video-flutter-player] README to documentation synchro
  • Loading branch information
olivier-lando authored Nov 13, 2023
2 parents 5cea21e + 3ad6411 commit 33da97b
Showing 1 changed file with 50 additions and 41 deletions.
91 changes: 50 additions & 41 deletions templates/documentation/sdks/player/apivideo-flutter-player.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ title: api.video Flutter Player
meta:
description: The official api.video Flutter Player component for api.video. [api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.
---
<!--
THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT!
IF YOU NEED TO CHANGE THIS FILE, CREATE A PR IN THE SOURCE REPOSITORY.
-->

# api.video Flutter Player

[api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast
video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in
your app.
[api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

## Project description

Expand Down Expand Up @@ -39,7 +41,7 @@ If you want to use your application as a web app, you need to add the [api.video
</head>

<body>
...
...
</body>
</html>
```
Expand Down Expand Up @@ -80,25 +82,27 @@ See the sample application below for more details.

A Widget that displays the video and its controls.

The [ApiVideoPlayer](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player.dart) constructor takes 3 parameters:
The [ApiVideoPlayer](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/widgets/apivideo_player.dart) constructor takes 3 parameters:

| Parameter | Mandatory | Type | Description |
|--------------|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| controller | Yes | [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart) | The controller that controls a video player |
| hideControls | No (default false) | bool | Allows you to hide or show the controls of a video player |
| theme | No (default PlayerTheme) | [PlayerTheme](https://github.com/apivideo/api.video-flutter-player/blob/4efe23f20ccf1c9459cee7588da1d3fed74e8e36/lib/src/apivideo_player.dart#L102) | Allows you to customize the video player's colors |
| Parameter | Mandatory | Type | Description |
|------------|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| controller | Yes | [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart) | The controller that controls a video player | | Allows you to hide or show the controls of a video player |
| fit | No (default BoxFit.contain) | [BoxFit](https://api.flutter.dev/flutter/painting/BoxFit.html) | How the player should be inscribed into its box. |
| style | No (default api.video style) | [PlayerStyle](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/style/apivideo_style.dart#L102) | Allows you to customize the video player's colors, shapes,... |
| child | No (default api.video overlay) | Widget | Replace api.video overlay by your own implementation. |

```dart
final ApiVideoPlayerController controller = ApiVideoPlayerController(
videoOptions: VideoOptions(videoId: 'VIDEO_ID'),
);
await controller.initialize();
Widget build(BuildContext context) {
return ApiVideoPlayer(
controller: controller,
)
return ApiVideoPlayer(
controller: controller,
);
}
```

Expand All @@ -121,6 +125,7 @@ Once the [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutte
Example:

```dart
final ApiVideoPlayerController controller = ApiVideoPlayerController(
videoOptions: VideoOptions(videoId: 'VIDEO_ID'),
);
Expand Down Expand Up @@ -150,6 +155,7 @@ Once the [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutte
Example:

```dart
final ApiVideoPlayerController controller = ApiVideoPlayerController(
videoOptions: VideoOptions(videoId: 'VIDEO_ID'),
);
Expand All @@ -166,30 +172,32 @@ final bool isMuted = await controller.isMuted;
When you instantiate a new [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart), you can bind callbacks to some events:

```dart
final ApiVideoPlayerController controller = ApiVideoPlayerController(
videoOptions: VideoOptions(videoId: 'VIDEO_ID'),
onPlay: () => print('PLAY'),
onPause: () => print('PAUSE'),
);
videoOptions: VideoOptions(videoId: 'VIDEO_ID'),
onPlay: () => print('PLAY'),
onPause: () => print('PAUSE'),
);
```

#### Add a new event listener: Method 2

Once the [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart) has been instantiated, you can bind callbacks to some events:

```dart
final ApiVideoPlayerController controller = ApiVideoPlayerController(
videoOptions: VideoOptions(videoId: 'VIDEO_ID'),
);
await controller.initialize();
final ApiVideoPlayerEventsListener eventsListener =
ApiVideoPlayerEventsListener(
onPlay: () => print('PLAY'),
);
final ApiVideoPlayerControllerEventsListener eventsListener =
ApiVideoPlayerControllerEventsListener(
onPlay: () => print('PLAY'),
);
controller.addEventsListener(eventsListener);
controller.addListener(eventsListener);
```

| Event | Type | Description |
Expand All @@ -202,31 +210,24 @@ controller.addEventsListener(eventsListener);

#### Remove an event listener

To remove an event listener, you need to call the controller's `removeEventsListener` method.
To remove an event listener, you need to call the controller's `removeListener` method.

```dart
final ApiVideoPlayerController controller = ApiVideoPlayerController(
videoOptions: VideoOptions(videoId: 'VIDEO_ID'),
);
await controller.initialize();
final ApiVideoPlayerEventsListener eventsListener =
ApiVideoPlayerEventsListener(
onPlay: () => print('PLAY'),
);
final ApiVideoPlayerControllerEventsListener eventsListener =
ApiVideoPlayerControllerEventsListener(
onPlay: () => print('PLAY'),
);
controller.removeEventsListener(eventsListener);
controller.removeListener(eventsListener);
```

## Dependencies

We are using external library

| Plugin | README |
|--------------------------------------------------|---------------------------------------------------------|
| [Exoplayer](https://github.com/google/ExoPlayer) | [README.md](https://github.com/google/ExoPlayer#readme) |

## Sample application

```dart
Expand Down Expand Up @@ -255,8 +256,8 @@ class _MyAppState extends State<MyApp> {
void initState() {
super.initState();
_controller.initialize();
_controller.addEventsListener(
ApiVideoPlayerEventsListener(
_controller.addListener(
ApiVideoPlayerControllerEventsListener(
onPause: () => print('PAUSE'),
),
);
Expand Down Expand Up @@ -307,10 +308,18 @@ class _MyAppState extends State<MyApp> {
);
}
}
```

## Dependencies

We are using external library

| Plugin | README |
|--------------------------------------------------|---------------------------------------------------------|
| [Exoplayer](https://github.com/google/ExoPlayer) | [README.md](https://github.com/google/ExoPlayer#readme) |


## FAQ

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

0 comments on commit 33da97b

Please sign in to comment.