Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.1

* Return correct platform event type when buffering

## 1.0.0

* Initial release.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class MethodChannelVideoPlayer extends VideoPlayerPlatform {

return VideoEvent(
buffered: values.map<DurationRange>(_toDurationRange).toList(),
eventType: VideoEventType.completed,
eventType: VideoEventType.bufferingUpdate,
);
case 'bufferingStart':
return VideoEvent(eventType: VideoEventType.bufferingStart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart' show required, visibleForTesting;

Expand Down Expand Up @@ -159,6 +160,24 @@ class VideoEvent {
final Duration duration;
final Size size;
final List<DurationRange> buffered;

@override
bool operator ==(Object other) {
return identical(this, other) ||
other is VideoEvent &&
runtimeType == other.runtimeType &&
eventType == other.eventType &&
duration == other.duration &&
size == other.size &&
listEquals(buffered, other.buffered);
}

@override
int get hashCode =>
eventType.hashCode ^
duration.hashCode ^
size.hashCode ^
buffered.hashCode;
}

enum VideoEventType {
Expand Down Expand Up @@ -186,4 +205,15 @@ class DurationRange {

@override
String toString() => '$runtimeType(start: $start, end: $end)';

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is DurationRange &&
runtimeType == other.runtimeType &&
start == other.start &&
end == other.end;

@override
int get hashCode => start.hashCode ^ end.hashCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: Flutter Team <[email protected]>
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: 1.0.0
version: 1.0.1

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
import 'dart:ui';

import 'package:mockito/mockito.dart';
Expand Down Expand Up @@ -245,6 +244,58 @@ void main() {
}),
(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
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
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
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
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') {
return const StandardMethodCodec().encodeSuccessEnvelope(null);
Expand All @@ -253,16 +304,30 @@ void main() {
}
},
);
final Stream<VideoEvent> videoEvents = player.videoEventsFor(123);
expect((await videoEvents.first).eventType, VideoEventType.initialized);
expect(
(await videoEvents.first).duration,
const Duration(milliseconds: 98765),
);
expect(
(await videoEvents.first).size,
const Size(1920, 1080),
);
player.videoEventsFor(123),
emitsInOrder(<dynamic>[
VideoEvent(
eventType: VideoEventType.initialized,
duration: const Duration(milliseconds: 98765),
size: const Size(1920, 1080),
),
VideoEvent(eventType: VideoEventType.completed),
VideoEvent(
eventType: VideoEventType.bufferingUpdate,
buffered: <DurationRange>[
DurationRange(
const Duration(milliseconds: 0),
const Duration(milliseconds: 1234),
),
DurationRange(
const Duration(milliseconds: 1235),
const Duration(milliseconds: 4000),
),
]),
VideoEvent(eventType: VideoEventType.bufferingStart),
VideoEvent(eventType: VideoEventType.bufferingEnd),
]));
});
});
}
Expand Down