From aa5a24b3c726d2404362f5321498b0ae9af8d83c Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 30 Aug 2021 14:24:00 -0700 Subject: [PATCH 1/2] [video_player_platform_interface] upgraded pigeon to 1.0 --- .../CHANGELOG.md | 4 + .../lib/messages.dart | 307 +++++++++++------- .../lib/test.dart | 212 ++++++++---- .../pubspec.yaml | 2 +- 4 files changed, 344 insertions(+), 181 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index 24631513f800..118751bef87f 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 @@ +## 5.0.0 + +* Upgraded to Pigeon 1.0. + ## 4.1.0 * Add `httpHeaders` to `DataSource` 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 0ddbfaeaf247..6358d7d3cc83 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -1,14 +1,15 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -// Autogenerated from Pigeon (v0.1.21), do not edit directly. +// +// Autogenerated from Pigeon (v1.0.0), 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 +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name // @dart = 2.12 import 'dart:async'; import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; import 'package:flutter/services.dart'; class TextureMessage { @@ -26,34 +27,6 @@ class TextureMessage { } } -class CreateMessage { - String? asset; - String? uri; - String? packageName; - String? formatHint; - Map? httpHeaders; - - Object encode() { - final Map pigeonMap = {}; - pigeonMap['asset'] = asset; - pigeonMap['uri'] = uri; - pigeonMap['packageName'] = packageName; - pigeonMap['formatHint'] = formatHint; - pigeonMap['httpHeaders'] = httpHeaders; - return pigeonMap; - } - - static CreateMessage decode(Object message) { - final Map pigeonMap = message as Map; - return CreateMessage() - ..asset = pigeonMap['asset'] as String? - ..uri = pigeonMap['uri'] as String? - ..packageName = pigeonMap['packageName'] as String? - ..formatHint = pigeonMap['formatHint'] as String? - ..httpHeaders = pigeonMap['httpHeaders'] as Map?; - } -} - class LoopingMessage { int? textureId; bool? isLooping; @@ -130,6 +103,35 @@ class PositionMessage { } } +class CreateMessage { + String? asset; + String? uri; + String? packageName; + String? formatHint; + Map? httpHeaders; + + Object encode() { + final Map pigeonMap = {}; + pigeonMap['asset'] = asset; + pigeonMap['uri'] = uri; + pigeonMap['packageName'] = packageName; + pigeonMap['formatHint'] = formatHint; + pigeonMap['httpHeaders'] = httpHeaders; + return pigeonMap; + } + + static CreateMessage decode(Object message) { + final Map pigeonMap = message as Map; + return CreateMessage() + ..asset = pigeonMap['asset'] as String? + ..uri = pigeonMap['uri'] as String? + ..packageName = pigeonMap['packageName'] as String? + ..formatHint = pigeonMap['formatHint'] as String? + ..httpHeaders = (pigeonMap['httpHeaders'] as Map?) + ?.cast(); + } +} + class MixWithOthersMessage { bool? mixWithOthers; @@ -146,10 +148,81 @@ class MixWithOthersMessage { } } +class _VideoPlayerApiCodec extends StandardMessageCodec { + const _VideoPlayerApiCodec(); + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is CreateMessage) { + buffer.putUint8(128); + writeValue(buffer, value.encode()); + } else if (value is LoopingMessage) { + buffer.putUint8(129); + writeValue(buffer, value.encode()); + } else if (value is MixWithOthersMessage) { + buffer.putUint8(130); + writeValue(buffer, value.encode()); + } else if (value is PlaybackSpeedMessage) { + buffer.putUint8(131); + writeValue(buffer, value.encode()); + } else if (value is PositionMessage) { + buffer.putUint8(132); + writeValue(buffer, value.encode()); + } else if (value is TextureMessage) { + buffer.putUint8(133); + writeValue(buffer, value.encode()); + } else if (value is VolumeMessage) { + buffer.putUint8(134); + writeValue(buffer, value.encode()); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 128: + return CreateMessage.decode(readValue(buffer)!); + + case 129: + return LoopingMessage.decode(readValue(buffer)!); + + case 130: + return MixWithOthersMessage.decode(readValue(buffer)!); + + case 131: + return PlaybackSpeedMessage.decode(readValue(buffer)!); + + case 132: + return PositionMessage.decode(readValue(buffer)!); + + case 133: + return TextureMessage.decode(readValue(buffer)!); + + case 134: + return VolumeMessage.decode(readValue(buffer)!); + + default: + return super.readValueOfType(type, buffer); + } + } +} + class VideoPlayerApi { + /// Constructor for [VideoPlayerApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + VideoPlayerApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec codec = _VideoPlayerApiCodec(); + Future initialize() async { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.initialize', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send(null) as Map?; if (replyMap == null) { @@ -160,23 +233,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } - Future create(CreateMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + Future create(CreateMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.create', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -185,23 +258,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - return TextureMessage.decode(replyMap['result']!); + return (replyMap['result'] as TextureMessage?)!; } } - Future dispose(TextureMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + Future dispose(TextureMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.dispose', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -210,23 +283,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } - Future setLooping(LoopingMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + Future setLooping(LoopingMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setLooping', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -235,23 +308,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } - Future setVolume(VolumeMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + Future setVolume(VolumeMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setVolume', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -260,24 +333,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } - Future setPlaybackSpeed(PlaybackSpeedMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', - StandardMessageCodec()); + Future setPlaybackSpeed(PlaybackSpeedMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -286,23 +358,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } - Future play(TextureMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + Future play(TextureMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.play', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -311,23 +383,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } - Future position(TextureMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + Future position(TextureMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.position', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -336,23 +408,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - return PositionMessage.decode(replyMap['result']!); + return (replyMap['result'] as PositionMessage?)!; } } - Future seekTo(PositionMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + Future seekTo(PositionMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.seekTo', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -361,23 +433,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } - Future pause(TextureMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + Future pause(TextureMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.pause', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -386,24 +458,23 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } - Future setMixWithOthers(MixWithOthersMessage arg) async { - final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', - StandardMessageCodec()); + Future setMixWithOthers(MixWithOthersMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send(encoded) as Map?; + await channel.send([arg_msg]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -412,14 +483,14 @@ class VideoPlayerApi { ); } else if (replyMap['error'] != null) { final Map error = - replyMap['error'] as Map; + (replyMap['error'] as Map?)!; throw PlatformException( - code: error['code'] as String, + code: (error['code'] as String?)!, message: error['message'] as String?, details: error['details'], ); } else { - // noop + return; } } } diff --git a/packages/video_player/video_player_platform_interface/lib/test.dart b/packages/video_player/video_player_platform_interface/lib/test.dart index b4fd81f44f41..f9655b113740 100644 --- a/packages/video_player/video_player_platform_interface/lib/test.dart +++ b/packages/video_player/video_player_platform_interface/lib/test.dart @@ -1,35 +1,97 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -// Autogenerated from Pigeon (v0.1.21), do not edit directly. +// +// Autogenerated from Pigeon (v1.0.0), 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.12 import 'dart:async'; import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'messages.dart'; +class _TestHostVideoPlayerApiCodec extends StandardMessageCodec { + const _TestHostVideoPlayerApiCodec(); + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is CreateMessage) { + buffer.putUint8(128); + writeValue(buffer, value.encode()); + } else if (value is LoopingMessage) { + buffer.putUint8(129); + writeValue(buffer, value.encode()); + } else if (value is MixWithOthersMessage) { + buffer.putUint8(130); + writeValue(buffer, value.encode()); + } else if (value is PlaybackSpeedMessage) { + buffer.putUint8(131); + writeValue(buffer, value.encode()); + } else if (value is PositionMessage) { + buffer.putUint8(132); + writeValue(buffer, value.encode()); + } else if (value is TextureMessage) { + buffer.putUint8(133); + writeValue(buffer, value.encode()); + } else if (value is VolumeMessage) { + buffer.putUint8(134); + writeValue(buffer, value.encode()); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 128: + return CreateMessage.decode(readValue(buffer)!); + + case 129: + return LoopingMessage.decode(readValue(buffer)!); + + case 130: + return MixWithOthersMessage.decode(readValue(buffer)!); + + case 131: + return PlaybackSpeedMessage.decode(readValue(buffer)!); + + case 132: + return PositionMessage.decode(readValue(buffer)!); + + case 133: + return TextureMessage.decode(readValue(buffer)!); + + case 134: + return VolumeMessage.decode(readValue(buffer)!); + + default: + return super.readValueOfType(type, buffer); + } + } +} + abstract class TestHostVideoPlayerApi { + static const MessageCodec codec = _TestHostVideoPlayerApiCodec(); + 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); + TextureMessage create(CreateMessage msg); + 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); + void pause(TextureMessage msg); + void setMixWithOthers(MixWithOthersMessage msg); static void setup(TestHostVideoPlayerApi? api) { { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.initialize', - StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.initialize', codec); if (api == null) { channel.setMockMessageHandler(null); } else { @@ -42,156 +104,182 @@ abstract class TestHostVideoPlayerApi { } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.create', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.create was null. Expected CreateMessage.'); - final CreateMessage input = CreateMessage.decode(message!); - final TextureMessage output = api.create(input); - return {'result': output.encode()}; + 'Argument for dev.flutter.pigeon.VideoPlayerApi.create was null.'); + final List args = (message as List?)!; + final CreateMessage? arg_msg = args[0] as CreateMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.create was null, expected non-null CreateMessage.'); + final TextureMessage output = api.create(arg_msg!); + return {'result': output}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.dispose', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.dispose was null. Expected TextureMessage.'); - final TextureMessage input = TextureMessage.decode(message!); - api.dispose(input); + 'Argument for dev.flutter.pigeon.VideoPlayerApi.dispose was null.'); + final List args = (message as List?)!; + final TextureMessage? arg_msg = args[0] as TextureMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.dispose was null, expected non-null TextureMessage.'); + api.dispose(arg_msg!); return {}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setLooping', - StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.setLooping', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.setLooping was null. Expected LoopingMessage.'); - final LoopingMessage input = LoopingMessage.decode(message!); - api.setLooping(input); + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setLooping was null.'); + final List args = (message as List?)!; + final LoopingMessage? arg_msg = args[0] as LoopingMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setLooping was null, expected non-null LoopingMessage.'); + api.setLooping(arg_msg!); return {}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setVolume', - StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.setVolume', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.setVolume was null. Expected VolumeMessage.'); - final VolumeMessage input = VolumeMessage.decode(message!); - api.setVolume(input); + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setVolume was null.'); + final List args = (message as List?)!; + final VolumeMessage? arg_msg = args[0] as VolumeMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setVolume was null, expected non-null VolumeMessage.'); + api.setVolume(arg_msg!); return {}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', - StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed was null. Expected PlaybackSpeedMessage.'); - final PlaybackSpeedMessage input = - PlaybackSpeedMessage.decode(message!); - api.setPlaybackSpeed(input); + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed was null.'); + final List args = (message as List?)!; + final PlaybackSpeedMessage? arg_msg = + args[0] as PlaybackSpeedMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed was null, expected non-null PlaybackSpeedMessage.'); + api.setPlaybackSpeed(arg_msg!); return {}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.play', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.play was null. Expected TextureMessage.'); - final TextureMessage input = TextureMessage.decode(message!); - api.play(input); + 'Argument for dev.flutter.pigeon.VideoPlayerApi.play was null.'); + final List args = (message as List?)!; + final TextureMessage? arg_msg = args[0] as TextureMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.play was null, expected non-null TextureMessage.'); + api.play(arg_msg!); return {}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.position', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.position was null. Expected TextureMessage.'); - final TextureMessage input = TextureMessage.decode(message!); - final PositionMessage output = api.position(input); - return {'result': output.encode()}; + 'Argument for dev.flutter.pigeon.VideoPlayerApi.position was null.'); + final List args = (message as List?)!; + final TextureMessage? arg_msg = args[0] as TextureMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.position was null, expected non-null TextureMessage.'); + final PositionMessage output = api.position(arg_msg!); + return {'result': output}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.seekTo', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.seekTo was null. Expected PositionMessage.'); - final PositionMessage input = PositionMessage.decode(message!); - api.seekTo(input); + 'Argument for dev.flutter.pigeon.VideoPlayerApi.seekTo was null.'); + final List args = (message as List?)!; + final PositionMessage? arg_msg = args[0] as PositionMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.seekTo was null, expected non-null PositionMessage.'); + api.seekTo(arg_msg!); return {}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.pause', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.pause was null. Expected TextureMessage.'); - final TextureMessage input = TextureMessage.decode(message!); - api.pause(input); + 'Argument for dev.flutter.pigeon.VideoPlayerApi.pause was null.'); + final List args = (message as List?)!; + final TextureMessage? arg_msg = args[0] as TextureMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.pause was null, expected non-null TextureMessage.'); + api.pause(arg_msg!); return {}; }); } } { const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', - StandardMessageCodec()); + 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', codec); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers was null. Expected MixWithOthersMessage.'); - final MixWithOthersMessage input = - MixWithOthersMessage.decode(message!); - api.setMixWithOthers(input); + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers was null.'); + final List args = (message as List?)!; + final MixWithOthersMessage? arg_msg = + args[0] as MixWithOthersMessage?; + assert(arg_msg != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers was null, expected non-null MixWithOthersMessage.'); + api.setMixWithOthers(arg_msg!); return {}; }); } diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index 2a0ef10a9d2b..16f24e3f8042 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/master/packages/video_player issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 # 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: 4.1.0 +version: 5.0.0 environment: sdk: ">=2.12.0 <3.0.0" From b8d3c7cd00a5014cb1ec2feda45c1d1138b095a0 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 30 Aug 2021 14:24:45 -0700 Subject: [PATCH 2/2] [video_player] upgraded to pigeon 1.0 --- .../video_player/video_player/CHANGELOG.md | 3 +- .../flutter/plugins/videoplayer/Messages.java | 479 ++++++++++-------- .../ios/Classes/FLTVideoPlayerPlugin.m | 2 +- .../video_player/ios/Classes/messages.h | 48 +- .../video_player/ios/Classes/messages.m | 319 ++++++++---- .../video_player/pigeons/copyright.txt | 4 + .../video_player/pigeons/messages.dart | 68 +-- .../video_player/video_player/pubspec.yaml | 11 +- 8 files changed, 581 insertions(+), 353 deletions(-) create mode 100644 packages/video_player/video_player/pigeons/copyright.txt diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index f07bb5f66f8c..a99b5f5b9df6 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.1.15 +* Upgraded Pigeon to 1.0 * Updated Android lint settings. ## 2.1.14 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 e0a4a3b8dd08..24197b7515b9 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,19 +1,24 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -// Autogenerated from Pigeon (v0.1.21), do not edit directly. +// +// Autogenerated from Pigeon (v1.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon package io.flutter.plugins.videoplayer; import io.flutter.plugin.common.BasicMessageChannel; import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; /** Generated class from Pigeon. */ -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) public class Messages { /** Generated class from Pigeon that represents data sent in messages. */ @@ -28,13 +33,13 @@ public void setTextureId(Long setterArg) { this.textureId = setterArg; } - HashMap toMap() { - HashMap toMapResult = new HashMap<>(); + Map toMap() { + Map toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); return toMapResult; } - static TextureMessage fromMap(HashMap map) { + static TextureMessage fromMap(Map map) { TextureMessage fromMapResult = new TextureMessage(); Object textureId = map.get("textureId"); fromMapResult.textureId = @@ -45,84 +50,6 @@ 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; - } - - private String uri; - - 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; - } - - private String formatHint; - - public String getFormatHint() { - return formatHint; - } - - public void setFormatHint(String setterArg) { - this.formatHint = setterArg; - } - - private HashMap httpHeaders; - - public HashMap getHttpHeaders() { - return httpHeaders; - } - - public void setHttpHeaders(HashMap setterArg) { - this.httpHeaders = setterArg; - } - - HashMap toMap() { - HashMap toMapResult = new HashMap<>(); - toMapResult.put("asset", asset); - toMapResult.put("uri", uri); - toMapResult.put("packageName", packageName); - toMapResult.put("formatHint", formatHint); - toMapResult.put("httpHeaders", httpHeaders); - return toMapResult; - } - - static CreateMessage fromMap(HashMap map) { - CreateMessage fromMapResult = new CreateMessage(); - 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; - Object httpHeaders = map.get("httpHeaders"); - fromMapResult.httpHeaders = (HashMap) httpHeaders; - return fromMapResult; - } - } - /** Generated class from Pigeon that represents data sent in messages. */ public static class LoopingMessage { private Long textureId; @@ -145,14 +72,14 @@ public void setIsLooping(Boolean setterArg) { this.isLooping = setterArg; } - HashMap toMap() { - HashMap toMapResult = new HashMap<>(); + Map toMap() { + Map toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); toMapResult.put("isLooping", isLooping); return toMapResult; } - static LoopingMessage fromMap(HashMap map) { + static LoopingMessage fromMap(Map map) { LoopingMessage fromMapResult = new LoopingMessage(); Object textureId = map.get("textureId"); fromMapResult.textureId = @@ -187,14 +114,14 @@ public void setVolume(Double setterArg) { this.volume = setterArg; } - HashMap toMap() { - HashMap toMapResult = new HashMap<>(); + Map toMap() { + Map toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); toMapResult.put("volume", volume); return toMapResult; } - static VolumeMessage fromMap(HashMap map) { + static VolumeMessage fromMap(Map map) { VolumeMessage fromMapResult = new VolumeMessage(); Object textureId = map.get("textureId"); fromMapResult.textureId = @@ -229,14 +156,14 @@ public void setSpeed(Double setterArg) { this.speed = setterArg; } - HashMap toMap() { - HashMap toMapResult = new HashMap<>(); + Map toMap() { + Map toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); toMapResult.put("speed", speed); return toMapResult; } - static PlaybackSpeedMessage fromMap(HashMap map) { + static PlaybackSpeedMessage fromMap(Map map) { PlaybackSpeedMessage fromMapResult = new PlaybackSpeedMessage(); Object textureId = map.get("textureId"); fromMapResult.textureId = @@ -271,14 +198,14 @@ public void setPosition(Long setterArg) { this.position = setterArg; } - HashMap toMap() { - HashMap toMapResult = new HashMap<>(); + Map toMap() { + Map toMapResult = new HashMap<>(); toMapResult.put("textureId", textureId); toMapResult.put("position", position); return toMapResult; } - static PositionMessage fromMap(HashMap map) { + static PositionMessage fromMap(Map map) { PositionMessage fromMapResult = new PositionMessage(); Object textureId = map.get("textureId"); fromMapResult.textureId = @@ -294,6 +221,84 @@ static PositionMessage 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; + } + + private String uri; + + 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; + } + + private String formatHint; + + public String getFormatHint() { + return formatHint; + } + + public void setFormatHint(String setterArg) { + this.formatHint = setterArg; + } + + private Map httpHeaders; + + public Map getHttpHeaders() { + return httpHeaders; + } + + public void setHttpHeaders(Map setterArg) { + this.httpHeaders = setterArg; + } + + Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("asset", asset); + toMapResult.put("uri", uri); + toMapResult.put("packageName", packageName); + toMapResult.put("formatHint", formatHint); + toMapResult.put("httpHeaders", httpHeaders); + return toMapResult; + } + + static CreateMessage fromMap(Map map) { + CreateMessage fromMapResult = new CreateMessage(); + 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; + Object httpHeaders = map.get("httpHeaders"); + fromMapResult.httpHeaders = (Map) httpHeaders; + return fromMapResult; + } + } + /** Generated class from Pigeon that represents data sent in messages. */ public static class MixWithOthersMessage { private Boolean mixWithOthers; @@ -306,13 +311,13 @@ public void setMixWithOthers(Boolean setterArg) { this.mixWithOthers = setterArg; } - HashMap toMap() { - HashMap toMapResult = new HashMap<>(); + Map toMap() { + Map toMapResult = new HashMap<>(); toMapResult.put("mixWithOthers", mixWithOthers); return toMapResult; } - static MixWithOthersMessage fromMap(HashMap map) { + static MixWithOthersMessage fromMap(Map map) { MixWithOthersMessage fromMapResult = new MixWithOthersMessage(); Object mixWithOthers = map.get("mixWithOthers"); fromMapResult.mixWithOthers = (Boolean) mixWithOthers; @@ -320,46 +325,112 @@ static MixWithOthersMessage fromMap(HashMap map) { } } + private static class VideoPlayerApiCodec extends StandardMessageCodec { + public static final VideoPlayerApiCodec INSTANCE = new VideoPlayerApiCodec(); + + private VideoPlayerApiCodec() {} + + @Override + protected Object readValueOfType(byte type, ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return CreateMessage.fromMap((Map) readValue(buffer)); + + case (byte) 129: + return LoopingMessage.fromMap((Map) readValue(buffer)); + + case (byte) 130: + return MixWithOthersMessage.fromMap((Map) readValue(buffer)); + + case (byte) 131: + return PlaybackSpeedMessage.fromMap((Map) readValue(buffer)); + + case (byte) 132: + return PositionMessage.fromMap((Map) readValue(buffer)); + + case (byte) 133: + return TextureMessage.fromMap((Map) readValue(buffer)); + + case (byte) 134: + return VolumeMessage.fromMap((Map) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(ByteArrayOutputStream stream, Object value) { + if (value instanceof CreateMessage) { + stream.write(128); + writeValue(stream, ((CreateMessage) value).toMap()); + } else if (value instanceof LoopingMessage) { + stream.write(129); + writeValue(stream, ((LoopingMessage) value).toMap()); + } else if (value instanceof MixWithOthersMessage) { + stream.write(130); + writeValue(stream, ((MixWithOthersMessage) value).toMap()); + } else if (value instanceof PlaybackSpeedMessage) { + stream.write(131); + writeValue(stream, ((PlaybackSpeedMessage) value).toMap()); + } else if (value instanceof PositionMessage) { + stream.write(132); + writeValue(stream, ((PositionMessage) value).toMap()); + } else if (value instanceof TextureMessage) { + stream.write(133); + writeValue(stream, ((TextureMessage) value).toMap()); + } else if (value instanceof VolumeMessage) { + stream.write(134); + writeValue(stream, ((VolumeMessage) value).toMap()); + } else { + super.writeValue(stream, value); + } + } + } + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface VideoPlayerApi { void initialize(); - TextureMessage create(CreateMessage arg); + TextureMessage create(CreateMessage msg); - void dispose(TextureMessage arg); + void dispose(TextureMessage msg); - void setLooping(LoopingMessage arg); + void setLooping(LoopingMessage msg); - void setVolume(VolumeMessage arg); + void setVolume(VolumeMessage msg); - void setPlaybackSpeed(PlaybackSpeedMessage arg); + void setPlaybackSpeed(PlaybackSpeedMessage msg); - void play(TextureMessage arg); + void play(TextureMessage msg); - PositionMessage position(TextureMessage arg); + PositionMessage position(TextureMessage msg); - void seekTo(PositionMessage arg); + void seekTo(PositionMessage msg); - void pause(TextureMessage arg); + void pause(TextureMessage msg); - void setMixWithOthers(MixWithOthersMessage arg); + void setMixWithOthers(MixWithOthersMessage msg); + + /** The codec used by VideoPlayerApi. */ + static MessageCodec getCodec() { + return VideoPlayerApiCodec.INSTANCE; + } - /** Sets up an instance of `VideoPlayerApi` to handle messages through the `binaryMessenger` */ + /** 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()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.initialize", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { api.initialize(); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -371,19 +442,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.create", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.create", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map 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) { + ArrayList args = (ArrayList) message; + CreateMessage msgArg = (CreateMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + TextureMessage output = api.create(msgArg); + wrapped.put("result", output); + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -395,19 +467,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.dispose", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.dispose", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.dispose(input); + ArrayList args = (ArrayList) message; + TextureMessage msgArg = (TextureMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.dispose(msgArg); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -419,19 +492,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setLooping", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setLooping", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { - @SuppressWarnings("ConstantConditions") - LoopingMessage input = LoopingMessage.fromMap((HashMap) message); - api.setLooping(input); + ArrayList args = (ArrayList) message; + LoopingMessage msgArg = (LoopingMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.setLooping(msgArg); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -443,19 +517,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setVolume", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setVolume", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { - @SuppressWarnings("ConstantConditions") - VolumeMessage input = VolumeMessage.fromMap((HashMap) message); - api.setVolume(input); + ArrayList args = (ArrayList) message; + VolumeMessage msgArg = (VolumeMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.setVolume(msgArg); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -467,19 +542,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { - @SuppressWarnings("ConstantConditions") - PlaybackSpeedMessage input = PlaybackSpeedMessage.fromMap((HashMap) message); - api.setPlaybackSpeed(input); + ArrayList args = (ArrayList) message; + PlaybackSpeedMessage msgArg = (PlaybackSpeedMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.setPlaybackSpeed(msgArg); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -491,19 +567,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.play", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.play", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.play(input); + ArrayList args = (ArrayList) message; + TextureMessage msgArg = (TextureMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.play(msgArg); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -515,19 +592,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.position", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.position", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map 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) { + ArrayList args = (ArrayList) message; + TextureMessage msgArg = (TextureMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + PositionMessage output = api.position(msgArg); + wrapped.put("result", output); + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -539,19 +617,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.seekTo", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.seekTo", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { - @SuppressWarnings("ConstantConditions") - PositionMessage input = PositionMessage.fromMap((HashMap) message); - api.seekTo(input); + ArrayList args = (ArrayList) message; + PositionMessage msgArg = (PositionMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.seekTo(msgArg); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -563,19 +642,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.pause", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.pause", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { - @SuppressWarnings("ConstantConditions") - TextureMessage input = TextureMessage.fromMap((HashMap) message); - api.pause(input); + ArrayList args = (ArrayList) message; + TextureMessage msgArg = (TextureMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.pause(msgArg); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -587,19 +667,20 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", - new StandardMessageCodec()); + binaryMessenger, "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { - HashMap wrapped = new HashMap<>(); + Map wrapped = new HashMap<>(); try { - @SuppressWarnings("ConstantConditions") - MixWithOthersMessage input = MixWithOthersMessage.fromMap((HashMap) message); - api.setMixWithOthers(input); + ArrayList args = (ArrayList) message; + MixWithOthersMessage msgArg = (MixWithOthersMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.setMixWithOthers(msgArg); wrapped.put("result", null); - } catch (Exception exception) { + } catch (Error | RuntimeException exception) { wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); @@ -611,8 +692,8 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) { } } - private static HashMap wrapError(Exception exception) { - HashMap errorMap = new HashMap<>(); + private static Map wrapError(Throwable exception) { + Map errorMap = new HashMap<>(); errorMap.put("message", exception.toString()); errorMap.put("code", exception.getClass().getSimpleName()); errorMap.put("details", null); diff --git a/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m b/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m index f0f672d87431..d3d27c0d5f0a 100644 --- a/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m +++ b/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m @@ -511,7 +511,7 @@ - (FLTTextureMessage*)onPlayerSetup:(FLTVideoPlayer*)player return result; } -- (void)initialize:(FlutterError* __autoreleasing*)error { +- (void)initialize:(FlutterError* _Nullable __autoreleasing*)error { // Allow audio playback when the Ring/Silent switch is set to silent [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; diff --git a/packages/video_player/video_player/ios/Classes/messages.h b/packages/video_player/video_player/ios/Classes/messages.h index e21e7860ba09..8ac6e582da71 100644 --- a/packages/video_player/video_player/ios/Classes/messages.h +++ b/packages/video_player/video_player/ios/Classes/messages.h @@ -1,36 +1,29 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -// Autogenerated from Pigeon (v0.1.21), do not edit directly. +// +// Autogenerated from Pigeon (v1.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @protocol FlutterBinaryMessenger; +@protocol FlutterMessageCodec; @class FlutterError; @class FlutterStandardTypedData; NS_ASSUME_NONNULL_BEGIN @class FLTTextureMessage; -@class FLTCreateMessage; @class FLTLoopingMessage; @class FLTVolumeMessage; @class FLTPlaybackSpeedMessage; @class FLTPositionMessage; +@class FLTCreateMessage; @class FLTMixWithOthersMessage; @interface FLTTextureMessage : NSObject @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, strong, nullable) NSDictionary *httpHeaders; -@end - @interface FLTLoopingMessage : NSObject @property(nonatomic, strong, nullable) NSNumber *textureId; @property(nonatomic, strong, nullable) NSNumber *isLooping; @@ -51,29 +44,40 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong, nullable) NSNumber *position; @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, strong, nullable) NSDictionary *httpHeaders; +@end + @interface FLTMixWithOthersMessage : NSObject @property(nonatomic, strong, nullable) NSNumber *mixWithOthers; @end +/// The codec used by FLTVideoPlayerApi. +NSObject *FLTVideoPlayerApiGetCodec(void); + @protocol FLTVideoPlayerApi - (void)initialize:(FlutterError *_Nullable *_Nonnull)error; -- (nullable FLTTextureMessage *)create:(FLTCreateMessage *)input +- (nullable FLTTextureMessage *)create:(FLTCreateMessage *)msg 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 +- (void)dispose:(FLTTextureMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setLooping:(FLTLoopingMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setVolume:(FLTVolumeMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setPlaybackSpeed:(FLTPlaybackSpeedMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; -- (void)play:(FLTTextureMessage *)input error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable FLTPositionMessage *)position:(FLTTextureMessage *)input +- (void)play:(FLTTextureMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable FLTPositionMessage *)position:(FLTTextureMessage *)msg 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 +- (void)seekTo:(FLTPositionMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; +- (void)pause:(FLTTextureMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setMixWithOthers:(FLTMixWithOthersMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; @end extern void FLTVideoPlayerApiSetup(id binaryMessenger, - id _Nullable api); + NSObject *_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 0936bbc7d995..d7a1127a67cb 100644 --- a/packages/video_player/video_player/ios/Classes/messages.m +++ b/packages/video_player/video_player/ios/Classes/messages.m @@ -1,8 +1,8 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -// Autogenerated from Pigeon (v0.1.21), do not edit directly. +// +// Autogenerated from Pigeon (v1.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.h" #import @@ -11,7 +11,7 @@ #error File requires ARC to be enabled. #endif -static NSDictionary *wrapResult(NSDictionary *result, FlutterError *error) { +static NSDictionary *wrapResult(id result, FlutterError *error) { NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { errorDict = @{ @@ -30,10 +30,6 @@ @interface FLTTextureMessage () + (FLTTextureMessage *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @end -@interface FLTCreateMessage () -+ (FLTCreateMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; -@end @interface FLTLoopingMessage () + (FLTLoopingMessage *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @@ -50,6 +46,10 @@ @interface FLTPositionMessage () + (FLTPositionMessage *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @end +@interface FLTCreateMessage () ++ (FLTCreateMessage *)fromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end @interface FLTMixWithOthersMessage () + (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @@ -65,47 +65,9 @@ + (FLTTextureMessage *)fromMap:(NSDictionary *)dict { return result; } - (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]), - @"textureId", nil]; -} -@end - -@implementation FLTCreateMessage -+ (FLTCreateMessage *)fromMap:(NSDictionary *)dict { - FLTCreateMessage *result = [[FLTCreateMessage alloc] init]; - result.asset = dict[@"asset"]; - if ((NSNull *)result.asset == [NSNull null]) { - result.asset = nil; - } - result.uri = dict[@"uri"]; - if ((NSNull *)result.uri == [NSNull null]) { - result.uri = nil; - } - result.packageName = dict[@"packageName"]; - if ((NSNull *)result.packageName == [NSNull null]) { - result.packageName = nil; - } - result.formatHint = dict[@"formatHint"]; - if ((NSNull *)result.formatHint == [NSNull null]) { - result.formatHint = nil; - } - result.httpHeaders = dict[@"httpHeaders"]; - if ((NSNull *)result.httpHeaders == [NSNull null]) { - result.httpHeaders = nil; - } - 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", - (self.httpHeaders ? self.httpHeaders : [NSNull null]), - @"httpHeaders", nil]; + return + [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), + @"textureId", nil]; } @end @@ -124,10 +86,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 @@ -146,9 +107,8 @@ + (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 @@ -167,9 +127,8 @@ + (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict { } - (NSDictionary *)toMap { return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]), - @"textureId", (self.speed != nil ? self.speed : [NSNull null]), - @"speed", nil]; + dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", + (self.speed ? self.speed : [NSNull null]), @"speed", nil]; } @end @@ -188,10 +147,47 @@ + (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 + +@implementation FLTCreateMessage ++ (FLTCreateMessage *)fromMap:(NSDictionary *)dict { + FLTCreateMessage *result = [[FLTCreateMessage alloc] init]; + result.asset = dict[@"asset"]; + if ((NSNull *)result.asset == [NSNull null]) { + result.asset = nil; + } + result.uri = dict[@"uri"]; + if ((NSNull *)result.uri == [NSNull null]) { + result.uri = nil; + } + result.packageName = dict[@"packageName"]; + if ((NSNull *)result.packageName == [NSNull null]) { + result.packageName = nil; + } + result.formatHint = dict[@"formatHint"]; + if ((NSNull *)result.formatHint == [NSNull null]) { + result.formatHint = nil; + } + result.httpHeaders = dict[@"httpHeaders"]; + if ((NSNull *)result.httpHeaders == [NSNull null]) { + result.httpHeaders = nil; + } + 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", + (self.httpHeaders ? self.httpHeaders : [NSNull null]), + @"httpHeaders", nil]; } @end @@ -206,17 +202,106 @@ + (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 -void FLTVideoPlayerApiSetup(id binaryMessenger, id api) { +@interface FLTVideoPlayerApiCodecReader : FlutterStandardReader +@end +@implementation FLTVideoPlayerApiCodecReader +- (nullable id)readValueOfType:(UInt8)type { + switch (type) { + case 128: + return [FLTCreateMessage fromMap:[self readValue]]; + + case 129: + return [FLTLoopingMessage fromMap:[self readValue]]; + + case 130: + return [FLTMixWithOthersMessage fromMap:[self readValue]]; + + case 131: + return [FLTPlaybackSpeedMessage fromMap:[self readValue]]; + + case 132: + return [FLTPositionMessage fromMap:[self readValue]]; + + case 133: + return [FLTTextureMessage fromMap:[self readValue]]; + + case 134: + return [FLTVolumeMessage fromMap:[self readValue]]; + + default: + return [super readValueOfType:type]; + } +} +@end + +@interface FLTVideoPlayerApiCodecWriter : FlutterStandardWriter +@end +@implementation FLTVideoPlayerApiCodecWriter +- (void)writeValue:(id)value { + if ([value isKindOfClass:[FLTCreateMessage class]]) { + [self writeByte:128]; + [self writeValue:[value toMap]]; + } else if ([value isKindOfClass:[FLTLoopingMessage class]]) { + [self writeByte:129]; + [self writeValue:[value toMap]]; + } else if ([value isKindOfClass:[FLTMixWithOthersMessage class]]) { + [self writeByte:130]; + [self writeValue:[value toMap]]; + } else if ([value isKindOfClass:[FLTPlaybackSpeedMessage class]]) { + [self writeByte:131]; + [self writeValue:[value toMap]]; + } else if ([value isKindOfClass:[FLTPositionMessage class]]) { + [self writeByte:132]; + [self writeValue:[value toMap]]; + } else if ([value isKindOfClass:[FLTTextureMessage class]]) { + [self writeByte:133]; + [self writeValue:[value toMap]]; + } else if ([value isKindOfClass:[FLTVolumeMessage class]]) { + [self writeByte:134]; + [self writeValue:[value toMap]]; + } else { + [super writeValue:value]; + } +} +@end + +@interface FLTVideoPlayerApiCodecReaderWriter : FlutterStandardReaderWriter +@end +@implementation FLTVideoPlayerApiCodecReaderWriter +- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { + return [[FLTVideoPlayerApiCodecWriter alloc] initWithData:data]; +} +- (FlutterStandardReader *)readerWithData:(NSData *)data { + return [[FLTVideoPlayerApiCodecReader alloc] initWithData:data]; +} +@end + +NSObject *FLTVideoPlayerApiGetCodec() { + static dispatch_once_t s_pred = 0; + static FlutterStandardMessageCodec *s_sharedObject = nil; + dispatch_once(&s_pred, ^{ + FLTVideoPlayerApiCodecReaderWriter *readerWriter = + [[FLTVideoPlayerApiCodecReaderWriter alloc] init]; + s_sharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; + }); + return s_sharedObject; +} + +void FLTVideoPlayerApiSetup(id binaryMessenger, + NSObject *api) { { FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:@"dev.flutter.pigeon.VideoPlayerApi.initialize" - binaryMessenger:binaryMessenger]; + binaryMessenger:binaryMessenger + codec:FLTVideoPlayerApiGetCodec()]; if (api) { + NSCAssert([api respondsToSelector:@selector(initialize:)], + @"FLTVideoPlayerApi api doesn't respond to @selector(initialize:)"); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api initialize:&error]; @@ -229,13 +314,17 @@ void FLTVideoPlayerApiSetup(id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id binaryMessenger, id httpHeaders; + String? asset; + String? uri; + String? packageName; + String? formatHint; + Map? httpHeaders; } class MixWithOthersMessage { - bool mixWithOthers; + bool? mixWithOthers; } @HostApi(dartHostTestHandler: 'TestHostVideoPlayerApi') abstract class VideoPlayerApi { + @ObjCSelector('initialize') void initialize(); + @ObjCSelector('create:') TextureMessage create(CreateMessage msg); + @ObjCSelector('dispose:') void dispose(TextureMessage msg); + @ObjCSelector('setLooping:') void setLooping(LoopingMessage msg); + @ObjCSelector('setVolume:') void setVolume(VolumeMessage msg); + @ObjCSelector('setPlaybackSpeed:') void setPlaybackSpeed(PlaybackSpeedMessage msg); + @ObjCSelector('play:') void play(TextureMessage msg); + @ObjCSelector('position:') PositionMessage position(TextureMessage msg); + @ObjCSelector('seekTo:') void seekTo(PositionMessage msg); + @ObjCSelector('pause:') void pause(TextureMessage msg); + @ObjCSelector('setMixWithOthers:') void setMixWithOthers(MixWithOthersMessage msg); } - -void configurePigeon(PigeonOptions opts) { - opts.dartOut = '../video_player_platform_interface/lib/messages.dart'; - opts.dartTestOut = '../video_player_platform_interface/lib/test.dart'; - opts.objcHeaderOut = 'ios/Classes/messages.h'; - opts.objcSourceOut = 'ios/Classes/messages.m'; - opts.objcOptions.prefix = 'FLT'; - opts.javaOut = - 'android/src/main/java/io/flutter/plugins/videoplayer/Messages.java'; - opts.javaOptions.package = 'io.flutter.plugins.videoplayer'; -} diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 0d0cdb1cb436..b2314afd3fe6 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter widgets on Android, iOS, and web. repository: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.1.14 +version: 2.1.15 environment: sdk: ">=2.12.0 <3.0.0" @@ -24,17 +24,20 @@ dependencies: flutter: sdk: flutter meta: ^1.3.0 - video_player_platform_interface: ^4.1.0 + video_player_platform_interface: #^4.1.0 + path: ../video_player_platform_interface # 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. The exact value doesn't matter since # the constraints on the interface pins it. # TODO(amirh): Revisit this (either update this part in the design or the pub tool). # https://github.com/flutter/flutter/issues/46264 - video_player_web: ^2.0.0 + video_player_web: #^2.0.0 + path: ../video_player_web dev_dependencies: flutter_test: sdk: flutter pedantic: ^1.10.0 - pigeon: ^0.1.21 + pigeon: + path: /Users/aaclarke/dev/packages/packages/pigeon