Skip to content
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

Fix videoplayer status after pause&finish #15782

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

mmyduckx
Copy link
Contributor

Re: # related PR: cocos/cocos-test-projects#824

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@mmyduckx mmyduckx requested a review from minggo July 19, 2023 11:15
@mmyduckx mmyduckx changed the title Fix videoplayer status after pause Fix videoplayer status after pause&finish Jul 19, 2023
if (this._ignorePause) {
this._ignorePause = false;
return;
}
this._playing = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is _ignorePause. I don't quite understand its usage. But from its name, it seems to ignore stop. And if want to ignore stop, then should not change the status?

Copy link
Contributor Author

@mmyduckx mmyduckx Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
As you can see, when call stop(), it will set _ignorePause to ture, which is reasonable.
But then it call video.pause() then trigger onPause in web.
Q: Why? It should be call video.stop() then trigger onStop , like on other platform:
image
image
A: Because on web, we don't have such video.stop() interface. So, we use pause() instead of stop().

Based on the above, I think we should set _playing to false to make sure, in this condition, the video status is not playing. (obviously, when trigger onPause, _playing status shouldn't be true).
Otherwise, we got wrong isplaying value when click stop in web.

But from its name, it seems to ignore stop. And if want to ignore stop, then should not change the status?

By the way, as far as i'm concerned, _ignorePause is just to prevent to pause repeatly when video already pause or stop and emit extra Event.PAUSE. So it is safe to set _playing = false in advance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about add stopped status on web? Then can just remove _ignorePause. The stop implementation may be like this

public stop (): void {
    if (this._status == STOPPED) {
        return;
    }

    this.pause();
    this._status = STOPPED;
    ...
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And i think only _status variable is needed.

Copy link
Contributor Author

@mmyduckx mmyduckx Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about add stopped status on web? Then can just remove _ignorePause. The stop implementation may be like this

public stop (): void {
    if (this._status == STOPPED) {
        return;
    }

    this.pause();
    this._status = STOPPED;
    ...
}

Right now , _ignorePause is not only use on web but also on other platform. So I do not recommand change implementation in small version like 3.8.1; In fact, there are other implementations also not reasonable enough. Maybe we can do some refactory work all together later on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable.

@minggo minggo merged commit ebbba60 into cocos:v3.8.1 Jul 20, 2023
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants