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

[WIP] fix: trigger playback ready event when rendered #75

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

kslimani
Copy link
Contributor

It ensure that "PLAYBACK_READY" event is trigger when plugin is rendered to attempt to be consistent with other playback plugins.

These changes allow the "CORE_READY" event to be trigger before the play() method is called.

I also added some conditions to avoid potential predictable exception(s) on undefined/null properties/method results.

Should fix #74.

I focused on avoiding any backward incompatible changes, but it would be nice to have some code review before merge.

@kslimani
Copy link
Contributor Author

kslimani commented Jan 29, 2020

I added an additionnal commit to fix an issue with Safari on macOS : it store the user interaction provided by clicking on play (when autoplay is not permitted) before setup the Shaka instance.

The main reason is that the load() method will fetch the manifest and therefore will lost the user interaction. (required by core plugins which may require to initalize stuff when user click on play)

It is a workaround, otherwise when the playback "PLAY_INTENT" event is triggered, the user interaction is already lost. (this change make the Shaka playback plugin fully compatible with my IMA SDK ad plugin)

@kslimani
Copy link
Contributor Author

Added minor fix and updated jsDelivr script urls.

@kslimani
Copy link
Contributor Author

kslimani commented Jan 31, 2020

Added level property to "levels available" playback event object to increase consistency with hls.js playback plugin. (it allow developper to use label callback option in level selector plugin to fully customize label formatting).

Change default track label format.
Add language in tracks label when required.
Ensure tracks are sorted.
@kslimani
Copy link
Contributor Author

kslimani commented Feb 4, 2020

Added a commit which hopefully fix #76 .

@joaopaulovieira
Copy link
Member

Hey @kslimani, thanks for the contribution! I suggest one approach to handle the behavior related to issue #74.

Move the code on the _onShakaReady to the _ready and checks if the _setup has occurred. I think the semantic of the ready state is the playback is ready to play and this sentence is not true if the _setup doesn't occur.

Something like:

  _ready () {
    !this._player && this._setup()
    this._isShakaReadyState = true
    this.trigger(DashShakaPlayback.Events.SHAKA_READY)
    super._ready()
  }

  _onShakaReady() {
    this._ready()
  }

With this approach, we handle the call of _ready inside the render call on HTML5Video and when occurs one imperative call of the _setup on the DashShakaPlayback.

What do you think?

@kslimani
Copy link
Contributor Author

@joaopaulovieira indeed i missed the _ready() call in the HTML5 playback parent class, thank you for pointing this to me. (i think in the current state, this PR may trigger the playback state ready event too soon)

I like your approach because it attempt to create the Shaka instance and load the source manifest at render time. (which will avoid the source manifest ajax request when user click to play)

The only part i think about is that _setup() method perform asynchronous stuff and set _isShakaReadyState when Shaka instance has loaded source. For this reason, maybe we should still override the _ready method without calling super._ready() ?

What do you think ?

PS: i rename this PR as "WIP" until this issue is fixed.

@kslimani kslimani changed the title fix: trigger playback ready event when rendered [WIP] fix: trigger playback ready event when rendered Apr 29, 2020
@joaopaulovieira
Copy link
Member

I may not have understood. Can you apply your suggested changes to the PR?

@kslimani
Copy link
Contributor Author

kslimani commented May 5, 2020

Let's hold this PR until i have the hand again on mobile/desktop devices (covid-19 containment) to ensure it will works.

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.

Playback ready event logic issue
3 participants