-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[video_player]: reduce video player position update interval from 500ms to 100ms #8346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
268a174
670dfdd
2740a21
7d6d2c6
b4ace49
552f313
bece80c
68d9b80
4e7b75d
450858e
35e28c5
bb074ce
63514cb
617c2a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -956,6 +956,41 @@ void main() { | |
| }); | ||
| }); | ||
| }); | ||
| test('updates position', () async { | ||
abdelaziz-mahdy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| final VideoPlayerController controller = VideoPlayerController.networkUrl( | ||
| _localhostUri, | ||
| videoPlayerOptions: VideoPlayerOptions(), | ||
| ); | ||
|
|
||
| await controller.initialize(); | ||
|
|
||
| // Set a custom interval | ||
abdelaziz-mahdy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const Duration customInterval = Duration(milliseconds: 100); | ||
|
|
||
| final List<Duration> positions = <Duration>[]; | ||
| final Completer<void> intervalUpdateCompleter = Completer<void>(); | ||
|
|
||
| // Listen for position updates | ||
| controller.addListener(() { | ||
| positions.add(controller.value.position); | ||
| if (positions.length >= 3 && !intervalUpdateCompleter.isCompleted) { | ||
| intervalUpdateCompleter.complete(); | ||
| } | ||
| }); | ||
| await controller.play(); | ||
| for (int i = 0; i < 3; i++) { | ||
| await Future<void>.delayed(customInterval); | ||
| fakeVideoPlayerPlatform._positions[controller.textureId] = | ||
| Duration(milliseconds: i * customInterval.inMilliseconds); | ||
| } | ||
|
|
||
| // Wait for at least 3 position updates | ||
| await intervalUpdateCompleter.future.timeout(const Duration(seconds: 5)); | ||
abdelaziz-mahdy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Verify that the intervals between updates are approximately correct | ||
| expect(positions[1] - positions[0], greaterThanOrEqualTo(customInterval)); | ||
|
||
| expect(positions[2] - positions[1], greaterThanOrEqualTo(customInterval)); | ||
| }); | ||
|
|
||
| group('DurationRange', () { | ||
| test('uses given values', () { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.