Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 527abb0

Browse files
cbenhagenMichael Klimushyn
authored andcommitted
[video_player] Document public API of video_player_platform_interface. (#2355)
1 parent 0b22fec commit 527abb0

4 files changed

Lines changed: 76 additions & 14 deletions

File tree

packages/video_player/video_player_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.3
2+
3+
* Document public API.
4+
15
## 1.0.2
26

37
* Fix unawaited futures in the tests.

packages/video_player/video_player_platform_interface/analysis_options.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,22 @@ abstract class VideoPlayerPlatform {
119119
void _verifyProvidesDefaultImplementations() {}
120120
}
121121

122+
/// Description of the data source used to create an instance of
123+
/// the video player.
122124
class DataSource {
125+
/// Constructs an instance of [DataSource].
126+
///
127+
/// The [sourceType] is always required.
128+
///
129+
/// The [uri] argument takes the form of `'https://example.com/video.mp4'` or
130+
/// `'file://${file.path}'`.
131+
///
132+
/// The [formatHint] argument can be null.
133+
///
134+
/// The [asset] argument takes the form of `'assets/video.mp4'`.
135+
///
136+
/// The [package] argument must be non-null when the asset comes from a
137+
/// package and null otherwise.
123138
DataSource({
124139
@required this.sourceType,
125140
this.uri,
@@ -128,16 +143,34 @@ class DataSource {
128143
this.package,
129144
});
130145

146+
/// The way in which the video was originally loaded.
147+
///
148+
/// This has nothing to do with the video's file type. It's just the place
149+
/// from which the video is fetched from.
131150
final DataSourceType sourceType;
151+
152+
/// The URI to the video file.
153+
///
154+
/// This will be in different formats depending on the [DataSourceType] of
155+
/// the original video.
132156
final String uri;
157+
158+
/// **Android only**. Will override the platform's generic file format
159+
/// detection with whatever is set here.
133160
final VideoFormat formatHint;
161+
162+
/// The name of the asset. Only set for [DataSourceType.asset] videos.
134163
final String asset;
164+
165+
/// The package that the asset was loaded from. Only set for
166+
/// [DataSourceType.asset] videos.
135167
final String package;
136168
}
137169

138-
/// The way in which the video was originally loaded. This has nothing to do
139-
/// with the video's file type. It's just the place from which the video is
140-
/// fetched from.
170+
/// The way in which the video was originally loaded.
171+
///
172+
/// This has nothing to do with the video's file type. It's just the place
173+
/// from which the video is fetched from.
141174
enum DataSourceType {
142175
/// The video was included in the app's asset files.
143176
asset,
@@ -164,17 +197,37 @@ enum VideoFormat {
164197
other
165198
}
166199

200+
/// Event emitted from the platform implementation.
167201
class VideoEvent {
202+
/// Creates an instance of [VideoEvent].
203+
///
204+
/// The [eventType] argument is required.
205+
///
206+
/// Depending on the [eventType], the [duration], [size] and [buffered]
207+
/// arguments can be null.
168208
VideoEvent({
169209
@required this.eventType,
170210
this.duration,
171211
this.size,
172212
this.buffered,
173213
});
174214

215+
/// The type of the event.
175216
final VideoEventType eventType;
217+
218+
/// Duration of the video.
219+
///
220+
/// Only used if [eventType] is [VideoEventType.initialized].
176221
final Duration duration;
222+
223+
/// Size of the video.
224+
///
225+
/// Only used if [eventType] is [VideoEventType.initialized].
177226
final Size size;
227+
228+
/// Buffered parts of the video.
229+
///
230+
/// Only used if [eventType] is [VideoEventType.bufferingUpdate].
178231
final List<DurationRange> buffered;
179232

180233
@override
@@ -196,12 +249,27 @@ class VideoEvent {
196249
buffered.hashCode;
197250
}
198251

252+
/// Type of the event.
253+
///
254+
/// Emitted by the platform implementation when the video is initialized or
255+
/// completed or to communicate buffering events.
199256
enum VideoEventType {
257+
/// The video has been initialized.
200258
initialized,
259+
260+
/// The playback has ended.
201261
completed,
262+
263+
/// Updated information on the buffering state.
202264
bufferingUpdate,
265+
266+
/// The video started to buffer.
203267
bufferingStart,
268+
269+
/// The video stopped to buffer.
204270
bufferingEnd,
271+
272+
/// An unknown event has been received.
205273
unknown,
206274
}
207275

packages/video_player/video_player_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: Flutter Team <[email protected]>
44
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_platform_interface
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 1.0.2
7+
version: 1.0.3
88

99
dependencies:
1010
flutter:

0 commit comments

Comments
 (0)