@@ -44,67 +44,81 @@ abstract class VideoPlayerPlatform extends PlatformInterface {
4444 }
4545
4646 /// Clears one video.
47- Future <void > dispose (int textureId ) {
47+ Future <void > dispose (int playerId ) {
4848 throw UnimplementedError ('dispose() has not been implemented.' );
4949 }
5050
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.' )
5253 Future <int ?> create (DataSource dataSource) {
5354 throw UnimplementedError ('create() has not been implemented.' );
5455 }
5556
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+
5663 /// Returns a Stream of [VideoEventType] s.
57- Stream <VideoEvent > videoEventsFor (int textureId ) {
64+ Stream <VideoEvent > videoEventsFor (int playerId ) {
5865 throw UnimplementedError ('videoEventsFor() has not been implemented.' );
5966 }
6067
6168 /// Sets the looping attribute of the video.
62- Future <void > setLooping (int textureId , bool looping) {
69+ Future <void > setLooping (int playerId , bool looping) {
6370 throw UnimplementedError ('setLooping() has not been implemented.' );
6471 }
6572
6673 /// Starts the video playback.
67- Future <void > play (int textureId ) {
74+ Future <void > play (int playerId ) {
6875 throw UnimplementedError ('play() has not been implemented.' );
6976 }
7077
7178 /// Stops the video playback.
72- Future <void > pause (int textureId ) {
79+ Future <void > pause (int playerId ) {
7380 throw UnimplementedError ('pause() has not been implemented.' );
7481 }
7582
7683 /// 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) {
7885 throw UnimplementedError ('setVolume() has not been implemented.' );
7986 }
8087
8188 /// 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) {
8390 throw UnimplementedError ('seekTo() has not been implemented.' );
8491 }
8592
8693 /// 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) {
8895 throw UnimplementedError ('setPlaybackSpeed() has not been implemented.' );
8996 }
9097
9198 /// Gets the video position as [Duration] from the start.
92- Future <Duration > getPosition (int textureId ) {
99+ Future <Duration > getPosition (int playerId ) {
93100 throw UnimplementedError ('getPosition() has not been implemented.' );
94101 }
95102
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) {
98106 throw UnimplementedError ('buildView() has not been implemented.' );
99107 }
100108
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.
102116 Future <void > setMixWithOthers (bool mixWithOthers) {
103117 throw UnimplementedError ('setMixWithOthers() has not been implemented.' );
104118 }
105119
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) {
108122 throw UnimplementedError ('setWebOptions() has not been implemented.' );
109123 }
110124}
@@ -198,6 +212,15 @@ enum VideoFormat {
198212 other,
199213}
200214
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+
201224/// Event emitted from the platform implementation.
202225@immutable
203226class VideoEvent {
@@ -476,3 +499,31 @@ class VideoPlayerWebOptionsControls {
476499 return controlsList.join (' ' );
477500 }
478501}
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