From 58062c1605ea57f789f66d83e9539fa40ef09d9c Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Tue, 15 Sep 2020 14:56:44 +0000 Subject: [PATCH 01/17] Initial commit --- .../video_player/video_player/CHANGELOG.md | 5 + packages/video_player/video_player/README.md | 20 + .../flutter/plugins/videoplayer/Messages.java | 352 +++++++++++------- .../plugins/videoplayer/VideoPlayer.java | 9 + .../videoplayer/VideoPlayerPlugin.java | 6 + .../video_player/example/lib/main.dart | 33 +- .../ios/Classes/FLTVideoPlayerPlugin.m | 29 ++ .../video_player/ios/Classes/messages.h | 10 +- .../video_player/ios/Classes/messages.m | 72 +++- .../video_player/lib/video_player.dart | 62 ++- .../video_player/pigeons/messages.dart | 6 + .../video_player/video_player/pubspec.yaml | 5 +- .../video_player/test/video_player_test.dart | 84 ++++- .../CHANGELOG.md | 4 + .../lib/messages.dart | 183 ++++----- .../lib/method_channel_video_player.dart | 9 + .../lib/video_player_platform_interface.dart | 9 +- .../pubspec.yaml | 2 +- .../method_channel_video_player_test.dart | 19 +- .../video_player_web/CHANGELOG.md | 4 + .../lib/video_player_web.dart | 13 + .../video_player_web/pubspec.yaml | 2 +- .../test/video_player_web_test.dart | 8 +- 23 files changed, 639 insertions(+), 307 deletions(-) diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index 35f50419f823..6e30b7406007 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.11.0 + +* Added option to set the video playback speed on the video controller. +* **Minor breaking change**: fixed `VideoPlayerValue.toString` to insert a comma after `isBuffering`. + ## 0.10.12+2 * Fix `setMixWithOthers` test. diff --git a/packages/video_player/video_player/README.md b/packages/video_player/video_player/README.md index ef522a455c21..fa86ace9c7dc 100644 --- a/packages/video_player/video_player/README.md +++ b/packages/video_player/video_player/README.md @@ -127,3 +127,23 @@ class _VideoAppState extends State { } } ``` + +## Usage + +The following section contains usage information that goes beyond what is included in the +documentation in order to give a more elaborate overview of the API. + +This is not complete as of now. You can contribute to this section by [opening a pull request](https://github.com/flutter/plugins/pulls). + +### Playback speed + +You can set the playback speed on your `_controller` (instance of `VideoPlayerController`) by +calling `_controller.setPlaybackSpeed`. `setPlaybackSpeed` takes a `double` speed value indicating +the rate of playback for your video. +For example, when given a value of `2.0`, your video will play at 2x the regular playback speed +and so on. + +See the documentation for how different values for the playback speed are handled on the different +platforms. + +Furthermore, see the example app to see an example playback speed implementation. diff --git a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java index 003ca18f23cb..6ebed7aaf68e 100644 --- a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java +++ b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.0-experimental.11), do not edit directly. +// Autogenerated from Pigeon (v0.1.5), do not edit directly. // See also: https://pub.dev/packages/pigeon package io.flutter.plugins.videoplayer; @@ -9,6 +9,7 @@ import java.util.HashMap; /** Generated class from Pigeon. */ +@SuppressWarnings("unused") public class Messages { /** Generated class from Pigeon that represents data sent in messages. */ @@ -24,17 +25,18 @@ public void setTextureId(Long setterArg) { } HashMap toMap() { - HashMap toMapResult = new HashMap(); + HashMap toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); return toMapResult; } static TextureMessage fromMap(HashMap map) { TextureMessage fromMapResult = new TextureMessage(); + Object textureId = map.get("textureId"); fromMapResult.textureId = - (map.get("textureId") instanceof Integer) - ? (Integer) map.get("textureId") - : (Long) map.get("textureId"); + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); return fromMapResult; } } @@ -82,7 +84,7 @@ public void setFormatHint(String setterArg) { } HashMap toMap() { - HashMap toMapResult = new HashMap(); + HashMap toMapResult = new HashMap<>(); toMapResult.put("asset", asset); toMapResult.put("uri", uri); toMapResult.put("packageName", packageName); @@ -92,10 +94,14 @@ HashMap toMap() { static CreateMessage fromMap(HashMap map) { CreateMessage fromMapResult = new CreateMessage(); - fromMapResult.asset = (String) map.get("asset"); - fromMapResult.uri = (String) map.get("uri"); - fromMapResult.packageName = (String) map.get("packageName"); - fromMapResult.formatHint = (String) map.get("formatHint"); + Object asset = map.get("asset"); + fromMapResult.asset = (String) asset; + Object uri = map.get("uri"); + fromMapResult.uri = (String) uri; + Object packageName = map.get("packageName"); + fromMapResult.packageName = (String) packageName; + Object formatHint = map.get("formatHint"); + fromMapResult.formatHint = (String) formatHint; return fromMapResult; } } @@ -123,7 +129,7 @@ public void setIsLooping(Boolean setterArg) { } HashMap toMap() { - HashMap toMapResult = new HashMap(); + HashMap toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); toMapResult.put("isLooping", isLooping); return toMapResult; @@ -131,11 +137,13 @@ HashMap toMap() { static LoopingMessage fromMap(HashMap map) { LoopingMessage fromMapResult = new LoopingMessage(); + Object textureId = map.get("textureId"); fromMapResult.textureId = - (map.get("textureId") instanceof Integer) - ? (Integer) map.get("textureId") - : (Long) map.get("textureId"); - fromMapResult.isLooping = (Boolean) map.get("isLooping"); + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + Object isLooping = map.get("isLooping"); + fromMapResult.isLooping = (Boolean) isLooping; return fromMapResult; } } @@ -163,7 +171,7 @@ public void setVolume(Double setterArg) { } HashMap toMap() { - HashMap toMapResult = new HashMap(); + HashMap toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); toMapResult.put("volume", volume); return toMapResult; @@ -171,11 +179,55 @@ HashMap toMap() { static VolumeMessage fromMap(HashMap map) { VolumeMessage fromMapResult = new VolumeMessage(); + Object textureId = map.get("textureId"); fromMapResult.textureId = - (map.get("textureId") instanceof Integer) - ? (Integer) map.get("textureId") - : (Long) map.get("textureId"); - fromMapResult.volume = (Double) map.get("volume"); + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + Object volume = map.get("volume"); + fromMapResult.volume = (Double) volume; + return fromMapResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class PlaybackSpeedMessage { + private Long textureId; + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } + + private Double speed; + + public Double getSpeed() { + return speed; + } + + public void setSpeed(Double setterArg) { + this.speed = setterArg; + } + + HashMap toMap() { + HashMap toMapResult = new HashMap<>(); + toMapResult.put("textureId", textureId); + toMapResult.put("speed", speed); + return toMapResult; + } + + static PlaybackSpeedMessage fromMap(HashMap map) { + PlaybackSpeedMessage fromMapResult = new PlaybackSpeedMessage(); + Object textureId = map.get("textureId"); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + Object speed = map.get("speed"); + fromMapResult.speed = (Double) speed; return fromMapResult; } } @@ -203,7 +255,7 @@ public void setPosition(Long setterArg) { } HashMap toMap() { - HashMap toMapResult = new HashMap(); + HashMap toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); toMapResult.put("position", position); return toMapResult; @@ -211,14 +263,16 @@ HashMap toMap() { static PositionMessage fromMap(HashMap map) { PositionMessage fromMapResult = new PositionMessage(); + Object textureId = map.get("textureId"); fromMapResult.textureId = - (map.get("textureId") instanceof Integer) - ? (Integer) map.get("textureId") - : (Long) map.get("textureId"); + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + Object position = map.get("position"); fromMapResult.position = - (map.get("position") instanceof Integer) - ? (Integer) map.get("position") - : (Long) map.get("position"); + (position == null) + ? null + : ((position instanceof Integer) ? (Integer) position : (Long) position); return fromMapResult; } } @@ -236,14 +290,15 @@ public void setMixWithOthers(Boolean setterArg) { } HashMap toMap() { - HashMap toMapResult = new HashMap(); + HashMap toMapResult = new HashMap<>(); toMapResult.put("mixWithOthers", mixWithOthers); return toMapResult; } static MixWithOthersMessage fromMap(HashMap map) { MixWithOthersMessage fromMapResult = new MixWithOthersMessage(); - fromMapResult.mixWithOthers = (Boolean) map.get("mixWithOthers"); + Object mixWithOthers = map.get("mixWithOthers"); + fromMapResult.mixWithOthers = (Boolean) mixWithOthers; return fromMapResult; } } @@ -260,6 +315,8 @@ public interface VideoPlayerApi { void setVolume(VolumeMessage arg); + void setPlaybackSpeed(PlaybackSpeedMessage arg); + void play(TextureMessage arg); PositionMessage position(TextureMessage arg); @@ -271,26 +328,24 @@ public interface VideoPlayerApi { void setMixWithOthers(MixWithOthersMessage arg); /** Sets up an instance of `VideoPlayerApi` to handle messages through the `binaryMessenger` */ - public static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { + static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.initialize", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { - HashMap wrapped = new HashMap(); - try { - api.initialize(); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + api.initialize(); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -298,24 +353,23 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.create", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") CreateMessage input = CreateMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - TextureMessage output = api.create(input); - wrapped.put("result", output.toMap()); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + TextureMessage output = api.create(input); + wrapped.put("result", output.toMap()); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -323,24 +377,23 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.dispose", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") TextureMessage input = TextureMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - api.dispose(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + api.dispose(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -348,24 +401,23 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setLooping", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") LoopingMessage input = LoopingMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - api.setLooping(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + api.setLooping(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -373,24 +425,47 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setVolume", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") VolumeMessage input = VolumeMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - api.setVolume(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + api.setVolume(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", + new StandardMessageCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap) message); + api.setPlaybackSpeed(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -398,24 +473,23 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.play", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") TextureMessage input = TextureMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - api.play(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + api.play(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -423,24 +497,23 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.position", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") TextureMessage input = TextureMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - PositionMessage output = api.position(input); - wrapped.put("result", output.toMap()); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + PositionMessage output = api.position(input); + wrapped.put("result", output.toMap()); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -448,24 +521,23 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.seekTo", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") PositionMessage input = PositionMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - api.seekTo(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + api.seekTo(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -473,24 +545,23 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.pause", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") TextureMessage input = TextureMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - api.pause(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + api.pause(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -498,24 +569,23 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } { BasicMessageChannel channel = - new BasicMessageChannel( + new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", new StandardMessageCodec()); if (api != null) { channel.setMessageHandler( - new BasicMessageChannel.MessageHandler() { - public void onMessage(Object message, BasicMessageChannel.Reply reply) { + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap) message); - HashMap wrapped = new HashMap(); - try { - api.setMixWithOthers(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); + api.setMixWithOthers(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); } + reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -525,7 +595,7 @@ public void onMessage(Object message, BasicMessageChannel.Reply reply) { } private static HashMap wrapError(Exception exception) { - HashMap errorMap = new HashMap(); + HashMap errorMap = new HashMap<>(); errorMap.put("message", exception.toString()); errorMap.put("code", null); errorMap.put("details", null); diff --git a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java index 801c2ca3bff2..8f8c898dea27 100644 --- a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java +++ b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java @@ -11,6 +11,7 @@ import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.Format; +import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player.EventListener; import com.google.android.exoplayer2.SimpleExoPlayer; @@ -233,6 +234,14 @@ void setVolume(double value) { exoPlayer.setVolume(bracketedValue); } + void setPlaybackSpeed(double value) { + // We do not need to consider pitch and skipSilence for now as we do not handle them and + // therefore never diverge from the default values. + final PlaybackParameters playbackParameters = new PlaybackParameters(((float) value)); + + exoPlayer.setPlaybackParameters(playbackParameters); + } + void seekTo(int location) { exoPlayer.seekTo(location); } diff --git a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java index a22a4f2d7ae4..c93232f30b2d 100644 --- a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java +++ b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java @@ -14,6 +14,7 @@ import io.flutter.plugins.videoplayer.Messages.CreateMessage; import io.flutter.plugins.videoplayer.Messages.LoopingMessage; import io.flutter.plugins.videoplayer.Messages.MixWithOthersMessage; +import io.flutter.plugins.videoplayer.Messages.PlaybackSpeedMessage; import io.flutter.plugins.videoplayer.Messages.PositionMessage; import io.flutter.plugins.videoplayer.Messages.TextureMessage; import io.flutter.plugins.videoplayer.Messages.VideoPlayerApi; @@ -151,6 +152,11 @@ public void setVolume(VolumeMessage arg) { player.setVolume(arg.getVolume()); } + public void setPlaybackSpeed(PlaybackSpeedMessage arg) { + VideoPlayer player = videoPlayers.get(arg.getTextureId()); + player.setPlaybackSpeed(arg.getSpeed()); + } + public void play(TextureMessage arg) { VideoPlayer player = videoPlayers.get(arg.getTextureId()); player.play(); diff --git a/packages/video_player/video_player/example/lib/main.dart b/packages/video_player/video_player/example/lib/main.dart index ee2fcbdc9632..d595910425c3 100644 --- a/packages/video_player/video_player/example/lib/main.dart +++ b/packages/video_player/video_player/example/lib/main.dart @@ -188,7 +188,7 @@ class _ButterFlyAssetVideoState extends State<_ButterFlyAssetVideo> { alignment: Alignment.bottomCenter, children: [ VideoPlayer(_controller), - _PlayPauseOverlay(controller: _controller), + _ControlsOverlay(controller: _controller), VideoProgressIndicator(_controller, allowScrubbing: true), ], ), @@ -252,7 +252,7 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> { children: [ VideoPlayer(_controller), ClosedCaption(text: _controller.value.caption.text), - _PlayPauseOverlay(controller: _controller), + _ControlsOverlay(controller: _controller), VideoProgressIndicator(_controller, allowScrubbing: true), ], ), @@ -264,8 +264,19 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> { } } -class _PlayPauseOverlay extends StatelessWidget { - const _PlayPauseOverlay({Key key, this.controller}) : super(key: key); +class _ControlsOverlay extends StatelessWidget { + const _ControlsOverlay({Key key, this.controller}) : super(key: key); + + static const _examplePlaybackRates = [ + 0.25, + 0.5, + 1.0, + 1.5, + 2.0, + 3.0, + 5.0, + 10.0, + ]; final VideoPlayerController controller; @@ -294,6 +305,20 @@ class _PlayPauseOverlay extends StatelessWidget { controller.value.isPlaying ? controller.pause() : controller.play(); }, ), + Align( + alignment: Alignment.topRight, + child: FlatButton( + onPressed: () { + final currentIndex = _examplePlaybackRates + .indexOf(controller.value.playbackSpeed), + nextIndex = (currentIndex + 1) % _examplePlaybackRates.length; + + // Go through all provided example playback rates. + controller.setPlaybackSpeed(_examplePlaybackRates[nextIndex]); + }, + child: Text('${controller.value.playbackSpeed}x'), + ), + ), ], ); } diff --git a/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m b/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m index a834fe32b87b..e6a4f6ccb0b7 100644 --- a/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m +++ b/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m @@ -359,6 +359,30 @@ - (void)setVolume:(double)volume { _player.volume = (float)((volume < 0.0) ? 0.0 : ((volume > 1.0) ? 1.0 : volume)); } +- (void)setPlaybackSpeed:(double)speed { + // See https://developer.apple.com/library/archive/qa/qa1772/_index.html for an explanation of + // these checks. + if (speed > 2.0 && !_player.currentItem.canPlayFastForward) { + if (_eventSink != nil) { + _eventSink([FlutterError errorWithCode:@"VideoError" + message:@"Video cannot be fast-forwarded beyond 2.0x" + details:nil]); + } + return; + } + + if (speed < 1.0 && !_player.currentItem.canPlaySlowForward) { + if (_eventSink != nil) { + _eventSink([FlutterError errorWithCode:@"VideoError" + message:@"Video cannot be slow-forwarded" + details:nil]); + } + return; + } + + _player.rate = speed; +} + - (CVPixelBufferRef)copyPixelBuffer { CMTime outputItemTime = [_videoOutput itemTimeForHostTime:CACurrentMediaTime()]; if ([_videoOutput hasNewPixelBufferForItemTime:outputItemTime]) { @@ -538,6 +562,11 @@ - (void)setVolume:(FLTVolumeMessage*)input error:(FlutterError**)error { [player setVolume:[input.volume doubleValue]]; } +- (void)setPlaybackSpeed:(FLTPlaybackSpeedMessage*)input error:(FlutterError**)error { + FLTVideoPlayer* player = _players[input.textureId]; + [player setPlaybackSpeed:[input.speed doubleValue]]; +} + - (void)play:(FLTTextureMessage*)input error:(FlutterError**)error { FLTVideoPlayer* player = _players[input.textureId]; [player play]; diff --git a/packages/video_player/video_player/ios/Classes/messages.h b/packages/video_player/video_player/ios/Classes/messages.h index 27025ef27413..49239168e3ad 100644 --- a/packages/video_player/video_player/ios/Classes/messages.h +++ b/packages/video_player/video_player/ios/Classes/messages.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.0-experimental.11), do not edit directly. +// Autogenerated from Pigeon (v0.1.5), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @protocol FlutterBinaryMessenger; @@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN @class FLTCreateMessage; @class FLTLoopingMessage; @class FLTVolumeMessage; +@class FLTPlaybackSpeedMessage; @class FLTPositionMessage; @class FLTMixWithOthersMessage; @@ -35,6 +36,11 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong, nullable) NSNumber *volume; @end +@interface FLTPlaybackSpeedMessage : NSObject +@property(nonatomic, strong, nullable) NSNumber *textureId; +@property(nonatomic, strong, nullable) NSNumber *speed; +@end + @interface FLTPositionMessage : NSObject @property(nonatomic, strong, nullable) NSNumber *textureId; @property(nonatomic, strong, nullable) NSNumber *position; @@ -51,6 +57,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)dispose:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; - (void)setLooping:(FLTLoopingMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; - (void)setVolume:(FLTVolumeMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setPlaybackSpeed:(FLTPlaybackSpeedMessage *)input + error:(FlutterError *_Nullable *_Nonnull)error; - (void)play:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; - (nullable FLTPositionMessage *)position:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; diff --git a/packages/video_player/video_player/ios/Classes/messages.m b/packages/video_player/video_player/ios/Classes/messages.m index 64fcd75cc6bf..a560c8d9ab82 100644 --- a/packages/video_player/video_player/ios/Classes/messages.m +++ b/packages/video_player/video_player/ios/Classes/messages.m @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.0-experimental.11), do not edit directly. +// Autogenerated from Pigeon (v0.1.5), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.h" #import @@ -36,6 +36,10 @@ @interface FLTVolumeMessage () + (FLTVolumeMessage *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @end +@interface FLTPlaybackSpeedMessage () ++ (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end @interface FLTPositionMessage () + (FLTPositionMessage *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @@ -55,9 +59,9 @@ + (FLTTextureMessage *)fromMap:(NSDictionary *)dict { return result; } - (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]), - @"textureId", nil]; + return + [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), + @"textureId", nil]; } @end @@ -86,9 +90,9 @@ - (NSDictionary *)toMap { return [NSDictionary dictionaryWithObjectsAndKeys:(self.asset ? self.asset : [NSNull null]), @"asset", (self.uri ? self.uri : [NSNull null]), @"uri", - (self.packageName != nil ? self.packageName : [NSNull null]), + (self.packageName ? self.packageName : [NSNull null]), @"packageName", - (self.formatHint != nil ? self.formatHint : [NSNull null]), + (self.formatHint ? self.formatHint : [NSNull null]), @"formatHint", nil]; } @end @@ -108,10 +112,9 @@ + (FLTLoopingMessage *)fromMap:(NSDictionary *)dict { } - (NSDictionary *)toMap { return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]), - @"textureId", - (self.isLooping != nil ? self.isLooping : [NSNull null]), - @"isLooping", nil]; + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.isLooping ? self.isLooping : [NSNull null]), @"isLooping", + nil]; } @end @@ -130,9 +133,28 @@ + (FLTVolumeMessage *)fromMap:(NSDictionary *)dict { } - (NSDictionary *)toMap { return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]), - @"textureId", (self.volume != nil ? self.volume : [NSNull null]), - @"volume", nil]; + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.volume ? self.volume : [NSNull null]), @"volume", nil]; +} +@end + +@implementation FLTPlaybackSpeedMessage ++ (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict { + FLTPlaybackSpeedMessage *result = [[FLTPlaybackSpeedMessage alloc] init]; + result.textureId = dict[@"textureId"]; + if ((NSNull *)result.textureId == [NSNull null]) { + result.textureId = nil; + } + result.speed = dict[@"speed"]; + if ((NSNull *)result.speed == [NSNull null]) { + result.speed = nil; + } + return result; +} +- (NSDictionary *)toMap { + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.speed ? self.speed : [NSNull null]), @"speed", nil]; } @end @@ -151,10 +173,9 @@ + (FLTPositionMessage *)fromMap:(NSDictionary *)dict { } - (NSDictionary *)toMap { return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]), - @"textureId", - (self.position != nil ? self.position : [NSNull null]), - @"position", nil]; + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.position ? self.position : [NSNull null]), @"position", + nil]; } @end @@ -169,7 +190,7 @@ + (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict { } - (NSDictionary *)toMap { return [NSDictionary - dictionaryWithObjectsAndKeys:(self.mixWithOthers != nil ? self.mixWithOthers : [NSNull null]), + dictionaryWithObjectsAndKeys:(self.mixWithOthers ? self.mixWithOthers : [NSNull null]), @"mixWithOthers", nil]; } @end @@ -249,6 +270,21 @@ void FLTVideoPlayerApiSetup(id binaryMessenger, id { initializingCompleter.complete(null); _applyLooping(); _applyVolume(); + _applyPlaybackSpeed(); _applyPlayPause(); break; case VideoEventType.completed: @@ -397,6 +405,11 @@ class VideoPlayerController extends ValueNotifier { _updatePosition(newPosition); }, ); + + // This ensures that the correct playback speed is always applied when + // playing back. This is necessary because we do not set playback speed + // when paused. + await _applyPlaybackSpeed(); } else { _timer?.cancel(); await _videoPlayerPlatform.pause(_textureId); @@ -410,6 +423,22 @@ class VideoPlayerController extends ValueNotifier { await _videoPlayerPlatform.setVolume(_textureId, value.volume); } + Future _applyPlaybackSpeed() async { + if (!value.initialized || _isDisposed) { + return; + } + + // Setting the playback speed on iOS will trigger the video to play. We + // prevent this from happening by not applying the playback speed until + // the video is manually played from Flutter. + if (!value.isPlaying) return; + + await _videoPlayerPlatform.setPlaybackSpeed( + _textureId, + value.playbackSpeed, + ); + } + /// The position in the current video. Future get position async { if (_isDisposed) { @@ -445,6 +474,33 @@ class VideoPlayerController extends ValueNotifier { await _applyVolume(); } + /// Sets the playback speed of [this]. + /// + /// [speed] indicates a speed value with different platforms accepting + /// different ranges for speed values (that must not be negative). + /// The values will be handled as follows: + /// * On web, no exceptions will be thrown, however, different browser + /// implementations will e.g. mute audio. + /// "Gecko mutes the sound outside the range `0.25` to `5.0`" (see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate). + /// * On iOS, you can sometimes not go above `2.0` playback speed on a video. + /// An error will be thrown for if the option is unsupported. It is also + /// possible that your specific video cannot be slowed down, in which case + /// the plugin also reports errors. + /// * On Android, the handling is similar to web, where the plugin will not + /// report any errors, however, you cannot expect support for all speed + /// values (even though it should go way above `2.0`). + Future setPlaybackSpeed(double speed) async { + if (speed < 0) { + throw ArgumentError.value( + speed, + 'Negative playback speeds are generally unsupported.', + ); + } + + value = value.copyWith(playbackSpeed: speed); + await _applyPlaybackSpeed(); + } + /// The closed caption based on the current [position] in the video. /// /// If there are no closed captions at the current [position], this will diff --git a/packages/video_player/video_player/pigeons/messages.dart b/packages/video_player/video_player/pigeons/messages.dart index 074eef023b94..4415ff745bdd 100644 --- a/packages/video_player/video_player/pigeons/messages.dart +++ b/packages/video_player/video_player/pigeons/messages.dart @@ -14,6 +14,11 @@ class VolumeMessage { double volume; } +class PlaybackSpeedMessage { + int textureId; + double speed; +} + class PositionMessage { int textureId; int position; @@ -37,6 +42,7 @@ abstract class VideoPlayerApi { void dispose(TextureMessage msg); void setLooping(LoopingMessage msg); void setVolume(VolumeMessage msg); + void setPlaybackSpeed(PlaybackSpeedMessage msg); void play(TextureMessage msg); PositionMessage position(TextureMessage msg); void seekTo(PositionMessage msg); diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 04c7c6ba3ddb..be7a8520a985 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter # 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump # the version to 2.0.0. # See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 -version: 0.10.12+2 +version: 0.11.0 homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player flutter: @@ -21,6 +21,7 @@ flutter: dependencies: meta: ^1.0.5 video_player_platform_interface: ^2.1.0 + # The design on https://flutter.dev/go/federated-plugins was to leave # this constraint as "any". We cannot do it right now as it fails pub publish # validation, so we set a ^ constraint. @@ -35,7 +36,7 @@ dev_dependencies: flutter_test: sdk: flutter pedantic: ^1.8.0 - pigeon: 0.1.0-experimental.11 + pigeon: 0.1.5 environment: sdk: ">=2.1.0 <3.0.0" diff --git a/packages/video_player/video_player/test/video_player_test.dart b/packages/video_player/video_player/test/video_player_test.dart index f2d4c35a1ce8..e9f4e47d2ddc 100644 --- a/packages/video_player/video_player/test/video_player_test.dart +++ b/packages/video_player/video_player/test/video_player_test.dart @@ -4,12 +4,13 @@ import 'dart:async'; import 'dart:io'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; -import 'package:video_player/video_player.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:video_player/video_player.dart'; import 'package:video_player_platform_interface/messages.dart'; import 'package:video_player_platform_interface/video_player_platform_interface.dart'; @@ -27,23 +28,34 @@ class FakeController extends ValueNotifier @override String get dataSource => ''; + @override DataSourceType get dataSourceType => DataSourceType.file; + @override String get package => null; + @override Future get position async => value.position; @override Future seekTo(Duration moment) async {} + @override Future setVolume(double volume) async {} + + @override + Future setPlaybackSpeed(double speed) async {} + @override Future initialize() async {} + @override Future pause() async {} + @override Future play() async {} + @override Future setLooping(bool looping) async {} @@ -335,6 +347,31 @@ void main() { }); }); + group('setPlaybackSpeed', () { + test('works', () async { + final VideoPlayerController controller = VideoPlayerController.network( + 'https://127.0.0.1', + ); + await controller.initialize(); + expect(controller.value.playbackSpeed, 1.0); + + const double speed = 1.5; + await controller.setPlaybackSpeed(speed); + + expect(controller.value.playbackSpeed, speed); + }); + + test('rejects negative values', () async { + final VideoPlayerController controller = VideoPlayerController.network( + 'https://127.0.0.1', + ); + await controller.initialize(); + expect(controller.value.playbackSpeed, 1.0); + + expect(() => controller.setPlaybackSpeed(-1), throwsArgumentError); + }); + }); + group('caption', () { test('works when seeking', () async { final VideoPlayerController controller = VideoPlayerController.network( @@ -458,6 +495,7 @@ void main() { expect(uninitialized.isLooping, isFalse); expect(uninitialized.isBuffering, isFalse); expect(uninitialized.volume, 1.0); + expect(uninitialized.playbackSpeed, 1.0); expect(uninitialized.errorDescription, isNull); expect(uninitialized.size, isNull); expect(uninitialized.size, isNull); @@ -478,6 +516,7 @@ void main() { expect(error.isLooping, isFalse); expect(error.isBuffering, isFalse); expect(error.volume, 1.0); + expect(error.playbackSpeed, 1.0); expect(error.errorDescription, errorMessage); expect(error.size, isNull); expect(error.size, isNull); @@ -498,20 +537,34 @@ void main() { const bool isLooping = true; const bool isBuffering = true; const double volume = 0.5; + const double playbackSpeed = 1.5; final VideoPlayerValue value = VideoPlayerValue( - duration: duration, - size: size, - position: position, - caption: caption, - buffered: buffered, - isPlaying: isPlaying, - isLooping: isLooping, - isBuffering: isBuffering, - volume: volume); - - expect(value.toString(), - 'VideoPlayerValue(duration: 0:00:05.000000, size: Size(400.0, 300.0), position: 0:00:01.000000, caption: Instance of \'Caption\', buffered: [DurationRange(start: 0:00:00.000000, end: 0:00:04.000000)], isPlaying: true, isLooping: true, isBuffering: truevolume: 0.5, errorDescription: null)'); + duration: duration, + size: size, + position: position, + caption: caption, + buffered: buffered, + isPlaying: isPlaying, + isLooping: isLooping, + isBuffering: isBuffering, + volume: volume, + playbackSpeed: playbackSpeed, + ); + + expect( + value.toString(), + 'VideoPlayerValue(duration: 0:00:05.000000, ' + 'size: Size(400.0, 300.0), ' + 'position: 0:00:01.000000, ' + 'caption: Instance of \'Caption\', ' + 'buffered: [DurationRange(start: 0:00:00.000000, end: 0:00:04.000000)], ' + 'isPlaying: true, ' + 'isLooping: true, ' + 'isBuffering: true, ' + 'volume: 0.5, ' + 'playbackSpeed: 1.5, ' + 'errorDescription: null)'); }); test('copyWith()', () { @@ -657,6 +710,11 @@ class FakeVideoPlayerPlatform extends VideoPlayerApiTest { calls.add('setVolume'); } + @override + void setPlaybackSpeed(PlaybackSpeedMessage arg) { + calls.add('setPlaybackSpeed'); + } + @override void setMixWithOthers(MixWithOthersMessage arg) { calls.add('setMixWithOthers'); diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index 2af6f01ffe88..8af22f783675 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.2.0 + +* Added option to set the video playback speed on the video controller. + ## 2.1.1 * Fix mixWithOthers test channel. diff --git a/packages/video_player/video_player_platform_interface/lib/messages.dart b/packages/video_player/video_player_platform_interface/lib/messages.dart index c5e8cd413b70..e1003adc71cc 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -1,8 +1,9 @@ -// Autogenerated from Pigeon (v0.1.0-experimental.11), do not edit directly. +// Autogenerated from Pigeon (v0.1.5), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import import 'dart:async'; import 'package:flutter/services.dart'; +import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; class TextureMessage { int textureId; @@ -15,6 +16,9 @@ class TextureMessage { // ignore: unused_element static TextureMessage _fromMap(Map pigeonMap) { + if (pigeonMap == null) { + return null; + } final TextureMessage result = TextureMessage(); result.textureId = pigeonMap['textureId']; return result; @@ -38,6 +42,9 @@ class CreateMessage { // ignore: unused_element static CreateMessage _fromMap(Map pigeonMap) { + if (pigeonMap == null) { + return null; + } final CreateMessage result = CreateMessage(); result.asset = pigeonMap['asset']; result.uri = pigeonMap['uri']; @@ -60,6 +67,9 @@ class LoopingMessage { // ignore: unused_element static LoopingMessage _fromMap(Map pigeonMap) { + if (pigeonMap == null) { + return null; + } final LoopingMessage result = LoopingMessage(); result.textureId = pigeonMap['textureId']; result.isLooping = pigeonMap['isLooping']; @@ -80,6 +90,9 @@ class VolumeMessage { // ignore: unused_element static VolumeMessage _fromMap(Map pigeonMap) { + if (pigeonMap == null) { + return null; + } final VolumeMessage result = VolumeMessage(); result.textureId = pigeonMap['textureId']; result.volume = pigeonMap['volume']; @@ -87,6 +100,29 @@ class VolumeMessage { } } +class PlaybackSpeedMessage { + int textureId; + double speed; + // ignore: unused_element + Map _toMap() { + final Map pigeonMap = {}; + pigeonMap['textureId'] = textureId; + pigeonMap['speed'] = speed; + return pigeonMap; + } + + // ignore: unused_element + static PlaybackSpeedMessage _fromMap(Map pigeonMap) { + if (pigeonMap == null) { + return null; + } + final PlaybackSpeedMessage result = PlaybackSpeedMessage(); + result.textureId = pigeonMap['textureId']; + result.speed = pigeonMap['speed']; + return result; + } +} + class PositionMessage { int textureId; int position; @@ -100,6 +136,9 @@ class PositionMessage { // ignore: unused_element static PositionMessage _fromMap(Map pigeonMap) { + if (pigeonMap == null) { + return null; + } final PositionMessage result = PositionMessage(); result.textureId = pigeonMap['textureId']; result.position = pigeonMap['position']; @@ -118,128 +157,15 @@ class MixWithOthersMessage { // ignore: unused_element static MixWithOthersMessage _fromMap(Map pigeonMap) { + if (pigeonMap == null) { + return null; + } final MixWithOthersMessage result = MixWithOthersMessage(); result.mixWithOthers = pigeonMap['mixWithOthers']; return result; } } -abstract class VideoPlayerApiTest { - void initialize(); - TextureMessage create(CreateMessage arg); - void dispose(TextureMessage arg); - void setLooping(LoopingMessage arg); - void setVolume(VolumeMessage arg); - void play(TextureMessage arg); - PositionMessage position(TextureMessage arg); - void seekTo(PositionMessage arg); - void pause(TextureMessage arg); - void setMixWithOthers(MixWithOthersMessage arg); -} - -void VideoPlayerApiTestSetup(VideoPlayerApiTest api) { - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - api.initialize(); - return {}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final CreateMessage input = CreateMessage._fromMap(mapMessage); - final TextureMessage output = api.create(input); - return {'result': output._toMap()}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final TextureMessage input = TextureMessage._fromMap(mapMessage); - api.dispose(input); - return {}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final LoopingMessage input = LoopingMessage._fromMap(mapMessage); - api.setLooping(input); - return {}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final VolumeMessage input = VolumeMessage._fromMap(mapMessage); - api.setVolume(input); - return {}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final TextureMessage input = TextureMessage._fromMap(mapMessage); - api.play(input); - return {}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final TextureMessage input = TextureMessage._fromMap(mapMessage); - final PositionMessage output = api.position(input); - return {'result': output._toMap()}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final PositionMessage input = PositionMessage._fromMap(mapMessage); - api.seekTo(input); - return {}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final TextureMessage input = TextureMessage._fromMap(mapMessage); - api.pause(input); - return {}; - }); - } - { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', - StandardMessageCodec()); - channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final MixWithOthersMessage input = - MixWithOthersMessage._fromMap(mapMessage); - api.setMixWithOthers(input); - return {}; - }); - } -} - class VideoPlayerApi { Future initialize() async { const BasicMessageChannel channel = BasicMessageChannel( @@ -350,6 +276,29 @@ class VideoPlayerApi { } } + Future setPlaybackSpeed(PlaybackSpeedMessage arg) async { + final Map requestMap = arg._toMap(); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', + StandardMessageCodec()); + + final Map replyMap = await channel.send(requestMap); + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); + } else if (replyMap['error'] != null) { + final Map error = replyMap['error']; + throw PlatformException( + code: error['code'], + message: error['message'], + details: error['details']); + } else { + // noop + } + } + Future play(TextureMessage arg) async { final Map requestMap = arg._toMap(); const BasicMessageChannel channel = BasicMessageChannel( diff --git a/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart b/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart index 8c0f1de39661..d28d7ddea8df 100644 --- a/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart +++ b/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart @@ -71,6 +71,15 @@ class MethodChannelVideoPlayer extends VideoPlayerPlatform { ..volume = volume); } + @override + Future setPlaybackSpeed(int textureId, double speed) { + assert(speed >= 0); + + return _api.setPlaybackSpeed(PlaybackSpeedMessage() + ..textureId = textureId + ..speed = speed); + } + @override Future seekTo(int textureId, Duration position) { return _api.seekTo(PositionMessage() diff --git a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart index 279810aaaf63..2757fb135af6 100644 --- a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart +++ b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart @@ -100,6 +100,11 @@ abstract class VideoPlayerPlatform { throw UnimplementedError('seekTo() has not been implemented.'); } + /// Sets the playback speed to a [speed] value indicating the playback rate. + Future setPlaybackSpeed(int textureId, double speed) { + throw UnimplementedError('setPlaybackSpeed() has not been implemented.'); + } + /// Gets the video position as [Duration] from the start. Future getPosition(int textureId) { throw UnimplementedError('getPosition() has not been implemented.'); @@ -184,7 +189,7 @@ enum DataSourceType { network, /// The video was loaded off of the local filesystem. - file + file, } /// The file format of the given video. @@ -199,7 +204,7 @@ enum VideoFormat { ss, /// Any format other than the other ones defined in this enum. - other + other, } /// Event emitted from the platform implementation. diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index 38bc6851f376..4b61245653fc 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the video_player plugin. homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.1.1 +version: 2.2.0 dependencies: flutter: diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart index 185953163350..3917bd5485b3 100644 --- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart +++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart @@ -4,13 +4,12 @@ import 'dart:ui'; -import 'package:mockito/mockito.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; - +import 'package:mockito/mockito.dart'; +import 'package:video_player_platform_interface/messages.dart'; import 'package:video_player_platform_interface/method_channel_video_player.dart'; import 'package:video_player_platform_interface/video_player_platform_interface.dart'; -import 'package:video_player_platform_interface/messages.dart'; class _ApiLogger implements VideoPlayerApiTest { final List log = []; @@ -19,6 +18,7 @@ class _ApiLogger implements VideoPlayerApiTest { PositionMessage positionMessage; LoopingMessage loopingMessage; VolumeMessage volumeMessage; + PlaybackSpeedMessage playbackSpeedMessage; MixWithOthersMessage mixWithOthersMessage; @override @@ -81,6 +81,12 @@ class _ApiLogger implements VideoPlayerApiTest { log.add('setVolume'); volumeMessage = arg; } + + @override + void setPlaybackSpeed(PlaybackSpeedMessage arg) { + log.add('setPlaybackSpeed'); + playbackSpeedMessage = arg; + } } void main() { @@ -203,6 +209,13 @@ void main() { expect(log.volumeMessage.volume, 0.7); }); + test('setPlaybackSpeed', () async { + await player.setPlaybackSpeed(1, 1.5); + expect(log.log.last, 'setPlaybackSpeed'); + expect(log.playbackSpeedMessage.textureId, 1); + expect(log.playbackSpeedMessage.speed, 1.5); + }); + test('seekTo', () async { await player.seekTo(1, const Duration(milliseconds: 12345)); expect(log.log.last, 'seekTo'); diff --git a/packages/video_player/video_player_web/CHANGELOG.md b/packages/video_player/video_player_web/CHANGELOG.md index 9c500e951122..d18504913d89 100644 --- a/packages/video_player/video_player_web/CHANGELOG.md +++ b/packages/video_player/video_player_web/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.4 + +* Added option to set the video playback speed on the video controller. + ## 0.1.3+2 * Allow users to set the 'muted' attribute on video elements by setting their volume to 0. diff --git a/packages/video_player/video_player_web/lib/video_player_web.dart b/packages/video_player/video_player_web/lib/video_player_web.dart index 3a849f45e0c1..073144f91435 100644 --- a/packages/video_player/video_player_web/lib/video_player_web.dart +++ b/packages/video_player/video_player_web/lib/video_player_web.dart @@ -119,6 +119,13 @@ class VideoPlayerPlugin extends VideoPlayerPlatform { return _videoPlayers[textureId].setVolume(volume); } + @override + Future setPlaybackSpeed(int textureId, double speed) async { + assert(speed >= 0); + + return _videoPlayers[textureId].setPlaybackSpeed(speed); + } + @override Future seekTo(int textureId, Duration position) async { return _videoPlayers[textureId].seekTo(position); @@ -232,6 +239,12 @@ class _VideoPlayer { videoElement.volume = value; } + void setPlaybackSpeed(double speed) { + assert(speed >= 0); + + videoElement.playbackRate = speed; + } + void seekTo(Duration position) { videoElement.currentTime = position.inMilliseconds.toDouble() / 1000; } diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index 891430d7483b..da5d39bdc820 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/v # 0.1.y+z is compatible with 1.0.0, if you land a breaking change bump # the version to 2.0.0. # See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 -version: 0.1.3+2 +version: 0.1.4 flutter: plugin: diff --git a/packages/video_player/video_player_web/test/video_player_web_test.dart b/packages/video_player/video_player_web/test/video_player_web_test.dart index ef6dc028c529..115d3b35ef1b 100644 --- a/packages/video_player/video_player_web/test/video_player_web_test.dart +++ b/packages/video_player/video_player_web/test/video_player_web_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @TestOn('browser') - import 'dart:async'; import 'package:flutter/services.dart'; @@ -109,6 +108,13 @@ void main() { expect(VideoPlayerPlatform.instance.setVolume(textureId, 0.8), completes); }); + test('can set playback speed', () { + expect( + VideoPlayerPlatform.instance.setPlaybackSpeed(textureId, 2.0), + completes, + ); + }); + test('can seek to position', () { expect( VideoPlayerPlatform.instance.seekTo(textureId, Duration(seconds: 1)), From e1e2231b8f856f7b726b71cd7207526777a02834 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Tue, 15 Sep 2020 16:54:51 +0000 Subject: [PATCH 02/17] Add test host --- .../flutter/plugins/videoplayer/Messages.java | 544 +++++++----------- .../video_player/ios/Classes/messages.h | 57 +- .../video_player/ios/Classes/messages.m | 210 +++---- .../video_player/pigeons/messages.dart | 2 +- .../lib/messages.dart | 302 +++++++--- 5 files changed, 540 insertions(+), 575 deletions(-) diff --git a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java index 6ebed7aaf68e..d04a4a775760 100644 --- a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java +++ b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java @@ -6,6 +6,7 @@ import io.flutter.plugin.common.BasicMessageChannel; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; import java.util.HashMap; /** Generated class from Pigeon. */ @@ -15,28 +16,18 @@ public class Messages { /** Generated class from Pigeon that represents data sent in messages. */ public static class TextureMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); return toMapResult; } - static TextureMessage fromMap(HashMap map) { TextureMessage fromMapResult = new TextureMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); return fromMapResult; } } @@ -44,44 +35,20 @@ static TextureMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class CreateMessage { private String asset; - - public String getAsset() { - return asset; - } - - public void setAsset(String setterArg) { - this.asset = setterArg; - } + public String getAsset() { return asset; } + public void setAsset(String setterArg) { this.asset = setterArg; } private String uri; - - public String getUri() { - return uri; - } - - public void setUri(String setterArg) { - this.uri = setterArg; - } + public String getUri() { return uri; } + public void setUri(String setterArg) { this.uri = setterArg; } private String packageName; - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String setterArg) { - this.packageName = setterArg; - } + public String getPackageName() { return packageName; } + public void setPackageName(String setterArg) { this.packageName = setterArg; } private String formatHint; - - public String getFormatHint() { - return formatHint; - } - - public void setFormatHint(String setterArg) { - this.formatHint = setterArg; - } + public String getFormatHint() { return formatHint; } + public void setFormatHint(String setterArg) { this.formatHint = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -91,17 +58,16 @@ HashMap toMap() { toMapResult.put("formatHint", formatHint); return toMapResult; } - static CreateMessage fromMap(HashMap map) { CreateMessage fromMapResult = new CreateMessage(); Object asset = map.get("asset"); - fromMapResult.asset = (String) asset; + fromMapResult.asset = (String)asset; Object uri = map.get("uri"); - fromMapResult.uri = (String) uri; + fromMapResult.uri = (String)uri; Object packageName = map.get("packageName"); - fromMapResult.packageName = (String) packageName; + fromMapResult.packageName = (String)packageName; Object formatHint = map.get("formatHint"); - fromMapResult.formatHint = (String) formatHint; + fromMapResult.formatHint = (String)formatHint; return fromMapResult; } } @@ -109,24 +75,12 @@ static CreateMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class LoopingMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } private Boolean isLooping; - - public Boolean getIsLooping() { - return isLooping; - } - - public void setIsLooping(Boolean setterArg) { - this.isLooping = setterArg; - } + public Boolean getIsLooping() { return isLooping; } + public void setIsLooping(Boolean setterArg) { this.isLooping = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -134,16 +88,12 @@ HashMap toMap() { toMapResult.put("isLooping", isLooping); return toMapResult; } - static LoopingMessage fromMap(HashMap map) { LoopingMessage fromMapResult = new LoopingMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); Object isLooping = map.get("isLooping"); - fromMapResult.isLooping = (Boolean) isLooping; + fromMapResult.isLooping = (Boolean)isLooping; return fromMapResult; } } @@ -151,24 +101,12 @@ static LoopingMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class VolumeMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } private Double volume; - - public Double getVolume() { - return volume; - } - - public void setVolume(Double setterArg) { - this.volume = setterArg; - } + public Double getVolume() { return volume; } + public void setVolume(Double setterArg) { this.volume = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -176,16 +114,12 @@ HashMap toMap() { toMapResult.put("volume", volume); return toMapResult; } - static VolumeMessage fromMap(HashMap map) { VolumeMessage fromMapResult = new VolumeMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); Object volume = map.get("volume"); - fromMapResult.volume = (Double) volume; + fromMapResult.volume = (Double)volume; return fromMapResult; } } @@ -193,24 +127,12 @@ static VolumeMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class PlaybackSpeedMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } private Double speed; - - public Double getSpeed() { - return speed; - } - - public void setSpeed(Double setterArg) { - this.speed = setterArg; - } + public Double getSpeed() { return speed; } + public void setSpeed(Double setterArg) { this.speed = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -218,16 +140,12 @@ HashMap toMap() { toMapResult.put("speed", speed); return toMapResult; } - static PlaybackSpeedMessage fromMap(HashMap map) { PlaybackSpeedMessage fromMapResult = new PlaybackSpeedMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); Object speed = map.get("speed"); - fromMapResult.speed = (Double) speed; + fromMapResult.speed = (Double)speed; return fromMapResult; } } @@ -235,24 +153,12 @@ static PlaybackSpeedMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class PositionMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } private Long position; - - public Long getPosition() { - return position; - } - - public void setPosition(Long setterArg) { - this.position = setterArg; - } + public Long getPosition() { return position; } + public void setPosition(Long setterArg) { this.position = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -260,19 +166,12 @@ HashMap toMap() { toMapResult.put("position", position); return toMapResult; } - static PositionMessage fromMap(HashMap map) { PositionMessage fromMapResult = new PositionMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); Object position = map.get("position"); - fromMapResult.position = - (position == null) - ? null - : ((position instanceof Integer) ? (Integer) position : (Long) position); + fromMapResult.position = (position == null) ? null : ((position instanceof Integer) ? (Integer)position : (Long)position); return fromMapResult; } } @@ -280,320 +179,269 @@ static PositionMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class MixWithOthersMessage { private Boolean mixWithOthers; - - public Boolean getMixWithOthers() { - return mixWithOthers; - } - - public void setMixWithOthers(Boolean setterArg) { - this.mixWithOthers = setterArg; - } + public Boolean getMixWithOthers() { return mixWithOthers; } + public void setMixWithOthers(Boolean setterArg) { this.mixWithOthers = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); toMapResult.put("mixWithOthers", mixWithOthers); return toMapResult; } - static MixWithOthersMessage fromMap(HashMap map) { MixWithOthersMessage fromMapResult = new MixWithOthersMessage(); Object mixWithOthers = map.get("mixWithOthers"); - fromMapResult.mixWithOthers = (Boolean) mixWithOthers; + fromMapResult.mixWithOthers = (Boolean)mixWithOthers; return fromMapResult; } } - /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + /** Generated interface from Pigeon that represents a handler of messages from Flutter.*/ public interface VideoPlayerApi { void initialize(); - TextureMessage create(CreateMessage arg); - void dispose(TextureMessage arg); - void setLooping(LoopingMessage arg); - void setVolume(VolumeMessage arg); - void setPlaybackSpeed(PlaybackSpeedMessage arg); - void play(TextureMessage arg); - PositionMessage position(TextureMessage arg); - void seekTo(PositionMessage arg); - void pause(TextureMessage arg); - void setMixWithOthers(MixWithOthersMessage arg); /** Sets up an instance of `VideoPlayerApi` to handle messages through the `binaryMessenger` */ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.initialize", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.initialize", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - api.initialize(); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + api.initialize(); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.create", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.create", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - CreateMessage input = CreateMessage.fromMap((HashMap) message); - TextureMessage output = api.create(input); - wrapped.put("result", output.toMap()); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + CreateMessage input = CreateMessage.fromMap((HashMap)message); + TextureMessage output = api.create(input); + wrapped.put("result", output.toMap()); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.dispose", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.dispose", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.dispose(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap)message); + api.dispose(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setLooping", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setLooping", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - LoopingMessage input = LoopingMessage.fromMap((HashMap) message); - api.setLooping(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + LoopingMessage input = LoopingMessage.fromMap((HashMap)message); + api.setLooping(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setVolume", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setVolume", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - VolumeMessage input = VolumeMessage.fromMap((HashMap) message); - api.setVolume(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + VolumeMessage input = VolumeMessage.fromMap((HashMap)message); + api.setVolume(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap) message); - api.setPlaybackSpeed(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap)message); + api.setPlaybackSpeed(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.play", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.play", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.play(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap)message); + api.play(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.position", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.position", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - PositionMessage output = api.position(input); - wrapped.put("result", output.toMap()); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap)message); + PositionMessage output = api.position(input); + wrapped.put("result", output.toMap()); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.seekTo", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.seekTo", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - PositionMessage input = PositionMessage.fromMap((HashMap) message); - api.seekTo(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PositionMessage input = PositionMessage.fromMap((HashMap)message); + api.seekTo(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.pause", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.pause", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.pause(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap)message); + api.pause(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap) message); - api.setMixWithOthers(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap)message); + api.setMixWithOthers(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } } } - private static HashMap wrapError(Exception exception) { HashMap errorMap = new HashMap<>(); errorMap.put("message", exception.toString()); diff --git a/packages/video_player/video_player/ios/Classes/messages.h b/packages/video_player/video_player/ios/Classes/messages.h index 49239168e3ad..e481af08ea5a 100644 --- a/packages/video_player/video_player/ios/Classes/messages.h +++ b/packages/video_player/video_player/ios/Classes/messages.h @@ -16,59 +16,54 @@ NS_ASSUME_NONNULL_BEGIN @class FLTMixWithOthersMessage; @interface FLTTextureMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber *textureId; +@property(nonatomic, strong, nullable) NSNumber * textureId; @end @interface FLTCreateMessage : NSObject -@property(nonatomic, copy, nullable) NSString *asset; -@property(nonatomic, copy, nullable) NSString *uri; -@property(nonatomic, copy, nullable) NSString *packageName; -@property(nonatomic, copy, nullable) NSString *formatHint; +@property(nonatomic, copy, nullable) NSString * asset; +@property(nonatomic, copy, nullable) NSString * uri; +@property(nonatomic, copy, nullable) NSString * packageName; +@property(nonatomic, copy, nullable) NSString * formatHint; @end @interface FLTLoopingMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber *textureId; -@property(nonatomic, strong, nullable) NSNumber *isLooping; +@property(nonatomic, strong, nullable) NSNumber * textureId; +@property(nonatomic, strong, nullable) NSNumber * isLooping; @end @interface FLTVolumeMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber *textureId; -@property(nonatomic, strong, nullable) NSNumber *volume; +@property(nonatomic, strong, nullable) NSNumber * textureId; +@property(nonatomic, strong, nullable) NSNumber * volume; @end @interface FLTPlaybackSpeedMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber *textureId; -@property(nonatomic, strong, nullable) NSNumber *speed; +@property(nonatomic, strong, nullable) NSNumber * textureId; +@property(nonatomic, strong, nullable) NSNumber * speed; @end @interface FLTPositionMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber *textureId; -@property(nonatomic, strong, nullable) NSNumber *position; +@property(nonatomic, strong, nullable) NSNumber * textureId; +@property(nonatomic, strong, nullable) NSNumber * position; @end @interface FLTMixWithOthersMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber *mixWithOthers; +@property(nonatomic, strong, nullable) NSNumber * mixWithOthers; @end @protocol FLTVideoPlayerApi -- (void)initialize:(FlutterError *_Nullable *_Nonnull)error; -- (nullable FLTTextureMessage *)create:(FLTCreateMessage *)input - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)dispose:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setLooping:(FLTLoopingMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setVolume:(FLTVolumeMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setPlaybackSpeed:(FLTPlaybackSpeedMessage *)input - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)play:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable FLTPositionMessage *)position:(FLTTextureMessage *)input - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)seekTo:(FLTPositionMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; -- (void)pause:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setMixWithOthers:(FLTMixWithOthersMessage *)input - error:(FlutterError *_Nullable *_Nonnull)error; +-(void)initialize:(FlutterError *_Nullable *_Nonnull)error; +-(nullable FLTTextureMessage *)create:(FLTCreateMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(void)dispose:(FLTTextureMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(void)setLooping:(FLTLoopingMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(void)setVolume:(FLTVolumeMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(void)setPlaybackSpeed:(FLTPlaybackSpeedMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(void)play:(FLTTextureMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(nullable FLTPositionMessage *)position:(FLTTextureMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(void)seekTo:(FLTPositionMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(void)pause:(FLTTextureMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +-(void)setMixWithOthers:(FLTMixWithOthersMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FLTVideoPlayerApiSetup(id binaryMessenger, - id _Nullable api); +extern void FLTVideoPlayerApiSetup(id binaryMessenger, id _Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/video_player/video_player/ios/Classes/messages.m b/packages/video_player/video_player/ios/Classes/messages.m index a560c8d9ab82..1adb5d65b245 100644 --- a/packages/video_player/video_player/ios/Classes/messages.m +++ b/packages/video_player/video_player/ios/Classes/messages.m @@ -7,67 +7,67 @@ #error File requires ARC to be enabled. #endif -static NSDictionary *wrapResult(NSDictionary *result, FlutterError *error) { +static NSDictionary* wrapResult(NSDictionary *result, FlutterError *error) { NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { - errorDict = [NSDictionary - dictionaryWithObjectsAndKeys:(error.code ? error.code : [NSNull null]), @"code", - (error.message ? error.message : [NSNull null]), @"message", - (error.details ? error.details : [NSNull null]), @"details", - nil]; + errorDict = [NSDictionary dictionaryWithObjectsAndKeys: + (error.code ? error.code : [NSNull null]), @"code", + (error.message ? error.message : [NSNull null]), @"message", + (error.details ? error.details : [NSNull null]), @"details", + nil]; } - return [NSDictionary dictionaryWithObjectsAndKeys:(result ? result : [NSNull null]), @"result", - errorDict, @"error", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys: + (result ? result : [NSNull null]), @"result", + errorDict, @"error", + nil]; } @interface FLTTextureMessage () -+ (FLTTextureMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++(FLTTextureMessage*)fromMap:(NSDictionary*)dict; +-(NSDictionary*)toMap; @end @interface FLTCreateMessage () -+ (FLTCreateMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++(FLTCreateMessage*)fromMap:(NSDictionary*)dict; +-(NSDictionary*)toMap; @end @interface FLTLoopingMessage () -+ (FLTLoopingMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++(FLTLoopingMessage*)fromMap:(NSDictionary*)dict; +-(NSDictionary*)toMap; @end @interface FLTVolumeMessage () -+ (FLTVolumeMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++(FLTVolumeMessage*)fromMap:(NSDictionary*)dict; +-(NSDictionary*)toMap; @end @interface FLTPlaybackSpeedMessage () -+ (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++(FLTPlaybackSpeedMessage*)fromMap:(NSDictionary*)dict; +-(NSDictionary*)toMap; @end @interface FLTPositionMessage () -+ (FLTPositionMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++(FLTPositionMessage*)fromMap:(NSDictionary*)dict; +-(NSDictionary*)toMap; @end @interface FLTMixWithOthersMessage () -+ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++(FLTMixWithOthersMessage*)fromMap:(NSDictionary*)dict; +-(NSDictionary*)toMap; @end @implementation FLTTextureMessage -+ (FLTTextureMessage *)fromMap:(NSDictionary *)dict { - FLTTextureMessage *result = [[FLTTextureMessage alloc] init]; ++(FLTTextureMessage*)fromMap:(NSDictionary*)dict { + FLTTextureMessage* result = [[FLTTextureMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; } return result; } -- (NSDictionary *)toMap { - return - [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), - @"textureId", nil]; +-(NSDictionary*)toMap { + return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", nil]; } @end @implementation FLTCreateMessage -+ (FLTCreateMessage *)fromMap:(NSDictionary *)dict { - FLTCreateMessage *result = [[FLTCreateMessage alloc] init]; ++(FLTCreateMessage*)fromMap:(NSDictionary*)dict { + FLTCreateMessage* result = [[FLTCreateMessage alloc] init]; result.asset = dict[@"asset"]; if ((NSNull *)result.asset == [NSNull null]) { result.asset = nil; @@ -86,20 +86,14 @@ + (FLTCreateMessage *)fromMap:(NSDictionary *)dict { } return result; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.asset ? self.asset : [NSNull null]), @"asset", - (self.uri ? self.uri : [NSNull null]), @"uri", - (self.packageName ? self.packageName : [NSNull null]), - @"packageName", - (self.formatHint ? self.formatHint : [NSNull null]), - @"formatHint", nil]; +-(NSDictionary*)toMap { + return [NSDictionary dictionaryWithObjectsAndKeys:(self.asset ? self.asset : [NSNull null]), @"asset", (self.uri ? self.uri : [NSNull null]), @"uri", (self.packageName ? self.packageName : [NSNull null]), @"packageName", (self.formatHint ? self.formatHint : [NSNull null]), @"formatHint", nil]; } @end @implementation FLTLoopingMessage -+ (FLTLoopingMessage *)fromMap:(NSDictionary *)dict { - FLTLoopingMessage *result = [[FLTLoopingMessage alloc] init]; ++(FLTLoopingMessage*)fromMap:(NSDictionary*)dict { + FLTLoopingMessage* result = [[FLTLoopingMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; @@ -110,17 +104,14 @@ + (FLTLoopingMessage *)fromMap:(NSDictionary *)dict { } return result; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", - (self.isLooping ? self.isLooping : [NSNull null]), @"isLooping", - nil]; +-(NSDictionary*)toMap { + return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", (self.isLooping ? self.isLooping : [NSNull null]), @"isLooping", nil]; } @end @implementation FLTVolumeMessage -+ (FLTVolumeMessage *)fromMap:(NSDictionary *)dict { - FLTVolumeMessage *result = [[FLTVolumeMessage alloc] init]; ++(FLTVolumeMessage*)fromMap:(NSDictionary*)dict { + FLTVolumeMessage* result = [[FLTVolumeMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; @@ -131,16 +122,14 @@ + (FLTVolumeMessage *)fromMap:(NSDictionary *)dict { } return result; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", - (self.volume ? self.volume : [NSNull null]), @"volume", nil]; +-(NSDictionary*)toMap { + return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", (self.volume ? self.volume : [NSNull null]), @"volume", nil]; } @end @implementation FLTPlaybackSpeedMessage -+ (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict { - FLTPlaybackSpeedMessage *result = [[FLTPlaybackSpeedMessage alloc] init]; ++(FLTPlaybackSpeedMessage*)fromMap:(NSDictionary*)dict { + FLTPlaybackSpeedMessage* result = [[FLTPlaybackSpeedMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; @@ -151,16 +140,14 @@ + (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict { } return result; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", - (self.speed ? self.speed : [NSNull null]), @"speed", nil]; +-(NSDictionary*)toMap { + return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", (self.speed ? self.speed : [NSNull null]), @"speed", nil]; } @end @implementation FLTPositionMessage -+ (FLTPositionMessage *)fromMap:(NSDictionary *)dict { - FLTPositionMessage *result = [[FLTPositionMessage alloc] init]; ++(FLTPositionMessage*)fromMap:(NSDictionary*)dict { + FLTPositionMessage* result = [[FLTPositionMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; @@ -171,49 +158,47 @@ + (FLTPositionMessage *)fromMap:(NSDictionary *)dict { } return result; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", - (self.position ? self.position : [NSNull null]), @"position", - nil]; +-(NSDictionary*)toMap { + return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", (self.position ? self.position : [NSNull null]), @"position", nil]; } @end @implementation FLTMixWithOthersMessage -+ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict { - FLTMixWithOthersMessage *result = [[FLTMixWithOthersMessage alloc] init]; ++(FLTMixWithOthersMessage*)fromMap:(NSDictionary*)dict { + FLTMixWithOthersMessage* result = [[FLTMixWithOthersMessage alloc] init]; result.mixWithOthers = dict[@"mixWithOthers"]; if ((NSNull *)result.mixWithOthers == [NSNull null]) { result.mixWithOthers = nil; } return result; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.mixWithOthers ? self.mixWithOthers : [NSNull null]), - @"mixWithOthers", nil]; +-(NSDictionary*)toMap { + return [NSDictionary dictionaryWithObjectsAndKeys:(self.mixWithOthers ? self.mixWithOthers : [NSNull null]), @"mixWithOthers", nil]; } @end void FLTVideoPlayerApiSetup(id binaryMessenger, id api) { { - FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + FlutterBasicMessageChannel *channel = + [FlutterBasicMessageChannel messageChannelWithName:@"dev.flutter.pigeon.VideoPlayerApi.initialize" - binaryMessenger:binaryMessenger]; + binaryMessenger:binaryMessenger]; if (api) { [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api initialize:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + FlutterBasicMessageChannel *channel = + [FlutterBasicMessageChannel messageChannelWithName:@"dev.flutter.pigeon.VideoPlayerApi.create" - binaryMessenger:binaryMessenger]; + binaryMessenger:binaryMessenger]; if (api) { [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; @@ -221,14 +206,16 @@ void FLTVideoPlayerApiSetup(id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final TextureMessage result = TextureMessage(); @@ -39,10 +38,9 @@ class CreateMessage { pigeonMap['formatHint'] = formatHint; return pigeonMap; } - // ignore: unused_element static CreateMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final CreateMessage result = CreateMessage(); @@ -64,10 +62,9 @@ class LoopingMessage { pigeonMap['isLooping'] = isLooping; return pigeonMap; } - // ignore: unused_element static LoopingMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final LoopingMessage result = LoopingMessage(); @@ -87,10 +84,9 @@ class VolumeMessage { pigeonMap['volume'] = volume; return pigeonMap; } - // ignore: unused_element static VolumeMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final VolumeMessage result = VolumeMessage(); @@ -110,10 +106,9 @@ class PlaybackSpeedMessage { pigeonMap['speed'] = speed; return pigeonMap; } - // ignore: unused_element static PlaybackSpeedMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final PlaybackSpeedMessage result = PlaybackSpeedMessage(); @@ -133,10 +128,9 @@ class PositionMessage { pigeonMap['position'] = position; return pigeonMap; } - // ignore: unused_element static PositionMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final PositionMessage result = PositionMessage(); @@ -154,10 +148,9 @@ class MixWithOthersMessage { pigeonMap['mixWithOthers'] = mixWithOthers; return pigeonMap; } - // ignore: unused_element static MixWithOthersMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final MixWithOthersMessage result = MixWithOthersMessage(); @@ -168,15 +161,15 @@ class MixWithOthersMessage { class VideoPlayerApi { Future initialize() async { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + final Map replyMap = await channel.send(null); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -186,19 +179,19 @@ class VideoPlayerApi { } else { // noop } + } - Future create(CreateMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -208,19 +201,19 @@ class VideoPlayerApi { } else { return TextureMessage._fromMap(replyMap['result']); } + } - Future dispose(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -230,19 +223,19 @@ class VideoPlayerApi { } else { // noop } + } - Future setLooping(LoopingMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -252,19 +245,19 @@ class VideoPlayerApi { } else { // noop } + } - Future setVolume(VolumeMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -274,20 +267,19 @@ class VideoPlayerApi { } else { // noop } + } - Future setPlaybackSpeed(PlaybackSpeedMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', - StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -297,19 +289,19 @@ class VideoPlayerApi { } else { // noop } + } - Future play(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -319,19 +311,19 @@ class VideoPlayerApi { } else { // noop } + } - Future position(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -341,19 +333,19 @@ class VideoPlayerApi { } else { return PositionMessage._fromMap(replyMap['result']); } + } - Future seekTo(PositionMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -363,19 +355,19 @@ class VideoPlayerApi { } else { // noop } + } - Future pause(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -385,20 +377,19 @@ class VideoPlayerApi { } else { // noop } + } - Future setMixWithOthers(MixWithOthersMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', - StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -408,5 +399,132 @@ class VideoPlayerApi { } else { // noop } + } } + +abstract class TestHostVideoPlayerApi { + void initialize(); + TextureMessage create(CreateMessage arg); + void dispose(TextureMessage arg); + void setLooping(LoopingMessage arg); + void setVolume(VolumeMessage arg); + void setPlaybackSpeed(PlaybackSpeedMessage arg); + void play(TextureMessage arg); + PositionMessage position(TextureMessage arg); + void seekTo(PositionMessage arg); + void pause(TextureMessage arg); + void setMixWithOthers(MixWithOthersMessage arg); + static void setup(TestHostVideoPlayerApi api) { + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + api.initialize(); + return {}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final CreateMessage input = CreateMessage._fromMap(mapMessage); + final TextureMessage output = api.create(input); + return {'result': output._toMap()}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final TextureMessage input = TextureMessage._fromMap(mapMessage); + api.dispose(input); + return {}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final LoopingMessage input = LoopingMessage._fromMap(mapMessage); + api.setLooping(input); + return {}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final VolumeMessage input = VolumeMessage._fromMap(mapMessage); + api.setVolume(input); + return {}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final PlaybackSpeedMessage input = PlaybackSpeedMessage._fromMap(mapMessage); + api.setPlaybackSpeed(input); + return {}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final TextureMessage input = TextureMessage._fromMap(mapMessage); + api.play(input); + return {}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final TextureMessage input = TextureMessage._fromMap(mapMessage); + final PositionMessage output = api.position(input); + return {'result': output._toMap()}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final PositionMessage input = PositionMessage._fromMap(mapMessage); + api.seekTo(input); + return {}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final TextureMessage input = TextureMessage._fromMap(mapMessage); + api.pause(input); + return {}; + }); + } + { + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); + channel.setMockMessageHandler((dynamic message) async { + final Map mapMessage = message as Map; + final MixWithOthersMessage input = MixWithOthersMessage._fromMap(mapMessage); + api.setMixWithOthers(input); + return {}; + }); + } + } +} + From a9a93bfd792a358dead6743e5c146e87da9cdc73 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Tue, 15 Sep 2020 16:56:40 +0000 Subject: [PATCH 03/17] Format --- .../flutter/plugins/videoplayer/Messages.java | 544 +++++++++++------- .../lib/messages.dart | 265 +++++---- 2 files changed, 493 insertions(+), 316 deletions(-) diff --git a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java index d04a4a775760..6ebed7aaf68e 100644 --- a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java +++ b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java @@ -6,7 +6,6 @@ import io.flutter.plugin.common.BasicMessageChannel; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.StandardMessageCodec; -import java.util.ArrayList; import java.util.HashMap; /** Generated class from Pigeon. */ @@ -16,18 +15,28 @@ public class Messages { /** Generated class from Pigeon that represents data sent in messages. */ public static class TextureMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); return toMapResult; } + static TextureMessage fromMap(HashMap map) { TextureMessage fromMapResult = new TextureMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); return fromMapResult; } } @@ -35,20 +44,44 @@ static TextureMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class CreateMessage { private String asset; - public String getAsset() { return asset; } - public void setAsset(String setterArg) { this.asset = setterArg; } + + public String getAsset() { + return asset; + } + + public void setAsset(String setterArg) { + this.asset = setterArg; + } private String uri; - public String getUri() { return uri; } - public void setUri(String setterArg) { this.uri = setterArg; } + + public String getUri() { + return uri; + } + + public void setUri(String setterArg) { + this.uri = setterArg; + } private String packageName; - public String getPackageName() { return packageName; } - public void setPackageName(String setterArg) { this.packageName = setterArg; } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String setterArg) { + this.packageName = setterArg; + } private String formatHint; - public String getFormatHint() { return formatHint; } - public void setFormatHint(String setterArg) { this.formatHint = setterArg; } + + public String getFormatHint() { + return formatHint; + } + + public void setFormatHint(String setterArg) { + this.formatHint = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -58,16 +91,17 @@ HashMap toMap() { toMapResult.put("formatHint", formatHint); return toMapResult; } + static CreateMessage fromMap(HashMap map) { CreateMessage fromMapResult = new CreateMessage(); Object asset = map.get("asset"); - fromMapResult.asset = (String)asset; + fromMapResult.asset = (String) asset; Object uri = map.get("uri"); - fromMapResult.uri = (String)uri; + fromMapResult.uri = (String) uri; Object packageName = map.get("packageName"); - fromMapResult.packageName = (String)packageName; + fromMapResult.packageName = (String) packageName; Object formatHint = map.get("formatHint"); - fromMapResult.formatHint = (String)formatHint; + fromMapResult.formatHint = (String) formatHint; return fromMapResult; } } @@ -75,12 +109,24 @@ static CreateMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class LoopingMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } private Boolean isLooping; - public Boolean getIsLooping() { return isLooping; } - public void setIsLooping(Boolean setterArg) { this.isLooping = setterArg; } + + public Boolean getIsLooping() { + return isLooping; + } + + public void setIsLooping(Boolean setterArg) { + this.isLooping = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -88,12 +134,16 @@ HashMap toMap() { toMapResult.put("isLooping", isLooping); return toMapResult; } + static LoopingMessage fromMap(HashMap map) { LoopingMessage fromMapResult = new LoopingMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); Object isLooping = map.get("isLooping"); - fromMapResult.isLooping = (Boolean)isLooping; + fromMapResult.isLooping = (Boolean) isLooping; return fromMapResult; } } @@ -101,12 +151,24 @@ static LoopingMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class VolumeMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } private Double volume; - public Double getVolume() { return volume; } - public void setVolume(Double setterArg) { this.volume = setterArg; } + + public Double getVolume() { + return volume; + } + + public void setVolume(Double setterArg) { + this.volume = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -114,12 +176,16 @@ HashMap toMap() { toMapResult.put("volume", volume); return toMapResult; } + static VolumeMessage fromMap(HashMap map) { VolumeMessage fromMapResult = new VolumeMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); Object volume = map.get("volume"); - fromMapResult.volume = (Double)volume; + fromMapResult.volume = (Double) volume; return fromMapResult; } } @@ -127,12 +193,24 @@ static VolumeMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class PlaybackSpeedMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } private Double speed; - public Double getSpeed() { return speed; } - public void setSpeed(Double setterArg) { this.speed = setterArg; } + + public Double getSpeed() { + return speed; + } + + public void setSpeed(Double setterArg) { + this.speed = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -140,12 +218,16 @@ HashMap toMap() { toMapResult.put("speed", speed); return toMapResult; } + static PlaybackSpeedMessage fromMap(HashMap map) { PlaybackSpeedMessage fromMapResult = new PlaybackSpeedMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); Object speed = map.get("speed"); - fromMapResult.speed = (Double)speed; + fromMapResult.speed = (Double) speed; return fromMapResult; } } @@ -153,12 +235,24 @@ static PlaybackSpeedMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class PositionMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } private Long position; - public Long getPosition() { return position; } - public void setPosition(Long setterArg) { this.position = setterArg; } + + public Long getPosition() { + return position; + } + + public void setPosition(Long setterArg) { + this.position = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -166,12 +260,19 @@ HashMap toMap() { toMapResult.put("position", position); return toMapResult; } + static PositionMessage fromMap(HashMap map) { PositionMessage fromMapResult = new PositionMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); Object position = map.get("position"); - fromMapResult.position = (position == null) ? null : ((position instanceof Integer) ? (Integer)position : (Long)position); + fromMapResult.position = + (position == null) + ? null + : ((position instanceof Integer) ? (Integer) position : (Long) position); return fromMapResult; } } @@ -179,269 +280,320 @@ static PositionMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class MixWithOthersMessage { private Boolean mixWithOthers; - public Boolean getMixWithOthers() { return mixWithOthers; } - public void setMixWithOthers(Boolean setterArg) { this.mixWithOthers = setterArg; } + + public Boolean getMixWithOthers() { + return mixWithOthers; + } + + public void setMixWithOthers(Boolean setterArg) { + this.mixWithOthers = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); toMapResult.put("mixWithOthers", mixWithOthers); return toMapResult; } + static MixWithOthersMessage fromMap(HashMap map) { MixWithOthersMessage fromMapResult = new MixWithOthersMessage(); Object mixWithOthers = map.get("mixWithOthers"); - fromMapResult.mixWithOthers = (Boolean)mixWithOthers; + fromMapResult.mixWithOthers = (Boolean) mixWithOthers; return fromMapResult; } } - /** Generated interface from Pigeon that represents a handler of messages from Flutter.*/ + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface VideoPlayerApi { void initialize(); + TextureMessage create(CreateMessage arg); + void dispose(TextureMessage arg); + void setLooping(LoopingMessage arg); + void setVolume(VolumeMessage arg); + void setPlaybackSpeed(PlaybackSpeedMessage arg); + void play(TextureMessage arg); + PositionMessage position(TextureMessage arg); + void seekTo(PositionMessage arg); + void pause(TextureMessage arg); + void setMixWithOthers(MixWithOthersMessage arg); /** Sets up an instance of `VideoPlayerApi` to handle messages through the `binaryMessenger` */ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.initialize", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.initialize", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - api.initialize(); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + api.initialize(); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.create", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.create", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - CreateMessage input = CreateMessage.fromMap((HashMap)message); - TextureMessage output = api.create(input); - wrapped.put("result", output.toMap()); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + CreateMessage input = CreateMessage.fromMap((HashMap) message); + TextureMessage output = api.create(input); + wrapped.put("result", output.toMap()); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.dispose", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.dispose", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap)message); - api.dispose(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap) message); + api.dispose(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setLooping", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setLooping", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - LoopingMessage input = LoopingMessage.fromMap((HashMap)message); - api.setLooping(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + LoopingMessage input = LoopingMessage.fromMap((HashMap) message); + api.setLooping(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setVolume", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setVolume", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - VolumeMessage input = VolumeMessage.fromMap((HashMap)message); - api.setVolume(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + VolumeMessage input = VolumeMessage.fromMap((HashMap) message); + api.setVolume(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap)message); - api.setPlaybackSpeed(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap) message); + api.setPlaybackSpeed(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.play", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.play", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap)message); - api.play(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap) message); + api.play(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.position", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.position", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap)message); - PositionMessage output = api.position(input); - wrapped.put("result", output.toMap()); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap) message); + PositionMessage output = api.position(input); + wrapped.put("result", output.toMap()); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.seekTo", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.seekTo", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - PositionMessage input = PositionMessage.fromMap((HashMap)message); - api.seekTo(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PositionMessage input = PositionMessage.fromMap((HashMap) message); + api.seekTo(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.pause", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.pause", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap)message); - api.pause(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap) message); + api.pause(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap)message); - api.setMixWithOthers(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap) message); + api.setMixWithOthers(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } } } + private static HashMap wrapError(Exception exception) { HashMap errorMap = new HashMap<>(); errorMap.put("message", exception.toString()); diff --git a/packages/video_player/video_player_platform_interface/lib/messages.dart b/packages/video_player/video_player_platform_interface/lib/messages.dart index dfd2a9c5d770..8618c7925204 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -13,9 +13,10 @@ class TextureMessage { pigeonMap['textureId'] = textureId; return pigeonMap; } + // ignore: unused_element static TextureMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final TextureMessage result = TextureMessage(); @@ -38,9 +39,10 @@ class CreateMessage { pigeonMap['formatHint'] = formatHint; return pigeonMap; } + // ignore: unused_element static CreateMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final CreateMessage result = CreateMessage(); @@ -62,9 +64,10 @@ class LoopingMessage { pigeonMap['isLooping'] = isLooping; return pigeonMap; } + // ignore: unused_element static LoopingMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final LoopingMessage result = LoopingMessage(); @@ -84,9 +87,10 @@ class VolumeMessage { pigeonMap['volume'] = volume; return pigeonMap; } + // ignore: unused_element static VolumeMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final VolumeMessage result = VolumeMessage(); @@ -106,9 +110,10 @@ class PlaybackSpeedMessage { pigeonMap['speed'] = speed; return pigeonMap; } + // ignore: unused_element static PlaybackSpeedMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final PlaybackSpeedMessage result = PlaybackSpeedMessage(); @@ -128,9 +133,10 @@ class PositionMessage { pigeonMap['position'] = position; return pigeonMap; } + // ignore: unused_element static PositionMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final PositionMessage result = PositionMessage(); @@ -148,9 +154,10 @@ class MixWithOthersMessage { pigeonMap['mixWithOthers'] = mixWithOthers; return pigeonMap; } + // ignore: unused_element static MixWithOthersMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final MixWithOthersMessage result = MixWithOthersMessage(); @@ -161,15 +168,15 @@ class MixWithOthersMessage { class VideoPlayerApi { Future initialize() async { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + final Map replyMap = await channel.send(null); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -179,19 +186,19 @@ class VideoPlayerApi { } else { // noop } - } + Future create(CreateMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -201,19 +208,19 @@ class VideoPlayerApi { } else { return TextureMessage._fromMap(replyMap['result']); } - } + Future dispose(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -223,19 +230,19 @@ class VideoPlayerApi { } else { // noop } - } + Future setLooping(LoopingMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -245,19 +252,19 @@ class VideoPlayerApi { } else { // noop } - } + Future setVolume(VolumeMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -267,19 +274,20 @@ class VideoPlayerApi { } else { // noop } - } + Future setPlaybackSpeed(PlaybackSpeedMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', + StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -289,19 +297,19 @@ class VideoPlayerApi { } else { // noop } - } + Future play(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -311,19 +319,19 @@ class VideoPlayerApi { } else { // noop } - } + Future position(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -333,19 +341,19 @@ class VideoPlayerApi { } else { return PositionMessage._fromMap(replyMap['result']); } - } + Future seekTo(PositionMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -355,19 +363,19 @@ class VideoPlayerApi { } else { // noop } - } + Future pause(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -377,19 +385,20 @@ class VideoPlayerApi { } else { // noop } - } + Future setMixWithOthers(MixWithOthersMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', + StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -399,7 +408,6 @@ class VideoPlayerApi { } else { // noop } - } } @@ -417,114 +425,131 @@ abstract class TestHostVideoPlayerApi { void setMixWithOthers(MixWithOthersMessage arg); static void setup(TestHostVideoPlayerApi api) { { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.initialize', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; api.initialize(); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final CreateMessage input = CreateMessage._fromMap(mapMessage); final TextureMessage output = api.create(input); return {'result': output._toMap()}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.dispose(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setLooping', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final LoopingMessage input = LoopingMessage._fromMap(mapMessage); api.setLooping(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setVolume', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final VolumeMessage input = VolumeMessage._fromMap(mapMessage); api.setVolume(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final PlaybackSpeedMessage input = PlaybackSpeedMessage._fromMap(mapMessage); + final Map mapMessage = + message as Map; + final PlaybackSpeedMessage input = + PlaybackSpeedMessage._fromMap(mapMessage); api.setPlaybackSpeed(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.play(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); final PositionMessage output = api.position(input); return {'result': output._toMap()}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final PositionMessage input = PositionMessage._fromMap(mapMessage); api.seekTo(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.pause(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final MixWithOthersMessage input = MixWithOthersMessage._fromMap(mapMessage); + final Map mapMessage = + message as Map; + final MixWithOthersMessage input = + MixWithOthersMessage._fromMap(mapMessage); api.setMixWithOthers(input); return {}; }); } } } - From 99560b98caed7d995de4c7523da2f3ecd33eac62 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Tue, 15 Sep 2020 17:00:19 +0000 Subject: [PATCH 04/17] Use test host --- .../test/method_channel_video_player_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart index 3917bd5485b3..c4791001ad92 100644 --- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart +++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart @@ -11,7 +11,7 @@ import 'package:video_player_platform_interface/messages.dart'; import 'package:video_player_platform_interface/method_channel_video_player.dart'; import 'package:video_player_platform_interface/video_player_platform_interface.dart'; -class _ApiLogger implements VideoPlayerApiTest { +class _ApiLogger implements TestHostVideoPlayerApi { final List log = []; TextureMessage textureMessage; CreateMessage createMessage; @@ -122,7 +122,7 @@ void main() { setUp(() { log = _ApiLogger(); - VideoPlayerApiTestSetup(log); + TestHostVideoPlayerApi.setup(log); }); test('init', () async { From fec01cc3608eaa515d1f8b15e9b3eaf536f0a092 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Thu, 24 Sep 2020 13:42:09 +0000 Subject: [PATCH 05/17] Pigeon 1.7 --- .../flutter/plugins/videoplayer/Messages.java | 546 +++++++----------- .../video_player/ios/Classes/messages.h | 2 +- .../video_player/ios/Classes/messages.m | 2 +- .../video_player/video_player/pubspec.yaml | 2 +- .../lib/messages.dart | 267 ++++----- 5 files changed, 321 insertions(+), 498 deletions(-) diff --git a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java index 6ebed7aaf68e..fc73f0d16c63 100644 --- a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java +++ b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.5), do not edit directly. +// Autogenerated from Pigeon (v0.1.7), do not edit directly. // See also: https://pub.dev/packages/pigeon package io.flutter.plugins.videoplayer; @@ -6,6 +6,7 @@ import io.flutter.plugin.common.BasicMessageChannel; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; import java.util.HashMap; /** Generated class from Pigeon. */ @@ -15,28 +16,18 @@ public class Messages { /** Generated class from Pigeon that represents data sent in messages. */ public static class TextureMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); return toMapResult; } - static TextureMessage fromMap(HashMap map) { TextureMessage fromMapResult = new TextureMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); return fromMapResult; } } @@ -44,44 +35,20 @@ static TextureMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class CreateMessage { private String asset; - - public String getAsset() { - return asset; - } - - public void setAsset(String setterArg) { - this.asset = setterArg; - } + public String getAsset() { return asset; } + public void setAsset(String setterArg) { this.asset = setterArg; } private String uri; - - public String getUri() { - return uri; - } - - public void setUri(String setterArg) { - this.uri = setterArg; - } + public String getUri() { return uri; } + public void setUri(String setterArg) { this.uri = setterArg; } private String packageName; - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String setterArg) { - this.packageName = setterArg; - } + public String getPackageName() { return packageName; } + public void setPackageName(String setterArg) { this.packageName = setterArg; } private String formatHint; - - public String getFormatHint() { - return formatHint; - } - - public void setFormatHint(String setterArg) { - this.formatHint = setterArg; - } + public String getFormatHint() { return formatHint; } + public void setFormatHint(String setterArg) { this.formatHint = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -91,17 +58,16 @@ HashMap toMap() { toMapResult.put("formatHint", formatHint); return toMapResult; } - static CreateMessage fromMap(HashMap map) { CreateMessage fromMapResult = new CreateMessage(); Object asset = map.get("asset"); - fromMapResult.asset = (String) asset; + fromMapResult.asset = (String)asset; Object uri = map.get("uri"); - fromMapResult.uri = (String) uri; + fromMapResult.uri = (String)uri; Object packageName = map.get("packageName"); - fromMapResult.packageName = (String) packageName; + fromMapResult.packageName = (String)packageName; Object formatHint = map.get("formatHint"); - fromMapResult.formatHint = (String) formatHint; + fromMapResult.formatHint = (String)formatHint; return fromMapResult; } } @@ -109,24 +75,12 @@ static CreateMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class LoopingMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } private Boolean isLooping; - - public Boolean getIsLooping() { - return isLooping; - } - - public void setIsLooping(Boolean setterArg) { - this.isLooping = setterArg; - } + public Boolean getIsLooping() { return isLooping; } + public void setIsLooping(Boolean setterArg) { this.isLooping = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -134,16 +88,12 @@ HashMap toMap() { toMapResult.put("isLooping", isLooping); return toMapResult; } - static LoopingMessage fromMap(HashMap map) { LoopingMessage fromMapResult = new LoopingMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); Object isLooping = map.get("isLooping"); - fromMapResult.isLooping = (Boolean) isLooping; + fromMapResult.isLooping = (Boolean)isLooping; return fromMapResult; } } @@ -151,24 +101,12 @@ static LoopingMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class VolumeMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } private Double volume; - - public Double getVolume() { - return volume; - } - - public void setVolume(Double setterArg) { - this.volume = setterArg; - } + public Double getVolume() { return volume; } + public void setVolume(Double setterArg) { this.volume = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -176,16 +114,12 @@ HashMap toMap() { toMapResult.put("volume", volume); return toMapResult; } - static VolumeMessage fromMap(HashMap map) { VolumeMessage fromMapResult = new VolumeMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); Object volume = map.get("volume"); - fromMapResult.volume = (Double) volume; + fromMapResult.volume = (Double)volume; return fromMapResult; } } @@ -193,24 +127,12 @@ static VolumeMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class PlaybackSpeedMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } private Double speed; - - public Double getSpeed() { - return speed; - } - - public void setSpeed(Double setterArg) { - this.speed = setterArg; - } + public Double getSpeed() { return speed; } + public void setSpeed(Double setterArg) { this.speed = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -218,16 +140,12 @@ HashMap toMap() { toMapResult.put("speed", speed); return toMapResult; } - static PlaybackSpeedMessage fromMap(HashMap map) { PlaybackSpeedMessage fromMapResult = new PlaybackSpeedMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); Object speed = map.get("speed"); - fromMapResult.speed = (Double) speed; + fromMapResult.speed = (Double)speed; return fromMapResult; } } @@ -235,24 +153,12 @@ static PlaybackSpeedMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class PositionMessage { private Long textureId; - - public Long getTextureId() { - return textureId; - } - - public void setTextureId(Long setterArg) { - this.textureId = setterArg; - } + public Long getTextureId() { return textureId; } + public void setTextureId(Long setterArg) { this.textureId = setterArg; } private Long position; - - public Long getPosition() { - return position; - } - - public void setPosition(Long setterArg) { - this.position = setterArg; - } + public Long getPosition() { return position; } + public void setPosition(Long setterArg) { this.position = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -260,19 +166,12 @@ HashMap toMap() { toMapResult.put("position", position); return toMapResult; } - static PositionMessage fromMap(HashMap map) { PositionMessage fromMapResult = new PositionMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = - (textureId == null) - ? null - : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); + fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); Object position = map.get("position"); - fromMapResult.position = - (position == null) - ? null - : ((position instanceof Integer) ? (Integer) position : (Long) position); + fromMapResult.position = (position == null) ? null : ((position instanceof Integer) ? (Integer)position : (Long)position); return fromMapResult; } } @@ -280,320 +179,269 @@ static PositionMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class MixWithOthersMessage { private Boolean mixWithOthers; - - public Boolean getMixWithOthers() { - return mixWithOthers; - } - - public void setMixWithOthers(Boolean setterArg) { - this.mixWithOthers = setterArg; - } + public Boolean getMixWithOthers() { return mixWithOthers; } + public void setMixWithOthers(Boolean setterArg) { this.mixWithOthers = setterArg; } HashMap toMap() { HashMap toMapResult = new HashMap<>(); toMapResult.put("mixWithOthers", mixWithOthers); return toMapResult; } - static MixWithOthersMessage fromMap(HashMap map) { MixWithOthersMessage fromMapResult = new MixWithOthersMessage(); Object mixWithOthers = map.get("mixWithOthers"); - fromMapResult.mixWithOthers = (Boolean) mixWithOthers; + fromMapResult.mixWithOthers = (Boolean)mixWithOthers; return fromMapResult; } } - /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + /** Generated interface from Pigeon that represents a handler of messages from Flutter.*/ public interface VideoPlayerApi { void initialize(); - TextureMessage create(CreateMessage arg); - void dispose(TextureMessage arg); - void setLooping(LoopingMessage arg); - void setVolume(VolumeMessage arg); - void setPlaybackSpeed(PlaybackSpeedMessage arg); - void play(TextureMessage arg); - PositionMessage position(TextureMessage arg); - void seekTo(PositionMessage arg); - void pause(TextureMessage arg); - void setMixWithOthers(MixWithOthersMessage arg); /** Sets up an instance of `VideoPlayerApi` to handle messages through the `binaryMessenger` */ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.initialize", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.initialize", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - api.initialize(); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + api.initialize(); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.create", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.create", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - CreateMessage input = CreateMessage.fromMap((HashMap) message); - TextureMessage output = api.create(input); - wrapped.put("result", output.toMap()); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + CreateMessage input = CreateMessage.fromMap((HashMap)message); + TextureMessage output = api.create(input); + wrapped.put("result", output.toMap()); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.dispose", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.dispose", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.dispose(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap)message); + api.dispose(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setLooping", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setLooping", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - LoopingMessage input = LoopingMessage.fromMap((HashMap) message); - api.setLooping(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + LoopingMessage input = LoopingMessage.fromMap((HashMap)message); + api.setLooping(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setVolume", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setVolume", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - VolumeMessage input = VolumeMessage.fromMap((HashMap) message); - api.setVolume(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + VolumeMessage input = VolumeMessage.fromMap((HashMap)message); + api.setVolume(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap) message); - api.setPlaybackSpeed(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap)message); + api.setPlaybackSpeed(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.play", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.play", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.play(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap)message); + api.play(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.position", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.position", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - PositionMessage output = api.position(input); - wrapped.put("result", output.toMap()); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap)message); + PositionMessage output = api.position(input); + wrapped.put("result", output.toMap()); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.seekTo", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.seekTo", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - PositionMessage input = PositionMessage.fromMap((HashMap) message); - api.seekTo(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PositionMessage input = PositionMessage.fromMap((HashMap)message); + api.seekTo(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.pause", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.pause", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.pause(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap)message); + api.pause(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", - new StandardMessageCodec()); + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap) message); - api.setMixWithOthers(input); - wrapped.put("result", null); - } catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap)message); + api.setMixWithOthers(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } } } - private static HashMap wrapError(Exception exception) { HashMap errorMap = new HashMap<>(); errorMap.put("message", exception.toString()); diff --git a/packages/video_player/video_player/ios/Classes/messages.h b/packages/video_player/video_player/ios/Classes/messages.h index e481af08ea5a..945bc13e21de 100644 --- a/packages/video_player/video_player/ios/Classes/messages.h +++ b/packages/video_player/video_player/ios/Classes/messages.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.5), do not edit directly. +// Autogenerated from Pigeon (v0.1.7), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @protocol FlutterBinaryMessenger; diff --git a/packages/video_player/video_player/ios/Classes/messages.m b/packages/video_player/video_player/ios/Classes/messages.m index 1adb5d65b245..92563bda9d38 100644 --- a/packages/video_player/video_player/ios/Classes/messages.m +++ b/packages/video_player/video_player/ios/Classes/messages.m @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.5), do not edit directly. +// Autogenerated from Pigeon (v0.1.7), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.h" #import diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index be7a8520a985..756aac14ca24 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -36,7 +36,7 @@ dev_dependencies: flutter_test: sdk: flutter pedantic: ^1.8.0 - pigeon: 0.1.5 + pigeon: 0.1.7 environment: sdk: ">=2.1.0 <3.0.0" diff --git a/packages/video_player/video_player_platform_interface/lib/messages.dart b/packages/video_player/video_player_platform_interface/lib/messages.dart index 8618c7925204..1e8dac054a18 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -1,6 +1,7 @@ -// Autogenerated from Pigeon (v0.1.5), do not edit directly. +// Autogenerated from Pigeon (v0.1.7), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import +// @dart = 2.8 import 'dart:async'; import 'package:flutter/services.dart'; import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; @@ -13,10 +14,9 @@ class TextureMessage { pigeonMap['textureId'] = textureId; return pigeonMap; } - // ignore: unused_element static TextureMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final TextureMessage result = TextureMessage(); @@ -39,10 +39,9 @@ class CreateMessage { pigeonMap['formatHint'] = formatHint; return pigeonMap; } - // ignore: unused_element static CreateMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final CreateMessage result = CreateMessage(); @@ -64,10 +63,9 @@ class LoopingMessage { pigeonMap['isLooping'] = isLooping; return pigeonMap; } - // ignore: unused_element static LoopingMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final LoopingMessage result = LoopingMessage(); @@ -87,10 +85,9 @@ class VolumeMessage { pigeonMap['volume'] = volume; return pigeonMap; } - // ignore: unused_element static VolumeMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final VolumeMessage result = VolumeMessage(); @@ -110,10 +107,9 @@ class PlaybackSpeedMessage { pigeonMap['speed'] = speed; return pigeonMap; } - // ignore: unused_element static PlaybackSpeedMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final PlaybackSpeedMessage result = PlaybackSpeedMessage(); @@ -133,10 +129,9 @@ class PositionMessage { pigeonMap['position'] = position; return pigeonMap; } - // ignore: unused_element static PositionMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final PositionMessage result = PositionMessage(); @@ -154,10 +149,9 @@ class MixWithOthersMessage { pigeonMap['mixWithOthers'] = mixWithOthers; return pigeonMap; } - // ignore: unused_element static MixWithOthersMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null) { + if (pigeonMap == null){ return null; } final MixWithOthersMessage result = MixWithOthersMessage(); @@ -168,15 +162,15 @@ class MixWithOthersMessage { class VideoPlayerApi { Future initialize() async { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + final Map replyMap = await channel.send(null); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -186,19 +180,19 @@ class VideoPlayerApi { } else { // noop } + } - Future create(CreateMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -208,19 +202,19 @@ class VideoPlayerApi { } else { return TextureMessage._fromMap(replyMap['result']); } + } - Future dispose(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -230,19 +224,19 @@ class VideoPlayerApi { } else { // noop } + } - Future setLooping(LoopingMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -252,19 +246,19 @@ class VideoPlayerApi { } else { // noop } + } - Future setVolume(VolumeMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -274,20 +268,19 @@ class VideoPlayerApi { } else { // noop } + } - Future setPlaybackSpeed(PlaybackSpeedMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', - StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -297,19 +290,19 @@ class VideoPlayerApi { } else { // noop } + } - Future play(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -319,19 +312,19 @@ class VideoPlayerApi { } else { // noop } + } - Future position(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -341,19 +334,19 @@ class VideoPlayerApi { } else { return PositionMessage._fromMap(replyMap['result']); } + } - Future seekTo(PositionMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -363,19 +356,19 @@ class VideoPlayerApi { } else { // noop } + } - Future pause(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -385,20 +378,19 @@ class VideoPlayerApi { } else { // noop } + } - Future setMixWithOthers(MixWithOthersMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', - StandardMessageCodec()); - + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -408,6 +400,7 @@ class VideoPlayerApi { } else { // noop } + } } @@ -425,131 +418,113 @@ abstract class TestHostVideoPlayerApi { void setMixWithOthers(MixWithOthersMessage arg); static void setup(TestHostVideoPlayerApi api) { { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.initialize', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; api.initialize(); return {}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; + final Map mapMessage = message as Map; final CreateMessage input = CreateMessage._fromMap(mapMessage); final TextureMessage output = api.create(input); return {'result': output._toMap()}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; + final Map mapMessage = message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.dispose(input); return {}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setLooping', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; + final Map mapMessage = message as Map; final LoopingMessage input = LoopingMessage._fromMap(mapMessage); api.setLooping(input); return {}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setVolume', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; + final Map mapMessage = message as Map; final VolumeMessage input = VolumeMessage._fromMap(mapMessage); api.setVolume(input); return {}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; - final PlaybackSpeedMessage input = - PlaybackSpeedMessage._fromMap(mapMessage); + final Map mapMessage = message as Map; + final PlaybackSpeedMessage input = PlaybackSpeedMessage._fromMap(mapMessage); api.setPlaybackSpeed(input); return {}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; + final Map mapMessage = message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.play(input); return {}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; + final Map mapMessage = message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); final PositionMessage output = api.position(input); return {'result': output._toMap()}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; + final Map mapMessage = message as Map; final PositionMessage input = PositionMessage._fromMap(mapMessage); api.seekTo(input); return {}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; + final Map mapMessage = message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.pause(input); return {}; }); } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = - message as Map; - final MixWithOthersMessage input = - MixWithOthersMessage._fromMap(mapMessage); + final Map mapMessage = message as Map; + final MixWithOthersMessage input = MixWithOthersMessage._fromMap(mapMessage); api.setMixWithOthers(input); return {}; }); } } } + From e36cf1fe418b1c232f3618250374e06140930218 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Thu, 24 Sep 2020 13:51:05 +0000 Subject: [PATCH 06/17] Format --- .../flutter/plugins/videoplayer/Messages.java | 544 +++++++++++------- .../lib/messages.dart | 262 +++++---- 2 files changed, 491 insertions(+), 315 deletions(-) diff --git a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java index fc73f0d16c63..78da7150edf0 100644 --- a/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java +++ b/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java @@ -6,7 +6,6 @@ import io.flutter.plugin.common.BasicMessageChannel; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.StandardMessageCodec; -import java.util.ArrayList; import java.util.HashMap; /** Generated class from Pigeon. */ @@ -16,18 +15,28 @@ public class Messages { /** Generated class from Pigeon that represents data sent in messages. */ public static class TextureMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); return toMapResult; } + static TextureMessage fromMap(HashMap map) { TextureMessage fromMapResult = new TextureMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); return fromMapResult; } } @@ -35,20 +44,44 @@ static TextureMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class CreateMessage { private String asset; - public String getAsset() { return asset; } - public void setAsset(String setterArg) { this.asset = setterArg; } + + public String getAsset() { + return asset; + } + + public void setAsset(String setterArg) { + this.asset = setterArg; + } private String uri; - public String getUri() { return uri; } - public void setUri(String setterArg) { this.uri = setterArg; } + + public String getUri() { + return uri; + } + + public void setUri(String setterArg) { + this.uri = setterArg; + } private String packageName; - public String getPackageName() { return packageName; } - public void setPackageName(String setterArg) { this.packageName = setterArg; } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String setterArg) { + this.packageName = setterArg; + } private String formatHint; - public String getFormatHint() { return formatHint; } - public void setFormatHint(String setterArg) { this.formatHint = setterArg; } + + public String getFormatHint() { + return formatHint; + } + + public void setFormatHint(String setterArg) { + this.formatHint = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -58,16 +91,17 @@ HashMap toMap() { toMapResult.put("formatHint", formatHint); return toMapResult; } + static CreateMessage fromMap(HashMap map) { CreateMessage fromMapResult = new CreateMessage(); Object asset = map.get("asset"); - fromMapResult.asset = (String)asset; + fromMapResult.asset = (String) asset; Object uri = map.get("uri"); - fromMapResult.uri = (String)uri; + fromMapResult.uri = (String) uri; Object packageName = map.get("packageName"); - fromMapResult.packageName = (String)packageName; + fromMapResult.packageName = (String) packageName; Object formatHint = map.get("formatHint"); - fromMapResult.formatHint = (String)formatHint; + fromMapResult.formatHint = (String) formatHint; return fromMapResult; } } @@ -75,12 +109,24 @@ static CreateMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class LoopingMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } private Boolean isLooping; - public Boolean getIsLooping() { return isLooping; } - public void setIsLooping(Boolean setterArg) { this.isLooping = setterArg; } + + public Boolean getIsLooping() { + return isLooping; + } + + public void setIsLooping(Boolean setterArg) { + this.isLooping = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -88,12 +134,16 @@ HashMap toMap() { toMapResult.put("isLooping", isLooping); return toMapResult; } + static LoopingMessage fromMap(HashMap map) { LoopingMessage fromMapResult = new LoopingMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); Object isLooping = map.get("isLooping"); - fromMapResult.isLooping = (Boolean)isLooping; + fromMapResult.isLooping = (Boolean) isLooping; return fromMapResult; } } @@ -101,12 +151,24 @@ static LoopingMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class VolumeMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } private Double volume; - public Double getVolume() { return volume; } - public void setVolume(Double setterArg) { this.volume = setterArg; } + + public Double getVolume() { + return volume; + } + + public void setVolume(Double setterArg) { + this.volume = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -114,12 +176,16 @@ HashMap toMap() { toMapResult.put("volume", volume); return toMapResult; } + static VolumeMessage fromMap(HashMap map) { VolumeMessage fromMapResult = new VolumeMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); Object volume = map.get("volume"); - fromMapResult.volume = (Double)volume; + fromMapResult.volume = (Double) volume; return fromMapResult; } } @@ -127,12 +193,24 @@ static VolumeMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class PlaybackSpeedMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } private Double speed; - public Double getSpeed() { return speed; } - public void setSpeed(Double setterArg) { this.speed = setterArg; } + + public Double getSpeed() { + return speed; + } + + public void setSpeed(Double setterArg) { + this.speed = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -140,12 +218,16 @@ HashMap toMap() { toMapResult.put("speed", speed); return toMapResult; } + static PlaybackSpeedMessage fromMap(HashMap map) { PlaybackSpeedMessage fromMapResult = new PlaybackSpeedMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); Object speed = map.get("speed"); - fromMapResult.speed = (Double)speed; + fromMapResult.speed = (Double) speed; return fromMapResult; } } @@ -153,12 +235,24 @@ static PlaybackSpeedMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class PositionMessage { private Long textureId; - public Long getTextureId() { return textureId; } - public void setTextureId(Long setterArg) { this.textureId = setterArg; } + + public Long getTextureId() { + return textureId; + } + + public void setTextureId(Long setterArg) { + this.textureId = setterArg; + } private Long position; - public Long getPosition() { return position; } - public void setPosition(Long setterArg) { this.position = setterArg; } + + public Long getPosition() { + return position; + } + + public void setPosition(Long setterArg) { + this.position = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); @@ -166,12 +260,19 @@ HashMap toMap() { toMapResult.put("position", position); return toMapResult; } + static PositionMessage fromMap(HashMap map) { PositionMessage fromMapResult = new PositionMessage(); Object textureId = map.get("textureId"); - fromMapResult.textureId = (textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId); + fromMapResult.textureId = + (textureId == null) + ? null + : ((textureId instanceof Integer) ? (Integer) textureId : (Long) textureId); Object position = map.get("position"); - fromMapResult.position = (position == null) ? null : ((position instanceof Integer) ? (Integer)position : (Long)position); + fromMapResult.position = + (position == null) + ? null + : ((position instanceof Integer) ? (Integer) position : (Long) position); return fromMapResult; } } @@ -179,269 +280,320 @@ static PositionMessage fromMap(HashMap map) { /** Generated class from Pigeon that represents data sent in messages. */ public static class MixWithOthersMessage { private Boolean mixWithOthers; - public Boolean getMixWithOthers() { return mixWithOthers; } - public void setMixWithOthers(Boolean setterArg) { this.mixWithOthers = setterArg; } + + public Boolean getMixWithOthers() { + return mixWithOthers; + } + + public void setMixWithOthers(Boolean setterArg) { + this.mixWithOthers = setterArg; + } HashMap toMap() { HashMap toMapResult = new HashMap<>(); toMapResult.put("mixWithOthers", mixWithOthers); return toMapResult; } + static MixWithOthersMessage fromMap(HashMap map) { MixWithOthersMessage fromMapResult = new MixWithOthersMessage(); Object mixWithOthers = map.get("mixWithOthers"); - fromMapResult.mixWithOthers = (Boolean)mixWithOthers; + fromMapResult.mixWithOthers = (Boolean) mixWithOthers; return fromMapResult; } } - /** Generated interface from Pigeon that represents a handler of messages from Flutter.*/ + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface VideoPlayerApi { void initialize(); + TextureMessage create(CreateMessage arg); + void dispose(TextureMessage arg); + void setLooping(LoopingMessage arg); + void setVolume(VolumeMessage arg); + void setPlaybackSpeed(PlaybackSpeedMessage arg); + void play(TextureMessage arg); + PositionMessage position(TextureMessage arg); + void seekTo(PositionMessage arg); + void pause(TextureMessage arg); + void setMixWithOthers(MixWithOthersMessage arg); /** Sets up an instance of `VideoPlayerApi` to handle messages through the `binaryMessenger` */ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.initialize", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.initialize", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - api.initialize(); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + api.initialize(); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.create", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.create", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - CreateMessage input = CreateMessage.fromMap((HashMap)message); - TextureMessage output = api.create(input); - wrapped.put("result", output.toMap()); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + CreateMessage input = CreateMessage.fromMap((HashMap) message); + TextureMessage output = api.create(input); + wrapped.put("result", output.toMap()); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.dispose", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.dispose", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap)message); - api.dispose(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap) message); + api.dispose(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setLooping", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setLooping", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - LoopingMessage input = LoopingMessage.fromMap((HashMap)message); - api.setLooping(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + LoopingMessage input = LoopingMessage.fromMap((HashMap) message); + api.setLooping(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setVolume", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setVolume", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - VolumeMessage input = VolumeMessage.fromMap((HashMap)message); - api.setVolume(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + VolumeMessage input = VolumeMessage.fromMap((HashMap) message); + api.setVolume(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap)message); - api.setPlaybackSpeed(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap) message); + api.setPlaybackSpeed(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.play", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.play", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap)message); - api.play(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap) message); + api.play(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.position", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.position", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap)message); - PositionMessage output = api.position(input); - wrapped.put("result", output.toMap()); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap) message); + PositionMessage output = api.position(input); + wrapped.put("result", output.toMap()); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.seekTo", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.seekTo", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - PositionMessage input = PositionMessage.fromMap((HashMap)message); - api.seekTo(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + PositionMessage input = PositionMessage.fromMap((HashMap) message); + api.seekTo(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.pause", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.pause", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap)message); - api.pause(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + TextureMessage input = TextureMessage.fromMap((HashMap) message); + api.pause(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } { BasicMessageChannel channel = - new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", new StandardMessageCodec()); + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", + new StandardMessageCodec()); if (api != null) { - channel.setMessageHandler((message, reply) -> { - HashMap wrapped = new HashMap<>(); - try { - @SuppressWarnings("ConstantConditions") - MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap)message); - api.setMixWithOthers(input); - wrapped.put("result", null); - } - catch (Exception exception) { - wrapped.put("error", wrapError(exception)); - } - reply.reply(wrapped); - }); + channel.setMessageHandler( + (message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap) message); + api.setMixWithOthers(input); + wrapped.put("result", null); + } catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); } else { channel.setMessageHandler(null); } } } } + private static HashMap wrapError(Exception exception) { HashMap errorMap = new HashMap<>(); errorMap.put("message", exception.toString()); diff --git a/packages/video_player/video_player_platform_interface/lib/messages.dart b/packages/video_player/video_player_platform_interface/lib/messages.dart index 1e8dac054a18..bfe65f1fd2ea 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -14,9 +14,10 @@ class TextureMessage { pigeonMap['textureId'] = textureId; return pigeonMap; } + // ignore: unused_element static TextureMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final TextureMessage result = TextureMessage(); @@ -39,9 +40,10 @@ class CreateMessage { pigeonMap['formatHint'] = formatHint; return pigeonMap; } + // ignore: unused_element static CreateMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final CreateMessage result = CreateMessage(); @@ -63,9 +65,10 @@ class LoopingMessage { pigeonMap['isLooping'] = isLooping; return pigeonMap; } + // ignore: unused_element static LoopingMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final LoopingMessage result = LoopingMessage(); @@ -85,9 +88,10 @@ class VolumeMessage { pigeonMap['volume'] = volume; return pigeonMap; } + // ignore: unused_element static VolumeMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final VolumeMessage result = VolumeMessage(); @@ -107,9 +111,10 @@ class PlaybackSpeedMessage { pigeonMap['speed'] = speed; return pigeonMap; } + // ignore: unused_element static PlaybackSpeedMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final PlaybackSpeedMessage result = PlaybackSpeedMessage(); @@ -129,9 +134,10 @@ class PositionMessage { pigeonMap['position'] = position; return pigeonMap; } + // ignore: unused_element static PositionMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final PositionMessage result = PositionMessage(); @@ -149,9 +155,10 @@ class MixWithOthersMessage { pigeonMap['mixWithOthers'] = mixWithOthers; return pigeonMap; } + // ignore: unused_element static MixWithOthersMessage _fromMap(Map pigeonMap) { - if (pigeonMap == null){ + if (pigeonMap == null) { return null; } final MixWithOthersMessage result = MixWithOthersMessage(); @@ -162,15 +169,15 @@ class MixWithOthersMessage { class VideoPlayerApi { Future initialize() async { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + final Map replyMap = await channel.send(null); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -180,19 +187,19 @@ class VideoPlayerApi { } else { // noop } - } + Future create(CreateMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -202,19 +209,19 @@ class VideoPlayerApi { } else { return TextureMessage._fromMap(replyMap['result']); } - } + Future dispose(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -224,19 +231,19 @@ class VideoPlayerApi { } else { // noop } - } + Future setLooping(LoopingMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -246,19 +253,19 @@ class VideoPlayerApi { } else { // noop } - } + Future setVolume(VolumeMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -268,19 +275,20 @@ class VideoPlayerApi { } else { // noop } - } + Future setPlaybackSpeed(PlaybackSpeedMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', + StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -290,19 +298,19 @@ class VideoPlayerApi { } else { // noop } - } + Future play(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -312,19 +320,19 @@ class VideoPlayerApi { } else { // noop } - } + Future position(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -334,19 +342,19 @@ class VideoPlayerApi { } else { return PositionMessage._fromMap(replyMap['result']); } - } + Future seekTo(PositionMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -356,19 +364,19 @@ class VideoPlayerApi { } else { // noop } - } + Future pause(TextureMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -378,19 +386,20 @@ class VideoPlayerApi { } else { // noop } - } + Future setMixWithOthers(MixWithOthersMessage arg) async { final Map requestMap = arg._toMap(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); - + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', + StandardMessageCodec()); + final Map replyMap = await channel.send(requestMap); if (replyMap == null) { throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - details: null); + code: 'channel-error', + message: 'Unable to establish connection on channel.', + details: null); } else if (replyMap['error'] != null) { final Map error = replyMap['error']; throw PlatformException( @@ -400,7 +409,6 @@ class VideoPlayerApi { } else { // noop } - } } @@ -418,113 +426,129 @@ abstract class TestHostVideoPlayerApi { void setMixWithOthers(MixWithOthersMessage arg); static void setup(TestHostVideoPlayerApi api) { { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.initialize', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { api.initialize(); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final CreateMessage input = CreateMessage._fromMap(mapMessage); final TextureMessage output = api.create(input); return {'result': output._toMap()}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.dispose(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setLooping', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final LoopingMessage input = LoopingMessage._fromMap(mapMessage); api.setLooping(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setVolume', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final VolumeMessage input = VolumeMessage._fromMap(mapMessage); api.setVolume(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final PlaybackSpeedMessage input = PlaybackSpeedMessage._fromMap(mapMessage); + final Map mapMessage = + message as Map; + final PlaybackSpeedMessage input = + PlaybackSpeedMessage._fromMap(mapMessage); api.setPlaybackSpeed(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.play(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); final PositionMessage output = api.position(input); return {'result': output._toMap()}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final PositionMessage input = PositionMessage._fromMap(mapMessage); api.seekTo(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; + final Map mapMessage = + message as Map; final TextureMessage input = TextureMessage._fromMap(mapMessage); api.pause(input); return {}; }); } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', + StandardMessageCodec()); channel.setMockMessageHandler((dynamic message) async { - final Map mapMessage = message as Map; - final MixWithOthersMessage input = MixWithOthersMessage._fromMap(mapMessage); + final Map mapMessage = + message as Map; + final MixWithOthersMessage input = + MixWithOthersMessage._fromMap(mapMessage); api.setMixWithOthers(input); return {}; }); } } } - From 82ce9436ab5088bbd32130eea6df78b777dffdf0 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Thu, 24 Sep 2020 15:45:02 +0000 Subject: [PATCH 07/17] Dart SDK constraint --- .../video_player/video_player_platform_interface/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index 4b61245653fc..cc3cd79f1f33 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -17,5 +17,5 @@ dev_dependencies: pedantic: ^1.8.0 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.8.0 <3.0.0" flutter: ">=1.10.0 <2.0.0" From 9668a4714697f4d07ea6490c8c04c46eb0f4bda7 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 18:56:30 +0000 Subject: [PATCH 08/17] Address suggestions --- packages/video_player/video_player/README.md | 8 +++-- .../video_player/example/lib/main.dart | 33 ++++++++++++++----- .../video_player/lib/video_player.dart | 12 +++++-- .../video_player/video_player/pubspec.yaml | 2 +- .../lib/method_channel_video_player.dart | 2 +- .../lib/video_player_web.dart | 4 +-- .../video_player_web/pubspec.yaml | 2 +- 7 files changed, 43 insertions(+), 20 deletions(-) diff --git a/packages/video_player/video_player/README.md b/packages/video_player/video_player/README.md index fa86ace9c7dc..43e999c12290 100644 --- a/packages/video_player/video_player/README.md +++ b/packages/video_player/video_player/README.md @@ -143,7 +143,9 @@ the rate of playback for your video. For example, when given a value of `2.0`, your video will play at 2x the regular playback speed and so on. -See the documentation for how different values for the playback speed are handled on the different -platforms. +On web, the audio will be muted at some speeds (when the browser determines the sound would not be +useful anymore, e.g. `speed < 0.25` or `speed > 5`). On Android, some very extreme speeds will not +be played back accurately, but the video will still be played back at a capped speed. And on iOS, +speeds greater than `2.0` are not always supported, however, the plugin will throw an error for that. -Furthermore, see the example app to see an example playback speed implementation. +Furthermore, see the example app for an example playback speed implementation. diff --git a/packages/video_player/video_player/example/lib/main.dart b/packages/video_player/video_player/example/lib/main.dart index d595910425c3..a99b9da6bd0c 100644 --- a/packages/video_player/video_player/example/lib/main.dart +++ b/packages/video_player/video_player/example/lib/main.dart @@ -307,16 +307,31 @@ class _ControlsOverlay extends StatelessWidget { ), Align( alignment: Alignment.topRight, - child: FlatButton( - onPressed: () { - final currentIndex = _examplePlaybackRates - .indexOf(controller.value.playbackSpeed), - nextIndex = (currentIndex + 1) % _examplePlaybackRates.length; - - // Go through all provided example playback rates. - controller.setPlaybackSpeed(_examplePlaybackRates[nextIndex]); + child: PopupMenuButton( + initialValue: controller.value.playbackSpeed, + tooltip: 'Playback speed', + onSelected: (speed) { + controller.setPlaybackSpeed(speed); }, - child: Text('${controller.value.playbackSpeed}x'), + itemBuilder: (context) { + return [ + for (final speed in _examplePlaybackRates) + PopupMenuItem( + value: speed, + child: Text('${speed}x'), + ) + ]; + }, + child: Padding( + padding: const EdgeInsets.symmetric( + // Using less vertical padding as the text is also longer + // horizontally, so it feels like it would need more spacing + // horizontally (matching the aspect ratio of the video). + vertical: 12, + horizontal: 16, + ), + child: Text('${controller.value.playbackSpeed}x'), + ), ), ), ], diff --git a/packages/video_player/video_player/lib/video_player.dart b/packages/video_player/video_player/lib/video_player.dart index 8c8927e1c881..d11b781514a5 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -297,7 +297,6 @@ class VideoPlayerController extends ValueNotifier { initializingCompleter.complete(null); _applyLooping(); _applyVolume(); - _applyPlaybackSpeed(); _applyPlayPause(); break; case VideoEventType.completed: @@ -477,7 +476,8 @@ class VideoPlayerController extends ValueNotifier { /// Sets the playback speed of [this]. /// /// [speed] indicates a speed value with different platforms accepting - /// different ranges for speed values (that must not be negative). + /// different ranges for speed values. The [speed] must be greater than 0. + /// /// The values will be handled as follows: /// * On web, no exceptions will be thrown, however, different browser /// implementations will e.g. mute audio. @@ -488,13 +488,19 @@ class VideoPlayerController extends ValueNotifier { /// the plugin also reports errors. /// * On Android, the handling is similar to web, where the plugin will not /// report any errors, however, you cannot expect support for all speed - /// values (even though it should go way above `2.0`). + /// values. In that case, your video will still be played back, but the + /// speed will be clamped by ExoPlayer. Future setPlaybackSpeed(double speed) async { if (speed < 0) { throw ArgumentError.value( speed, 'Negative playback speeds are generally unsupported.', ); + } else if (speed == 0) { + throw ArgumentError.value( + speed, + 'Zero playback speed is generally unsupported. Consider using [pause].', + ); } value = value.copyWith(playbackSpeed: speed); diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 756aac14ca24..3f3640c3d689 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -39,5 +39,5 @@ dev_dependencies: pigeon: 0.1.7 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.8.0 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" diff --git a/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart b/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart index d28d7ddea8df..0ea443fb6e12 100644 --- a/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart +++ b/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart @@ -73,7 +73,7 @@ class MethodChannelVideoPlayer extends VideoPlayerPlatform { @override Future setPlaybackSpeed(int textureId, double speed) { - assert(speed >= 0); + assert(speed > 0); return _api.setPlaybackSpeed(PlaybackSpeedMessage() ..textureId = textureId diff --git a/packages/video_player/video_player_web/lib/video_player_web.dart b/packages/video_player/video_player_web/lib/video_player_web.dart index 073144f91435..251da3779e7f 100644 --- a/packages/video_player/video_player_web/lib/video_player_web.dart +++ b/packages/video_player/video_player_web/lib/video_player_web.dart @@ -121,7 +121,7 @@ class VideoPlayerPlugin extends VideoPlayerPlatform { @override Future setPlaybackSpeed(int textureId, double speed) async { - assert(speed >= 0); + assert(speed > 0); return _videoPlayers[textureId].setPlaybackSpeed(speed); } @@ -240,7 +240,7 @@ class _VideoPlayer { } void setPlaybackSpeed(double speed) { - assert(speed >= 0); + assert(speed > 0); videoElement.playbackRate = speed; } diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index da5d39bdc820..9886374960b6 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -29,5 +29,5 @@ dev_dependencies: pedantic: ^1.8.0 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.8.0 <3.0.0" flutter: ">=1.12.8 <2.0.0" From 8866e26b16b6bc41ea7e16f5cbb0e4a0fa7845d9 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 19:07:27 +0000 Subject: [PATCH 09/17] Format --- .../video_player/ios/Classes/messages.h | 57 ++--- .../video_player/ios/Classes/messages.m | 210 +++++++++--------- 2 files changed, 134 insertions(+), 133 deletions(-) diff --git a/packages/video_player/video_player/ios/Classes/messages.h b/packages/video_player/video_player/ios/Classes/messages.h index 945bc13e21de..3c68b3dd24d4 100644 --- a/packages/video_player/video_player/ios/Classes/messages.h +++ b/packages/video_player/video_player/ios/Classes/messages.h @@ -16,54 +16,59 @@ NS_ASSUME_NONNULL_BEGIN @class FLTMixWithOthersMessage; @interface FLTTextureMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber * textureId; +@property(nonatomic, strong, nullable) NSNumber *textureId; @end @interface FLTCreateMessage : NSObject -@property(nonatomic, copy, nullable) NSString * asset; -@property(nonatomic, copy, nullable) NSString * uri; -@property(nonatomic, copy, nullable) NSString * packageName; -@property(nonatomic, copy, nullable) NSString * formatHint; +@property(nonatomic, copy, nullable) NSString *asset; +@property(nonatomic, copy, nullable) NSString *uri; +@property(nonatomic, copy, nullable) NSString *packageName; +@property(nonatomic, copy, nullable) NSString *formatHint; @end @interface FLTLoopingMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber * textureId; -@property(nonatomic, strong, nullable) NSNumber * isLooping; +@property(nonatomic, strong, nullable) NSNumber *textureId; +@property(nonatomic, strong, nullable) NSNumber *isLooping; @end @interface FLTVolumeMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber * textureId; -@property(nonatomic, strong, nullable) NSNumber * volume; +@property(nonatomic, strong, nullable) NSNumber *textureId; +@property(nonatomic, strong, nullable) NSNumber *volume; @end @interface FLTPlaybackSpeedMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber * textureId; -@property(nonatomic, strong, nullable) NSNumber * speed; +@property(nonatomic, strong, nullable) NSNumber *textureId; +@property(nonatomic, strong, nullable) NSNumber *speed; @end @interface FLTPositionMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber * textureId; -@property(nonatomic, strong, nullable) NSNumber * position; +@property(nonatomic, strong, nullable) NSNumber *textureId; +@property(nonatomic, strong, nullable) NSNumber *position; @end @interface FLTMixWithOthersMessage : NSObject -@property(nonatomic, strong, nullable) NSNumber * mixWithOthers; +@property(nonatomic, strong, nullable) NSNumber *mixWithOthers; @end @protocol FLTVideoPlayerApi --(void)initialize:(FlutterError *_Nullable *_Nonnull)error; --(nullable FLTTextureMessage *)create:(FLTCreateMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(void)dispose:(FLTTextureMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(void)setLooping:(FLTLoopingMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(void)setVolume:(FLTVolumeMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(void)setPlaybackSpeed:(FLTPlaybackSpeedMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(void)play:(FLTTextureMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(nullable FLTPositionMessage *)position:(FLTTextureMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(void)seekTo:(FLTPositionMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(void)pause:(FLTTextureMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; --(void)setMixWithOthers:(FLTMixWithOthersMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; +- (void)initialize:(FlutterError *_Nullable *_Nonnull)error; +- (nullable FLTTextureMessage *)create:(FLTCreateMessage *)input + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)dispose:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setLooping:(FLTLoopingMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setVolume:(FLTVolumeMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setPlaybackSpeed:(FLTPlaybackSpeedMessage *)input + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)play:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable FLTPositionMessage *)position:(FLTTextureMessage *)input + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)seekTo:(FLTPositionMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; +- (void)pause:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setMixWithOthers:(FLTMixWithOthersMessage *)input + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FLTVideoPlayerApiSetup(id binaryMessenger, id _Nullable api); +extern void FLTVideoPlayerApiSetup(id binaryMessenger, + id _Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/video_player/video_player/ios/Classes/messages.m b/packages/video_player/video_player/ios/Classes/messages.m index 92563bda9d38..b651a6137c11 100644 --- a/packages/video_player/video_player/ios/Classes/messages.m +++ b/packages/video_player/video_player/ios/Classes/messages.m @@ -7,67 +7,67 @@ #error File requires ARC to be enabled. #endif -static NSDictionary* wrapResult(NSDictionary *result, FlutterError *error) { +static NSDictionary *wrapResult(NSDictionary *result, FlutterError *error) { NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { - errorDict = [NSDictionary dictionaryWithObjectsAndKeys: - (error.code ? error.code : [NSNull null]), @"code", - (error.message ? error.message : [NSNull null]), @"message", - (error.details ? error.details : [NSNull null]), @"details", - nil]; + errorDict = [NSDictionary + dictionaryWithObjectsAndKeys:(error.code ? error.code : [NSNull null]), @"code", + (error.message ? error.message : [NSNull null]), @"message", + (error.details ? error.details : [NSNull null]), @"details", + nil]; } - return [NSDictionary dictionaryWithObjectsAndKeys: - (result ? result : [NSNull null]), @"result", - errorDict, @"error", - nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:(result ? result : [NSNull null]), @"result", + errorDict, @"error", nil]; } @interface FLTTextureMessage () -+(FLTTextureMessage*)fromMap:(NSDictionary*)dict; --(NSDictionary*)toMap; ++ (FLTTextureMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface FLTCreateMessage () -+(FLTCreateMessage*)fromMap:(NSDictionary*)dict; --(NSDictionary*)toMap; ++ (FLTCreateMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface FLTLoopingMessage () -+(FLTLoopingMessage*)fromMap:(NSDictionary*)dict; --(NSDictionary*)toMap; ++ (FLTLoopingMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface FLTVolumeMessage () -+(FLTVolumeMessage*)fromMap:(NSDictionary*)dict; --(NSDictionary*)toMap; ++ (FLTVolumeMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface FLTPlaybackSpeedMessage () -+(FLTPlaybackSpeedMessage*)fromMap:(NSDictionary*)dict; --(NSDictionary*)toMap; ++ (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface FLTPositionMessage () -+(FLTPositionMessage*)fromMap:(NSDictionary*)dict; --(NSDictionary*)toMap; ++ (FLTPositionMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface FLTMixWithOthersMessage () -+(FLTMixWithOthersMessage*)fromMap:(NSDictionary*)dict; --(NSDictionary*)toMap; ++ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @implementation FLTTextureMessage -+(FLTTextureMessage*)fromMap:(NSDictionary*)dict { - FLTTextureMessage* result = [[FLTTextureMessage alloc] init]; ++ (FLTTextureMessage *)fromMap:(NSDictionary *)dict { + FLTTextureMessage *result = [[FLTTextureMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; } return result; } --(NSDictionary*)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", nil]; +- (NSDictionary *)toMap { + return + [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), + @"textureId", nil]; } @end @implementation FLTCreateMessage -+(FLTCreateMessage*)fromMap:(NSDictionary*)dict { - FLTCreateMessage* result = [[FLTCreateMessage alloc] init]; ++ (FLTCreateMessage *)fromMap:(NSDictionary *)dict { + FLTCreateMessage *result = [[FLTCreateMessage alloc] init]; result.asset = dict[@"asset"]; if ((NSNull *)result.asset == [NSNull null]) { result.asset = nil; @@ -86,14 +86,20 @@ +(FLTCreateMessage*)fromMap:(NSDictionary*)dict { } return result; } --(NSDictionary*)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.asset ? self.asset : [NSNull null]), @"asset", (self.uri ? self.uri : [NSNull null]), @"uri", (self.packageName ? self.packageName : [NSNull null]), @"packageName", (self.formatHint ? self.formatHint : [NSNull null]), @"formatHint", nil]; +- (NSDictionary *)toMap { + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.asset ? self.asset : [NSNull null]), @"asset", + (self.uri ? self.uri : [NSNull null]), @"uri", + (self.packageName ? self.packageName : [NSNull null]), + @"packageName", + (self.formatHint ? self.formatHint : [NSNull null]), + @"formatHint", nil]; } @end @implementation FLTLoopingMessage -+(FLTLoopingMessage*)fromMap:(NSDictionary*)dict { - FLTLoopingMessage* result = [[FLTLoopingMessage alloc] init]; ++ (FLTLoopingMessage *)fromMap:(NSDictionary *)dict { + FLTLoopingMessage *result = [[FLTLoopingMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; @@ -104,14 +110,17 @@ +(FLTLoopingMessage*)fromMap:(NSDictionary*)dict { } return result; } --(NSDictionary*)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", (self.isLooping ? self.isLooping : [NSNull null]), @"isLooping", nil]; +- (NSDictionary *)toMap { + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.isLooping ? self.isLooping : [NSNull null]), @"isLooping", + nil]; } @end @implementation FLTVolumeMessage -+(FLTVolumeMessage*)fromMap:(NSDictionary*)dict { - FLTVolumeMessage* result = [[FLTVolumeMessage alloc] init]; ++ (FLTVolumeMessage *)fromMap:(NSDictionary *)dict { + FLTVolumeMessage *result = [[FLTVolumeMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; @@ -122,14 +131,16 @@ +(FLTVolumeMessage*)fromMap:(NSDictionary*)dict { } return result; } --(NSDictionary*)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", (self.volume ? self.volume : [NSNull null]), @"volume", nil]; +- (NSDictionary *)toMap { + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.volume ? self.volume : [NSNull null]), @"volume", nil]; } @end @implementation FLTPlaybackSpeedMessage -+(FLTPlaybackSpeedMessage*)fromMap:(NSDictionary*)dict { - FLTPlaybackSpeedMessage* result = [[FLTPlaybackSpeedMessage alloc] init]; ++ (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict { + FLTPlaybackSpeedMessage *result = [[FLTPlaybackSpeedMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; @@ -140,14 +151,16 @@ +(FLTPlaybackSpeedMessage*)fromMap:(NSDictionary*)dict { } return result; } --(NSDictionary*)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", (self.speed ? self.speed : [NSNull null]), @"speed", nil]; +- (NSDictionary *)toMap { + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.speed ? self.speed : [NSNull null]), @"speed", nil]; } @end @implementation FLTPositionMessage -+(FLTPositionMessage*)fromMap:(NSDictionary*)dict { - FLTPositionMessage* result = [[FLTPositionMessage alloc] init]; ++ (FLTPositionMessage *)fromMap:(NSDictionary *)dict { + FLTPositionMessage *result = [[FLTPositionMessage alloc] init]; result.textureId = dict[@"textureId"]; if ((NSNull *)result.textureId == [NSNull null]) { result.textureId = nil; @@ -158,47 +171,49 @@ +(FLTPositionMessage*)fromMap:(NSDictionary*)dict { } return result; } --(NSDictionary*)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", (self.position ? self.position : [NSNull null]), @"position", nil]; +- (NSDictionary *)toMap { + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.position ? self.position : [NSNull null]), @"position", + nil]; } @end @implementation FLTMixWithOthersMessage -+(FLTMixWithOthersMessage*)fromMap:(NSDictionary*)dict { - FLTMixWithOthersMessage* result = [[FLTMixWithOthersMessage alloc] init]; ++ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict { + FLTMixWithOthersMessage *result = [[FLTMixWithOthersMessage alloc] init]; result.mixWithOthers = dict[@"mixWithOthers"]; if ((NSNull *)result.mixWithOthers == [NSNull null]) { result.mixWithOthers = nil; } return result; } --(NSDictionary*)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.mixWithOthers ? self.mixWithOthers : [NSNull null]), @"mixWithOthers", nil]; +- (NSDictionary *)toMap { + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.mixWithOthers ? self.mixWithOthers : [NSNull null]), + @"mixWithOthers", nil]; } @end void FLTVideoPlayerApiSetup(id binaryMessenger, id api) { { - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:@"dev.flutter.pigeon.VideoPlayerApi.initialize" - binaryMessenger:binaryMessenger]; + binaryMessenger:binaryMessenger]; if (api) { [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api initialize:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:@"dev.flutter.pigeon.VideoPlayerApi.create" - binaryMessenger:binaryMessenger]; + binaryMessenger:binaryMessenger]; if (api) { [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; @@ -206,16 +221,14 @@ void FLTVideoPlayerApiSetup(id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id Date: Fri, 25 Sep 2020 20:34:23 +0000 Subject: [PATCH 10/17] Update docs --- packages/video_player/video_player/README.md | 5 +---- .../video_player/video_player/lib/video_player.dart | 12 ++++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/video_player/video_player/README.md b/packages/video_player/video_player/README.md index 43e999c12290..9c0e6b1abb28 100644 --- a/packages/video_player/video_player/README.md +++ b/packages/video_player/video_player/README.md @@ -143,9 +143,6 @@ the rate of playback for your video. For example, when given a value of `2.0`, your video will play at 2x the regular playback speed and so on. -On web, the audio will be muted at some speeds (when the browser determines the sound would not be -useful anymore, e.g. `speed < 0.25` or `speed > 5`). On Android, some very extreme speeds will not -be played back accurately, but the video will still be played back at a capped speed. And on iOS, -speeds greater than `2.0` are not always supported, however, the plugin will throw an error for that. +To learn about playback speed limitations, see the [`setPlaybackSpeed` method documentation](https://pub.dev/documentation/video_player/latest/video_player/VideoPlayerController/setPlaybackSpeed.html). Furthermore, see the example app for an example playback speed implementation. diff --git a/packages/video_player/video_player/lib/video_player.dart b/packages/video_player/video_player/lib/video_player.dart index d11b781514a5..bf98096af45d 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -479,17 +479,17 @@ class VideoPlayerController extends ValueNotifier { /// different ranges for speed values. The [speed] must be greater than 0. /// /// The values will be handled as follows: - /// * On web, no exceptions will be thrown, however, different browser - /// implementations will e.g. mute audio. + /// * On web, the audio will be muted at some speed when the browser + /// determines that the sound would not be useful anymore. For example, /// "Gecko mutes the sound outside the range `0.25` to `5.0`" (see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate). + /// * On Android, some very extreme speeds will not be played back accurately. + /// Instead, your video will still be played back, but the speed will be + /// clamped by ExoPlayer (but the values are allowed by the player, like on + /// web). /// * On iOS, you can sometimes not go above `2.0` playback speed on a video. /// An error will be thrown for if the option is unsupported. It is also /// possible that your specific video cannot be slowed down, in which case /// the plugin also reports errors. - /// * On Android, the handling is similar to web, where the plugin will not - /// report any errors, however, you cannot expect support for all speed - /// values. In that case, your video will still be played back, but the - /// speed will be clamped by ExoPlayer. Future setPlaybackSpeed(double speed) async { if (speed < 0) { throw ArgumentError.value( From ca989f5e6db31ceb85541fa2893f1a820569e101 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 22:07:50 +0000 Subject: [PATCH 11/17] Description --- packages/video_player/video_player/pubspec.yaml | 2 +- packages/video_player/video_player_web/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 3f3640c3d689..ca5e801c2248 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -1,6 +1,6 @@ name: video_player description: Flutter plugin for displaying inline video with other Flutter - widgets on Android and iOS. + widgets on Android, iOS, and web. # 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump # the version to 2.0.0. # See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index 9886374960b6..a803e86fea0b 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -1,5 +1,5 @@ name: video_player_web -description: Web platform implementation of video_player +description: Web platform implementation of video_player. homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_web # 0.1.y+z is compatible with 1.0.0, if you land a breaking change bump # the version to 2.0.0. From eb86f3500872539246a8a987012804ef12092fb7 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 22:09:19 +0000 Subject: [PATCH 12/17] Web dependency --- packages/video_player/video_player_web/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_web/pubspec.yaml b/packages/video_player/video_player_web/pubspec.yaml index a803e86fea0b..98191bf6ba85 100644 --- a/packages/video_player/video_player_web/pubspec.yaml +++ b/packages/video_player/video_player_web/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: flutter_web_plugins: sdk: flutter meta: ^1.1.7 - video_player_platform_interface: ^2.0.0 + video_player_platform_interface: ^2.2.0 dev_dependencies: flutter_test: From 5e6cdc8f40eb006728f68a5fca59a62effeab064 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 22:15:42 +0000 Subject: [PATCH 13/17] Bump --- packages/video_player/video_player/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index ca5e801c2248..09dc9a9bb984 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -20,7 +20,7 @@ flutter: dependencies: meta: ^1.0.5 - video_player_platform_interface: ^2.1.0 + video_player_platform_interface: ^2.2.0 # The design on https://flutter.dev/go/federated-plugins was to leave # this constraint as "any". We cannot do it right now as it fails pub publish From 4657063139f612cbb800675f619dd0a6d0ac6f12 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 22:17:22 +0000 Subject: [PATCH 14/17] Add new line back --- .../video_player_web/test/video_player_web_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/video_player/video_player_web/test/video_player_web_test.dart b/packages/video_player/video_player_web/test/video_player_web_test.dart index 115d3b35ef1b..453079bfcd40 100644 --- a/packages/video_player/video_player_web/test/video_player_web_test.dart +++ b/packages/video_player/video_player_web/test/video_player_web_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @TestOn('browser') + import 'dart:async'; import 'package:flutter/services.dart'; From 25600cc752237738ddfad0b443af159da1aeb308 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 22:28:58 +0000 Subject: [PATCH 15/17] Adjust main tests --- .../video_player/test/video_player_test.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/video_player/video_player/test/video_player_test.dart b/packages/video_player/video_player/test/video_player_test.dart index e9f4e47d2ddc..35cab6204965 100644 --- a/packages/video_player/video_player/test/video_player_test.dart +++ b/packages/video_player/video_player/test/video_player_test.dart @@ -262,7 +262,14 @@ void main() { await controller.play(); expect(controller.value.isPlaying, isTrue); - expect(fakeVideoPlayerPlatform.calls.last, 'play'); + + // The two last calls will be "play" and then "setPlaybackSpeed". The + // reason for this is that "play" calls "setPlaybackSpeed" internally. + expect( + fakeVideoPlayerPlatform + .calls[fakeVideoPlayerPlatform.calls.length - 2], + 'play'); + expect(fakeVideoPlayerPlatform.calls.last, 'setPlaybackSpeed'); }); test('setLooping', () async { @@ -641,9 +648,9 @@ void main() { }); } -class FakeVideoPlayerPlatform extends VideoPlayerApiTest { +class FakeVideoPlayerPlatform extends TestHostVideoPlayerApi { FakeVideoPlayerPlatform() { - VideoPlayerApiTestSetup(this); + TestHostVideoPlayerApi.setup(this); } Completer initialized = Completer(); From 5c3a108adf8d819ea5963e33727999324b95021e Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 23:35:14 +0000 Subject: [PATCH 16/17] .. --- .../video_player/video_player/CHANGELOG.md | 393 ------------------ 1 file changed, 393 deletions(-) delete mode 100644 packages/video_player/video_player/CHANGELOG.md diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md deleted file mode 100644 index 37eb6745f75c..000000000000 --- a/packages/video_player/video_player/CHANGELOG.md +++ /dev/null @@ -1,393 +0,0 @@ -## 0.11.0 - -* Added option to set the video playback speed on the video controller. -* **Minor breaking change**: fixed `VideoPlayerValue.toString` to insert a comma after `isBuffering`. - -## 0.10.12+4 - -* Keep handling deprecated Android v1 classes for backward compatibility. - -## 0.10.12+3 - -* Avoiding uses or overrides a deprecated API in `VideoPlayerPlugin` class. - -## 0.10.12+2 - -* Fix `setMixWithOthers` test. - -## 0.10.12+1 - -* Depend on the version of `video_player_platform_interface` that contains the new `VideoPlayerOptions` class. - -## 0.10.12 - -* Introduce VideoPlayerOptions to set the audio mix mode. - -## 0.10.11+2 - -* Fix aspectRatio calculation when size.width or size.height are zero. - -## 0.10.11+1 - -* Post-v2 Android embedding cleanups. - -## 0.10.11 - -* iOS: Fixed crash when detaching from a dying engine. -* Android: Fixed exception when detaching from any engine. - -## 0.10.10 - -* Migrated to [pigeon](https://pub.dev/packages/pigeon). - -## 0.10.9+2 - -* Declare API stability and compatibility with `1.0.0` (more details at: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0). - -## 0.10.9+1 - -* Readme updated to include web support and details on how to use for web - -## 0.10.9 - -* Remove Android dependencies fallback. -* Require Flutter SDK 1.12.13+hotfix.5 or greater. -* Fix CocoaPods podspec lint warnings. - -## 0.10.8+2 - -* Replace deprecated `getFlutterEngine` call on Android. - -## 0.10.8+1 - -* Make the pedantic dev_dependency explicit. - -## 0.10.8 - -* Added support for cleaning up the plugin if used for add-to-app (Flutter - v1.15.3 is required for that feature). - - -## 0.10.7 - -* `VideoPlayerController` support for reading closed caption files. -* `VideoPlayerValue` has a `caption` field for reading the current closed caption at any given time. - -## 0.10.6 - -* `ClosedCaptionFile` and `SubRipCaptionFile` classes added to read - [SubRip](https://en.wikipedia.org/wiki/SubRip) files into dart objects. - -## 0.10.5+3 - -* Add integration instructions for the `web` platform. - -## 0.10.5+2 - -* Make sure the plugin is correctly initialized - -## 0.10.5+1 - -* Fixes issue where `initialize()` `Future` stalls when failing to load source - data and does not throw an error. - -## 0.10.5 - -* Support `web` by default. -* Require Flutter SDK 1.12.13+hotfix.4 or greater. - -## 0.10.4+2 - -* Remove the deprecated `author:` field form pubspec.yaml -* Migrate the plugin to the pubspec platforms manifest. -* Require Flutter SDK 1.10.0 or greater. - -## 0.10.4+1 - -* Fix pedantic lints. This fixes some potential race conditions in cases where - futures within some video_player methods weren't being awaited correctly. - -## 0.10.4 - -* Port plugin code to use the federated Platform Interface, instead of a MethodChannel directly. - -## 0.10.3+3 - -* Add DartDocs and unit tests. - -## 0.10.3+2 - -* Update the homepage to point to the new plugin location - -## 0.10.3+1 - -* Dispose `FLTVideoPlayer` in `onTextureUnregistered` callback on iOS. -* Add a temporary fix to dispose the `FLTVideoPlayer` with a delay to avoid race condition. -* Updated the example app to include a new page that pop back after video is done playing. - -## 0.10.3 - -* Add support for the v2 Android embedding. This shouldn't impact existing - functionality. - -## 0.10.2+6 - -* Remove AndroidX warnings. - -## 0.10.2+5 - -* Update unit test for compatibility with Flutter stable branch. - -## 0.10.2+4 - -* Define clang module for iOS. - -## 0.10.2+3 - -* Fix bug where formatHint was not being pass down to network sources. - -## 0.10.2+2 - -* Update and migrate iOS example project. - -## 0.10.2+1 - -* Use DefaultHttpDataSourceFactory only when network schemas and use -DefaultHttpDataSourceFactory by default. - -## 0.10.2 - -* **Android Only** Adds optional VideoFormat used to signal what format the plugin should try. - -## 0.10.1+7 - -* Fix tests by ignoring deprecated member use. - -## 0.10.1+6 - -* [iOS] Fixed a memory leak with notification observing. - -## 0.10.1+5 - -* Fix race condition while disposing the VideoController. - -## 0.10.1+4 - -* Fixed syntax error in README.md. - -## 0.10.1+3 - -* Add missing template type parameter to `invokeMethod` calls. -* Bump minimum Flutter version to 1.5.0. -* Replace invokeMethod with invokeMapMethod wherever necessary. - -## 0.10.1+2 - -* Example: Fixed tab display and added scroll view - -## 0.10.1+1 - -* iOS: Avoid deprecated `seekToTime` API - -## 0.10.1 - -* iOS: Consider a player only `initialized` once duration is determined. - -## 0.10.0+8 - -* iOS: Fix an issue where the player sends initialization message incorrectly. - -* Fix a few other IDE warnings. - - -## 0.10.0+7 - -* Android: Fix issue where buffering status in percentage instead of milliseconds - -* Android: Update buffering status everytime we notify for position change - -## 0.10.0+6 - -* Android: Fix missing call to `event.put("event", "completed");` which makes it possible to detect when the video is over. - -## 0.10.0+5 - -* Fixed iOS build warnings about implicit retains. - -## 0.10.0+4 - -* Android: Upgrade ExoPlayer to 2.9.6. - -## 0.10.0+3 - -* Fix divide by zero bug on iOS. - -## 0.10.0+2 - -* Added supported format documentation in README. - -## 0.10.0+1 - -* Log a more detailed warning at build time about the previous AndroidX - migration. - -## 0.10.0 - -* **Breaking change**. Migrate from the deprecated original Android Support - Library to AndroidX. This shouldn't result in any functional changes, but it - requires any Android apps using this plugin to [also - migrate](https://developer.android.com/jetpack/androidx/migrate) if they're - using the original support library. - -## 0.9.0 - -* Fixed the aspect ratio and orientation of videos. Videos are now properly displayed when recorded - in portrait mode both in iOS and Android. - -## 0.8.0 - -* Android: Upgrade ExoPlayer to 2.9.1 -* Android: Use current gradle dependencies -* Android 9 compatibility fixes for Demo App - -## 0.7.2 - -* Updated to use factories on exoplayer `MediaSource`s for Android instead of the now-deprecated constructors. - -## 0.7.1 - -* Fixed null exception on Android when the video has a width or height of 0. - -## 0.7.0 - -* Add a unit test for controller and texture changes. This is a breaking change since the interface - had to be cleaned up to facilitate faking. - -## 0.6.6 - -* Fix the condition where the player doesn't update when attached controller is changed. - -## 0.6.5 - -* Eliminate race conditions around initialization: now initialization events are queued and guaranteed - to be delivered to the Dart side. VideoPlayer widget is rebuilt upon completion of initialization. - -## 0.6.4 - -* Android: add support for hls, dash and ss video formats. - -## 0.6.3 - -* iOS: Allow audio playback in silent mode. - -## 0.6.2 - -* `VideoPlayerController.seekTo()` is now frame accurate on both platforms. - -## 0.6.1 - -* iOS: add missing observer removals to prevent crashes on deallocation. - -## 0.6.0 - -* Android: use ExoPlayer instead of MediaPlayer for better video format support. - -## 0.5.5 - -* **Breaking change** `VideoPlayerController.initialize()` now only completes after the controller is initialized. -* Updated example in README.md. - -## 0.5.4 - -* Updated Gradle tooling to match Android Studio 3.1.2. - -## 0.5.3 - -* Added video buffering status. - -## 0.5.2 - -* Fixed a bug on iOS that could lead to missing initialization. -* Added support for HLS video on iOS. - -## 0.5.1 - -* Fixed bug on video loop feature for iOS. - -## 0.5.0 - -* Added the constructor `VideoPlayerController.file`. -* **Breaking change**. Changed `VideoPlayerController.isNetwork` to - an enum `VideoPlayerController.dataSourceType`. - -## 0.4.1 - -* Updated Flutter SDK constraint to reflect the changes in v0.4.0. - -## 0.4.0 - -* **Breaking change**. Removed the `VideoPlayerController` constructor -* Added two new factory constructors `VideoPlayerController.asset` and - `VideoPlayerController.network` to respectively play a video from the - Flutter assets and from a network uri. - -## 0.3.0 - -* **Breaking change**. Set SDK constraints to match the Flutter beta release. - -## 0.2.1 - -* Fixed some signatures to account for strong mode runtime errors. -* Fixed spelling mistake in toString output. - -## 0.2.0 - -* **Breaking change**. Renamed `VideoPlayerController.isErroneous` to `VideoPlayerController.hasError`. -* Updated documentation of when fields are available on `VideoPlayerController`. -* Updated links in README.md. - -## 0.1.1 - -* Simplified and upgraded Android project template to Android SDK 27. -* Moved Android package to io.flutter.plugins. -* Fixed warnings from the Dart 2.0 analyzer. - -## 0.1.0 - -* **Breaking change**. Upgraded to Gradle 4.1 and Android Studio Gradle plugin - 3.0.1. Older Flutter projects need to upgrade their Gradle setup as well in - order to use this version of the plugin. Instructions can be found - [here](https://github.com/flutter/flutter/wiki/Updating-Flutter-projects-to-Gradle-4.1-and-Android-Studio-Gradle-plugin-3.0.1). - -## 0.0.7 - -* Added access to the video size. -* Made the VideoProgressIndicator render using a LinearProgressIndicator. - -## 0.0.6 - -* Fixed a bug related to hot restart on Android. - -## 0.0.5 - -* Added VideoPlayerValue.toString(). -* Added FLT prefix to iOS types. - -## 0.0.4 - -* The player will now pause on app pause, and resume on app resume. -* Implemented scrubbing on the progress bar. - -## 0.0.3 - -* Made creating a VideoPlayerController a synchronous operation. Must be followed by a call to initialize(). -* Added VideoPlayerController.setVolume(). -* Moved the package to flutter/plugins github repo. - -## 0.0.2 - -* Fix meta dependency version. - -## 0.0.1 - -* Initial release From bdfedc4735247648ad793a7256c901a0da465c7d Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 25 Sep 2020 23:37:03 +0000 Subject: [PATCH 17/17] Include changelog --- .../video_player/video_player/CHANGELOG.md | 398 ++++++++++++++++++ 1 file changed, 398 insertions(+) create mode 100644 packages/video_player/video_player/CHANGELOG.md diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md new file mode 100644 index 000000000000..f7fad2648b3e --- /dev/null +++ b/packages/video_player/video_player/CHANGELOG.md @@ -0,0 +1,398 @@ +## 0.11.0 + +* Added option to set the video playback speed on the video controller. +* **Minor breaking change**: fixed `VideoPlayerValue.toString` to insert a comma after `isBuffering`. + +## 0.10.12+5 + +* Depend on `video_player_platform_interface` version that contains the new `TestHostVideoPlayerApi` + in order for tests to pass using the latest dependency. + +## 0.10.12+4 + +* Keep handling deprecated Android v1 classes for backward compatibility. + +## 0.10.12+3 + +* Avoiding uses or overrides a deprecated API in `VideoPlayerPlugin` class. + +## 0.10.12+2 + +* Fix `setMixWithOthers` test. + +## 0.10.12+1 + +* Depend on the version of `video_player_platform_interface` that contains the new `VideoPlayerOptions` class. + +## 0.10.12 + +* Introduce VideoPlayerOptions to set the audio mix mode. + +## 0.10.11+2 + +* Fix aspectRatio calculation when size.width or size.height are zero. + +## 0.10.11+1 + +* Post-v2 Android embedding cleanups. + +## 0.10.11 + +* iOS: Fixed crash when detaching from a dying engine. +* Android: Fixed exception when detaching from any engine. + +## 0.10.10 + +* Migrated to [pigeon](https://pub.dev/packages/pigeon). + +## 0.10.9+2 + +* Declare API stability and compatibility with `1.0.0` (more details at: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0). + +## 0.10.9+1 + +* Readme updated to include web support and details on how to use for web + +## 0.10.9 + +* Remove Android dependencies fallback. +* Require Flutter SDK 1.12.13+hotfix.5 or greater. +* Fix CocoaPods podspec lint warnings. + +## 0.10.8+2 + +* Replace deprecated `getFlutterEngine` call on Android. + +## 0.10.8+1 + +* Make the pedantic dev_dependency explicit. + +## 0.10.8 + +* Added support for cleaning up the plugin if used for add-to-app (Flutter + v1.15.3 is required for that feature). + + +## 0.10.7 + +* `VideoPlayerController` support for reading closed caption files. +* `VideoPlayerValue` has a `caption` field for reading the current closed caption at any given time. + +## 0.10.6 + +* `ClosedCaptionFile` and `SubRipCaptionFile` classes added to read + [SubRip](https://en.wikipedia.org/wiki/SubRip) files into dart objects. + +## 0.10.5+3 + +* Add integration instructions for the `web` platform. + +## 0.10.5+2 + +* Make sure the plugin is correctly initialized + +## 0.10.5+1 + +* Fixes issue where `initialize()` `Future` stalls when failing to load source + data and does not throw an error. + +## 0.10.5 + +* Support `web` by default. +* Require Flutter SDK 1.12.13+hotfix.4 or greater. + +## 0.10.4+2 + +* Remove the deprecated `author:` field form pubspec.yaml +* Migrate the plugin to the pubspec platforms manifest. +* Require Flutter SDK 1.10.0 or greater. + +## 0.10.4+1 + +* Fix pedantic lints. This fixes some potential race conditions in cases where + futures within some video_player methods weren't being awaited correctly. + +## 0.10.4 + +* Port plugin code to use the federated Platform Interface, instead of a MethodChannel directly. + +## 0.10.3+3 + +* Add DartDocs and unit tests. + +## 0.10.3+2 + +* Update the homepage to point to the new plugin location + +## 0.10.3+1 + +* Dispose `FLTVideoPlayer` in `onTextureUnregistered` callback on iOS. +* Add a temporary fix to dispose the `FLTVideoPlayer` with a delay to avoid race condition. +* Updated the example app to include a new page that pop back after video is done playing. + +## 0.10.3 + +* Add support for the v2 Android embedding. This shouldn't impact existing + functionality. + +## 0.10.2+6 + +* Remove AndroidX warnings. + +## 0.10.2+5 + +* Update unit test for compatibility with Flutter stable branch. + +## 0.10.2+4 + +* Define clang module for iOS. + +## 0.10.2+3 + +* Fix bug where formatHint was not being pass down to network sources. + +## 0.10.2+2 + +* Update and migrate iOS example project. + +## 0.10.2+1 + +* Use DefaultHttpDataSourceFactory only when network schemas and use +DefaultHttpDataSourceFactory by default. + +## 0.10.2 + +* **Android Only** Adds optional VideoFormat used to signal what format the plugin should try. + +## 0.10.1+7 + +* Fix tests by ignoring deprecated member use. + +## 0.10.1+6 + +* [iOS] Fixed a memory leak with notification observing. + +## 0.10.1+5 + +* Fix race condition while disposing the VideoController. + +## 0.10.1+4 + +* Fixed syntax error in README.md. + +## 0.10.1+3 + +* Add missing template type parameter to `invokeMethod` calls. +* Bump minimum Flutter version to 1.5.0. +* Replace invokeMethod with invokeMapMethod wherever necessary. + +## 0.10.1+2 + +* Example: Fixed tab display and added scroll view + +## 0.10.1+1 + +* iOS: Avoid deprecated `seekToTime` API + +## 0.10.1 + +* iOS: Consider a player only `initialized` once duration is determined. + +## 0.10.0+8 + +* iOS: Fix an issue where the player sends initialization message incorrectly. + +* Fix a few other IDE warnings. + + +## 0.10.0+7 + +* Android: Fix issue where buffering status in percentage instead of milliseconds + +* Android: Update buffering status everytime we notify for position change + +## 0.10.0+6 + +* Android: Fix missing call to `event.put("event", "completed");` which makes it possible to detect when the video is over. + +## 0.10.0+5 + +* Fixed iOS build warnings about implicit retains. + +## 0.10.0+4 + +* Android: Upgrade ExoPlayer to 2.9.6. + +## 0.10.0+3 + +* Fix divide by zero bug on iOS. + +## 0.10.0+2 + +* Added supported format documentation in README. + +## 0.10.0+1 + +* Log a more detailed warning at build time about the previous AndroidX + migration. + +## 0.10.0 + +* **Breaking change**. Migrate from the deprecated original Android Support + Library to AndroidX. This shouldn't result in any functional changes, but it + requires any Android apps using this plugin to [also + migrate](https://developer.android.com/jetpack/androidx/migrate) if they're + using the original support library. + +## 0.9.0 + +* Fixed the aspect ratio and orientation of videos. Videos are now properly displayed when recorded + in portrait mode both in iOS and Android. + +## 0.8.0 + +* Android: Upgrade ExoPlayer to 2.9.1 +* Android: Use current gradle dependencies +* Android 9 compatibility fixes for Demo App + +## 0.7.2 + +* Updated to use factories on exoplayer `MediaSource`s for Android instead of the now-deprecated constructors. + +## 0.7.1 + +* Fixed null exception on Android when the video has a width or height of 0. + +## 0.7.0 + +* Add a unit test for controller and texture changes. This is a breaking change since the interface + had to be cleaned up to facilitate faking. + +## 0.6.6 + +* Fix the condition where the player doesn't update when attached controller is changed. + +## 0.6.5 + +* Eliminate race conditions around initialization: now initialization events are queued and guaranteed + to be delivered to the Dart side. VideoPlayer widget is rebuilt upon completion of initialization. + +## 0.6.4 + +* Android: add support for hls, dash and ss video formats. + +## 0.6.3 + +* iOS: Allow audio playback in silent mode. + +## 0.6.2 + +* `VideoPlayerController.seekTo()` is now frame accurate on both platforms. + +## 0.6.1 + +* iOS: add missing observer removals to prevent crashes on deallocation. + +## 0.6.0 + +* Android: use ExoPlayer instead of MediaPlayer for better video format support. + +## 0.5.5 + +* **Breaking change** `VideoPlayerController.initialize()` now only completes after the controller is initialized. +* Updated example in README.md. + +## 0.5.4 + +* Updated Gradle tooling to match Android Studio 3.1.2. + +## 0.5.3 + +* Added video buffering status. + +## 0.5.2 + +* Fixed a bug on iOS that could lead to missing initialization. +* Added support for HLS video on iOS. + +## 0.5.1 + +* Fixed bug on video loop feature for iOS. + +## 0.5.0 + +* Added the constructor `VideoPlayerController.file`. +* **Breaking change**. Changed `VideoPlayerController.isNetwork` to + an enum `VideoPlayerController.dataSourceType`. + +## 0.4.1 + +* Updated Flutter SDK constraint to reflect the changes in v0.4.0. + +## 0.4.0 + +* **Breaking change**. Removed the `VideoPlayerController` constructor +* Added two new factory constructors `VideoPlayerController.asset` and + `VideoPlayerController.network` to respectively play a video from the + Flutter assets and from a network uri. + +## 0.3.0 + +* **Breaking change**. Set SDK constraints to match the Flutter beta release. + +## 0.2.1 + +* Fixed some signatures to account for strong mode runtime errors. +* Fixed spelling mistake in toString output. + +## 0.2.0 + +* **Breaking change**. Renamed `VideoPlayerController.isErroneous` to `VideoPlayerController.hasError`. +* Updated documentation of when fields are available on `VideoPlayerController`. +* Updated links in README.md. + +## 0.1.1 + +* Simplified and upgraded Android project template to Android SDK 27. +* Moved Android package to io.flutter.plugins. +* Fixed warnings from the Dart 2.0 analyzer. + +## 0.1.0 + +* **Breaking change**. Upgraded to Gradle 4.1 and Android Studio Gradle plugin + 3.0.1. Older Flutter projects need to upgrade their Gradle setup as well in + order to use this version of the plugin. Instructions can be found + [here](https://github.com/flutter/flutter/wiki/Updating-Flutter-projects-to-Gradle-4.1-and-Android-Studio-Gradle-plugin-3.0.1). + +## 0.0.7 + +* Added access to the video size. +* Made the VideoProgressIndicator render using a LinearProgressIndicator. + +## 0.0.6 + +* Fixed a bug related to hot restart on Android. + +## 0.0.5 + +* Added VideoPlayerValue.toString(). +* Added FLT prefix to iOS types. + +## 0.0.4 + +* The player will now pause on app pause, and resume on app resume. +* Implemented scrubbing on the progress bar. + +## 0.0.3 + +* Made creating a VideoPlayerController a synchronous operation. Must be followed by a call to initialize(). +* Added VideoPlayerController.setVolume(). +* Moved the package to flutter/plugins github repo. + +## 0.0.2 + +* Fix meta dependency version. + +## 0.0.1 + +* Initial release