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

[video_player] Migrate deprecated api #3409

Merged
merged 3 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.0-nullsafety.8

* Migrated from deprecated `defaultBinaryMessenger`.

## 2.0.0-nullsafety.7

* Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets.
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: 2.0.0-nullsafety.7
version: 2.0.0-nullsafety.8
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player

flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,7 @@ class FakeEventsChannel {
}

void _sendMessage(ByteData data) {
// TODO(jackson): This has been deprecated and should be replaced
// with `ServicesBinding.instance.defaultBinaryMessenger` when it's
// available on all the versions of Flutter that we test.
// ignore: deprecated_member_use
defaultBinaryMessenger.handlePlatformMessage(
ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
eventsMethodChannel.name, data, (ByteData? data) {});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,82 +234,63 @@ void main() {
});

test('videoEventsFor', () async {
// TODO(cbenhagen): This has been deprecated and should be replaced
// with `ServicesBinding.instance.defaultBinaryMessenger` when it's
// available on all the versions of Flutter that we test.
// ignore: deprecated_member_use
defaultBinaryMessenger.setMockMessageHandler(
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
"flutter.io/videoPlayer/videoEvents123",
(ByteData message) async {
final MethodCall methodCall =
const StandardMethodCodec().decodeMethodCall(message);
if (methodCall.method == 'listen') {
// TODO(cbenhagen): This has been deprecated and should be replaced
// with `ServicesBinding.instance.defaultBinaryMessenger` when it's
// available on all the versions of Flutter that we test.
// ignore: deprecated_member_use
await defaultBinaryMessenger.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'initialized',
'duration': 98765,
'width': 1920,
'height': 1080,
}),
(ByteData data) {});

// TODO(cbenhagen): This has been deprecated and should be replaced
// with `ServicesBinding.instance.defaultBinaryMessenger` when it's
// available on all the versions of Flutter that we test.
// ignore: deprecated_member_use
await defaultBinaryMessenger.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'completed',
}),
(ByteData data) {});

// TODO(cbenhagen): This has been deprecated and should be replaced
// with `ServicesBinding.instance.defaultBinaryMessenger` when it's
// available on all the versions of Flutter that we test.
// ignore: deprecated_member_use
await defaultBinaryMessenger.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'bufferingUpdate',
'values': <List<dynamic>>[
<int>[0, 1234],
<int>[1235, 4000],
],
}),
(ByteData data) {});

// TODO(cbenhagen): This has been deprecated and should be replaced
// with `ServicesBinding.instance.defaultBinaryMessenger` when it's
// available on all the versions of Flutter that we test.
// ignore: deprecated_member_use
await defaultBinaryMessenger.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'bufferingStart',
}),
(ByteData data) {});

// TODO(cbenhagen): This has been deprecated and should be replaced
// with `ServicesBinding.instance.defaultBinaryMessenger` when it's
// available on all the versions of Flutter that we test.
// ignore: deprecated_member_use
await defaultBinaryMessenger.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'bufferingEnd',
}),
(ByteData data) {});
await ServicesBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'initialized',
'duration': 98765,
'width': 1920,
'height': 1080,
}),
(ByteData data) {});

await ServicesBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'completed',
}),
(ByteData data) {});

await ServicesBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'bufferingUpdate',
'values': <List<dynamic>>[
<int>[0, 1234],
<int>[1235, 4000],
],
}),
(ByteData data) {});

await ServicesBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'bufferingStart',
}),
(ByteData data) {});

await ServicesBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
"flutter.io/videoPlayer/videoEvents123",
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
'event': 'bufferingEnd',
}),
(ByteData data) {});

return const StandardMethodCodec().encodeSuccessEnvelope(null);
} else if (methodCall.method == 'cancel') {
Expand Down