-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[video_player] foundation - reduce seek accuracy to fix seek to end bug #3784
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 8 commits
45fb3a5
426c067
7d167e2
b78ae9b
cc5b173
aa9fbbd
041dcb3
c6861f4
747a421
2e12e1a
d130337
7e8fada
b61eace
6a586d1
c9bd628
ce41a1f
3ef8801
46f3c7d
fb9b9b8
7aeb3db
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 |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## 2.4.5 | ||
|
|
||
| * Fixes hang when seeking to end of video. | ||
|
|
||
| ## 2.4.4 | ||
|
|
||
| * Updates pigeon to fix warnings with clang 15. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -420,9 +420,15 @@ - (int64_t)duration { | |
| } | ||
|
|
||
| - (void)seekTo:(int)location completionHandler:(void (^)(BOOL))completionHandler { | ||
| [_player seekToTime:CMTimeMake(location, 1000) | ||
| toleranceBefore:kCMTimeZero | ||
| toleranceAfter:kCMTimeZero | ||
| CMTime locationCMT = CMTimeMake(location, 1000); | ||
| CMTimeValue duration = _player.currentItem.asset.duration.value; | ||
| // Without adding tolerance when seeking to duration, | ||
| // seekToTime will never complete, and this call will hang. | ||
| // see issue https://github.com/flutter/flutter/issues/124475. | ||
| CMTime tolerance = location == duration ? CMTimeMake(1, 1000) : kCMTimeZero; | ||
|
Comment on lines
+442
to
+447
Contributor
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. What if
Contributor
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. Video https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4 from tests gives 2422 and 600 for
Collaborator
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. @misos1 This is a PR that landed a year and a half ago; comments here aren't actionable. If there's a bug, please file an issue with details. |
||
| [_player seekToTime:locationCMT | ||
| toleranceBefore:tolerance | ||
| toleranceAfter:tolerance | ||
| completionHandler:completionHandler]; | ||
| } | ||
|
|
||
|
|
||
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.
Can you write a unit test (XCTest) for this behavior?
Uh oh!
There was an error while loading. Please reload this page.
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.
I have no idea what I didn't think of that when @tarrinneal and I were talking about testing for this 🤦🏻
It looks like we don't currently have a way to mock out the underlying
AVPlayer, which significantly reduces testability. I would suggest wrapping the current call to[AVPlayer playerWithPlayerItem:]in a factory object, and do DI of that factory. So you'd make a test-only header that declared:AVPlayerinstance factory (which it looks like would just be a single method)The, similar to the other DI you did recently, you'd have a private implementation of that protocol that's the default version, just wrapping
[AVPlayer playerWithPlayerItem:], but tests could replace it with something vending mock AVPlayer instances where you could validate the tolerance parameter.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.
Can also try stubbing the constructor directly if it's easier:
Uh oh!
There was an error while loading. Please reload this page.
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.
Please don't. OCMock class mocking is giant foot-gun; it's incredibly easy to accidentally leak mocking across tests.
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.
gotcha. i did that a few times for camera plugin iirc. i should clean that up sometime.