This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[video_player] Pause video when it completes #3727
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fd4b230
Fix https://github.com/flutter/flutter/issues/77674
KyleFin 2c88d48
Add unit tests.
KyleFin be0bd21
Add unit tests.
KyleFin f44ace0
Merge remote-tracking branch 'origin/master'
KyleFin deaae24
dartfmt
KyleFin 60a6595
Update play() documentation.
KyleFin 46af8d4
Update test cases to use integration_tests.
KyleFin d88ac67
Update version.
KyleFin 7221af7
Merge branch 'master' into master
KyleFin c685ab3
Merge branch 'master' into master
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,51 @@ void main() { | |
}, | ||
); | ||
|
||
testWidgets( | ||
'stay paused when seeking after video completed', | ||
(WidgetTester tester) async { | ||
await _controller.initialize(); | ||
// Mute to allow playing without DOM interaction on Web. | ||
// See https://developers.google.com/web/updates/2017/09/autoplay-policy-changes | ||
await _controller.setVolume(0); | ||
Duration tenMillisBeforeEnd = | ||
_controller.value.duration - const Duration(milliseconds: 10); | ||
await _controller.seekTo(tenMillisBeforeEnd); | ||
await _controller.play(); | ||
await tester.pumpAndSettle(_playDuration); | ||
expect(_controller.value.isPlaying, false); | ||
expect(_controller.value.position, _controller.value.duration); | ||
|
||
await _controller.seekTo(tenMillisBeforeEnd); | ||
await tester.pumpAndSettle(_playDuration); | ||
|
||
expect(_controller.value.isPlaying, false); | ||
expect(_controller.value.position, tenMillisBeforeEnd); | ||
}, | ||
); | ||
|
||
testWidgets( | ||
'do not exceed duration on play after video completed', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The additional symptom I observed in flutter/flutter#77674 (comment) |
||
(WidgetTester tester) async { | ||
await _controller.initialize(); | ||
// Mute to allow playing without DOM interaction on Web. | ||
// See https://developers.google.com/web/updates/2017/09/autoplay-policy-changes | ||
await _controller.setVolume(0); | ||
await _controller.seekTo( | ||
_controller.value.duration - const Duration(milliseconds: 10)); | ||
await _controller.play(); | ||
await tester.pumpAndSettle(_playDuration); | ||
expect(_controller.value.isPlaying, false); | ||
expect(_controller.value.position, _controller.value.duration); | ||
|
||
await _controller.play(); | ||
await tester.pumpAndSettle(_playDuration); | ||
|
||
expect(_controller.value.position, | ||
lessThanOrEqualTo(_controller.value.duration)); | ||
}, | ||
); | ||
|
||
testWidgets('test video player view with local asset', | ||
(WidgetTester tester) async { | ||
Future<bool> started() async { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,6 +318,23 @@ void main() { | |
expect(fakeVideoPlayerPlatform.calls.last, 'setPlaybackSpeed'); | ||
}); | ||
|
||
test('play restarts from beginning if video is at end', () async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new behavior I added to make Android and iOS consistent with web. |
||
final VideoPlayerController controller = VideoPlayerController.network( | ||
'https://127.0.0.1', | ||
); | ||
await controller.initialize(); | ||
const Duration nonzeroDuration = Duration(milliseconds: 100); | ||
controller.value = controller.value.copyWith(duration: nonzeroDuration); | ||
await controller.seekTo(nonzeroDuration); | ||
expect(controller.value.isPlaying, isFalse); | ||
expect(controller.value.position, nonzeroDuration); | ||
|
||
await controller.play(); | ||
|
||
expect(controller.value.isPlaying, isTrue); | ||
expect(controller.value.position, Duration.zero); | ||
}); | ||
|
||
test('setLooping', () async { | ||
final VideoPlayerController controller = VideoPlayerController.network( | ||
'https://127.0.0.1', | ||
|
@@ -459,6 +476,8 @@ void main() { | |
'https://127.0.0.1', | ||
); | ||
await controller.initialize(); | ||
const Duration nonzeroDuration = Duration(milliseconds: 100); | ||
controller.value = controller.value.copyWith(duration: nonzeroDuration); | ||
expect(controller.value.isPlaying, isFalse); | ||
await controller.play(); | ||
expect(controller.value.isPlaying, isTrue); | ||
|
@@ -470,7 +489,7 @@ void main() { | |
await tester.pumpAndSettle(); | ||
|
||
expect(controller.value.isPlaying, isFalse); | ||
expect(controller.value.position, controller.value.duration); | ||
expect(controller.value.position, nonzeroDuration); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, |
||
}); | ||
|
||
testWidgets('buffering status', (WidgetTester tester) async { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original issue (flutter/flutter#77674)