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

Fix signature errors to account for strong mode errors #380

Merged
merged 7 commits into from
Feb 10, 2018
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/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.1

* Fixed some signatures to account for strong mode runtime errors.

## 0.2.0

* **Breaking change**. Renamed `VideoPlayerController.isErroneous` to `VideoPlayerController.hasError`.
Expand Down
16 changes: 9 additions & 7 deletions packages/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
Timer timer;
bool isDisposed = false;
Completer<Null> _creatingCompleter;
StreamSubscription<Map<String, dynamic>> _eventSubscription;
StreamSubscription<dynamic> _eventSubscription;
_VideoAppLifeCycleObserver _lifeCycleObserver;

VideoPlayerController(this.uri) : super(new VideoPlayerValue(duration: null));
Expand All @@ -145,22 +145,22 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
_lifeCycleObserver = new _VideoAppLifeCycleObserver(this);
_lifeCycleObserver.initialize();
_creatingCompleter = new Completer<Null>();
final Map<String, dynamic> response = await _channel.invokeMethod(
final Map<dynamic, dynamic> response = await _channel.invokeMethod(
'create',
<String, dynamic>{'dataSource': uri},
);
_textureId = response["textureId"];
_creatingCompleter.complete(null);

DurationRange toDurationRange(List<int> values) {
DurationRange toDurationRange(List<dynamic> values) {
return new DurationRange(
new Duration(milliseconds: values[0]),
new Duration(milliseconds: values[1]),
);
}

void eventListener(dynamic event) {
final Map<String, dynamic> map = event;
final Map<dynamic, dynamic> map = event;
if (map["event"] == "initialized") {
value = value.copyWith(
duration: new Duration(milliseconds: map["duration"]),
Expand All @@ -173,14 +173,16 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
value = value.copyWith(isPlaying: false);
timer?.cancel();
} else if (map["event"] == "bufferingUpdate") {
final List<List<int>> bufferedValues = map["values"];
final List<List<dynamic>> bufferedValues =
map["values"].cast<List<List<dynamic>>>();
value = value.copyWith(
buffered: bufferedValues.map(toDurationRange).toList(),
buffered: bufferedValues.map<DurationRange>(toDurationRange).toList(),
);
}
}

void errorListener(PlatformException e) {
void errorListener(Object obj) {
final PlatformException e = obj;
value = new VideoPlayerValue.erroneous(e.message);
timer?.cancel();
}
Expand Down