-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[video_player] Make initialize not depend on duration, fix the live stream
#1743
Conversation
…ontroller_dispose # Conflicts: # packages/video_player/CHANGELOG.md # packages/video_player/pubspec.yaml
…ontroller_dispose # Conflicts: # packages/video_player/CHANGELOG.md
|
Is there a better way to prevent the division by zero error that #1554 was trying to fix? |
|
@collinjackson Didn't know that the division by zero was the issue there. I will definitely work in a solution that solves both cases. |
Great, thanks! Let me know when this PR is ready for re-review. |
handle livestream better
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
|
Checking in, it looks like you're still working on this PR since the tests don't pass so I'm marking it WIP. Just let us know when it's ready for re-review. Thanks! |
|
@collinjackson We have a working solution already. Taking some time to fix the errors from the example app. Will be finished by tomorrow. |
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
|
@googlebot confirmed! |
|
@collinjackson I am done with the PR. Here are some things to notice:
When testing the example app, I've noticed that, everytime we switch to a tab that plays a video from the assets, an exception is thrown and the other videos start to play as well. This was not introduced by this PR. I went back and tested previous versions and it does the same. I refactored the whole example app trying to find the source of the problem but it's not in it. It's something from the player itself and I couldn't find the reason. That's probably why there was a I am sending the PR with the refactored example app (all the features remain the same). I believe it's cleaner this way. Let me know what you think. About the failing CLA: @bduyng is the co-author of this PR. He already signed the CLA and also sent a confirmation message here. |
|
@ianko Thank you for the contribution. The PR seems pretty long and it includes different things. Do you mind to separate the refactor and the race condition fixing to different PRs? |
It was already a different PR (#1562). I had to bring to try to fix the issue with the video from assets that I mentioned, but it does not solve this case. Added a reference to a related issue flutter/flutter#35402 opened recently. |
|
@ianko Thanks, this PR seems still contains multiple stuff: the duration method addition and a refactoring of the example app. Do you mind separate them so one PR only contains a single feature/fix? |
|
I can confirm that 0.10.1 causes this issue Thank you @ianko |
initialize not depend on duration, fix the live stream
cyanglaz
left a comment
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.
Thank you for the contribution. I have left some comments. One of them is a suggestion to an alternative solution for the problem. See if you like it.
| @@ -1,3 +1,7 @@ | |||
| ## 0.10.2 | |||
|
|
|||
| * iOS: Revert the changes made in version `0.10.1` that made live streams not able to initialize on the absence of `duration`. | |||
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 also add what is added in this patch as well.
| for (NSValue* rangeValue in [_player currentItem].loadedTimeRanges) { | ||
| CMTimeRange range = [rangeValue CMTimeRangeValue]; | ||
| int64_t start = FLTCMTimeToMillis(range.start); | ||
| if (start > maxBuffering) { |
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.
why did we need this check? Can start somehow be negative? If the start is 0, do we not add the range.duration to maxBuffering?
| } | ||
|
|
||
| - (int64_t)duration { | ||
| if (CMTIME_IS_INDEFINITE([[_player currentItem] duration])) { |
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 assume this is computing the length of loaded times in livestream. I personally would think the duration is the length of the whole video. Maybe create a different method for getting the "loadedTimes" for livestream videos?
| } | ||
|
|
||
| /// The duration in the current video. | ||
| Future<Duration> get duration async { |
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.
It would seem to fail if called on Android.
| if (height == CGSizeZero.height && width == CGSizeZero.width) { | ||
| return; | ||
| } | ||
| // The player may be initialized but still needs to determine the duration. |
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 think the quicker fix can be something like
if ([self duration] == 0 && ![self isDurationIndefinate])And create a method to check if the duration isDurationIndefinate as simple as
return CMTIME_IS_INDEFINITE([[_player currentItem] duration]);This way we can avoid the breakage also we won't need to introduce the new api for duration anymore.
|
Hi, could you please review the CLA task that is pending to move forward? This is pretty much needed. Thanks |
I have signed already. I believe that @bduyng has also signed. |
|
Ok, I think a project admin is needed to change the |
|
@ianko Are you still planning to work on this? It seems that I left some review comments that haven't been addressed. |
|
This bug seems to be very old and needed for everyone as I was reading through a lot of threads, so can you please fix it? |
|
Please, is there a fix for this?? |
Description
The
0.10.1version introduced the condition to have thedurationin order to consider the player initialized. That change made the live stream videos not able to play anymore, since it does not have a duration.Related Issues
flutter/flutter#35402
flutter/flutter#48670
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?