Skip to content

Commit

Permalink
fix updateTexture() never complete if no prepare. #148
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Sep 4, 2024
1 parent 6e8b74d commit 0f3ae36
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/src/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class Player {
rep.ref.prepared.boost = true;
/*
// callback can be late if prepare from pos > 0
_videoSize = Completer<ui.Size?>();
if (_videoSize.isCompleted)
_videoSize = Completer<ui.Size?>();
if (!_videoSize.isCompleted) {
if (pos < 0) {
_videoSize.complete(null);
Expand Down Expand Up @@ -122,7 +123,10 @@ class Player {
}
if (!oldValue.test(MediaStatus.loading) &&
newValue.test(MediaStatus.loading)) {
_videoSize = Completer<ui.Size?>();
if (_videoSize.isCompleted) {
// updateTexture() may be awaiting and won't wake up if reset to a new object here
_videoSize = Completer<ui.Size?>();
}
}
if (oldValue.test(MediaStatus.loading) &&
newValue.test(MediaStatus.invalid | MediaStatus.stalled)) {
Expand Down Expand Up @@ -233,6 +237,12 @@ class Player {

/// Set media, can be url, file path, assets://path etc.
set media(String value) {
if (_media != value) {
if (!_videoSize.isCompleted) {
_videoSize.complete(null);
}
_videoSize = Completer<ui.Size?>();
}
_media = value;
final cs = value.toNativeUtf8();
_player.ref.setMedia
Expand Down

0 comments on commit 0f3ae36

Please sign in to comment.