@@ -44,67 +44,81 @@ abstract class VideoPlayerPlatform extends PlatformInterface {
44
44
}
45
45
46
46
/// Clears one video.
47
- Future <void > dispose (int textureId ) {
47
+ Future <void > dispose (int playerId ) {
48
48
throw UnimplementedError ('dispose() has not been implemented.' );
49
49
}
50
50
51
- /// Creates an instance of a video player and returns its textureId.
51
+ /// Creates an instance of a video player and returns its playerId.
52
+ @Deprecated ('Use createWithOptions() instead.' )
52
53
Future <int ?> create (DataSource dataSource) {
53
54
throw UnimplementedError ('create() has not been implemented.' );
54
55
}
55
56
57
+ /// Creates an instance of a video player based on creation options
58
+ /// and returns its playerId.
59
+ Future <int ?> createWithOptions (VideoCreationOptions options) {
60
+ return create (options.dataSource);
61
+ }
62
+
56
63
/// Returns a Stream of [VideoEventType] s.
57
- Stream <VideoEvent > videoEventsFor (int textureId ) {
64
+ Stream <VideoEvent > videoEventsFor (int playerId ) {
58
65
throw UnimplementedError ('videoEventsFor() has not been implemented.' );
59
66
}
60
67
61
68
/// Sets the looping attribute of the video.
62
- Future <void > setLooping (int textureId , bool looping) {
69
+ Future <void > setLooping (int playerId , bool looping) {
63
70
throw UnimplementedError ('setLooping() has not been implemented.' );
64
71
}
65
72
66
73
/// Starts the video playback.
67
- Future <void > play (int textureId ) {
74
+ Future <void > play (int playerId ) {
68
75
throw UnimplementedError ('play() has not been implemented.' );
69
76
}
70
77
71
78
/// Stops the video playback.
72
- Future <void > pause (int textureId ) {
79
+ Future <void > pause (int playerId ) {
73
80
throw UnimplementedError ('pause() has not been implemented.' );
74
81
}
75
82
76
83
/// Sets the volume to a range between 0.0 and 1.0.
77
- Future <void > setVolume (int textureId , double volume) {
84
+ Future <void > setVolume (int playerId , double volume) {
78
85
throw UnimplementedError ('setVolume() has not been implemented.' );
79
86
}
80
87
81
88
/// Sets the video position to a [Duration] from the start.
82
- Future <void > seekTo (int textureId , Duration position) {
89
+ Future <void > seekTo (int playerId , Duration position) {
83
90
throw UnimplementedError ('seekTo() has not been implemented.' );
84
91
}
85
92
86
93
/// Sets the playback speed to a [speed] value indicating the playback rate.
87
- Future <void > setPlaybackSpeed (int textureId , double speed) {
94
+ Future <void > setPlaybackSpeed (int playerId , double speed) {
88
95
throw UnimplementedError ('setPlaybackSpeed() has not been implemented.' );
89
96
}
90
97
91
98
/// Gets the video position as [Duration] from the start.
92
- Future <Duration > getPosition (int textureId ) {
99
+ Future <Duration > getPosition (int playerId ) {
93
100
throw UnimplementedError ('getPosition() has not been implemented.' );
94
101
}
95
102
96
- /// Returns a widget displaying the video with a given textureID.
97
- Widget buildView (int textureId) {
103
+ /// Returns a widget displaying the video with a given playerId.
104
+ @Deprecated ('Use buildViewWithOptions() instead.' )
105
+ Widget buildView (int playerId) {
98
106
throw UnimplementedError ('buildView() has not been implemented.' );
99
107
}
100
108
101
- /// Sets the audio mode to mix with other sources
109
+ /// Returns a widget displaying the video based on given options.
110
+ Widget buildViewWithOptions (VideoViewOptions options) {
111
+ // Default implementation for backwards compatibility.
112
+ return buildView (options.playerId);
113
+ }
114
+
115
+ /// Sets the audio mode to mix with other sources.
102
116
Future <void > setMixWithOthers (bool mixWithOthers) {
103
117
throw UnimplementedError ('setMixWithOthers() has not been implemented.' );
104
118
}
105
119
106
- /// Sets additional options on web
107
- Future <void > setWebOptions (int textureId , VideoPlayerWebOptions options) {
120
+ /// Sets additional options on web.
121
+ Future <void > setWebOptions (int playerId , VideoPlayerWebOptions options) {
108
122
throw UnimplementedError ('setWebOptions() has not been implemented.' );
109
123
}
110
124
}
@@ -198,6 +212,15 @@ enum VideoFormat {
198
212
other,
199
213
}
200
214
215
+ /// The type of video view to be used.
216
+ enum VideoViewType {
217
+ /// Texture will be used to render video.
218
+ textureView,
219
+
220
+ /// Platform view will be used to render video.
221
+ platformView,
222
+ }
223
+
201
224
/// Event emitted from the platform implementation.
202
225
@immutable
203
226
class VideoEvent {
@@ -476,3 +499,31 @@ class VideoPlayerWebOptionsControls {
476
499
return controlsList.join (' ' );
477
500
}
478
501
}
502
+
503
+ /// [VideoViewOptions] contains configuration options for a video view.
504
+ @immutable
505
+ class VideoViewOptions {
506
+ /// Constructs an instance of [VideoViewOptions] .
507
+ const VideoViewOptions ({
508
+ required this .playerId,
509
+ });
510
+
511
+ /// The identifier of the video player.
512
+ final int playerId;
513
+ }
514
+
515
+ /// [VideoCreationOptions] contains creation options for a video player.
516
+ @immutable
517
+ class VideoCreationOptions {
518
+ /// Constructs an instance of [VideoCreationOptions] .
519
+ const VideoCreationOptions ({
520
+ required this .dataSource,
521
+ required this .viewType,
522
+ });
523
+
524
+ /// The data source used to create the player.
525
+ final DataSource dataSource;
526
+
527
+ /// The type of view to be used for displaying the video player
528
+ final VideoViewType viewType;
529
+ }
0 commit comments