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

Plugins #1840

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open

Plugins #1840

wants to merge 14 commits into from

Conversation

akuma06
Copy link
Contributor

@akuma06 akuma06 commented May 17, 2020

Link to related issue (if applicable)

#1242

Summary of proposed changes

This Pull request adds the plugin support. Youtube, Vimeo and HTML5 are each a provider of their own. Each provider inherits from the PlyrProvider class. Configs specific to each provider are now inside their static config property. It also make Youtube and Vimeo independent from the code base.
This PR has been tested on Chrome, Firefox and Edge. I don't have access to IE 10 and 11, so I need someone to test it thoroughly.

Checklist

  • Use develop as the base branch
  • Exclude the gulp build (/dist changes) from the PR
  • Test on supported browsers

akuma06 added 14 commits May 18, 2020 01:02
The plugin system as I coded it pass the player instance as a parameter. Therefore, even though I do not change the parameter per se, I enable modifying property of it (source, speed, ...).
Removing isYoutube and isVimeo functions. Since there might be a lot of external platforms supported, internal function for just 2 platforms shouldn't be the norm.
Removing the providers constant, it is now a static property on Plyr class. This way it can be augmented through the static "use" method and can be accessed through all Plyr class instanciation. The providers static property is now an array of PlyrProvider class.

getProviderByUrl is also moved as a static method inside Plyr and returns a PlyrProvider class instead of a string.
Config for both vimeo and youtube has been moved to their provider class. Every PyrProvider has a static config property. When adding the PyrProvider to Pyr, the config is set inside config[PyrProvider.name].

The only YouTube event still relevant is statechange (qualitychange support has been removed in a previous release). This event is moved to the static events method of the YouTubeProvider. Each PlyrProvider has a static events method returning an array of additional event specific to the provider.
Wether to display quality options or not should be the provider decision. Some providers might handle the quality option. Therefore a static getQualityOptions method can be implemented inside the PlyrProvider.
Example: HTML5Provider.
Pointing to the new way to get the name of the provider for the css class.

Removing the conditions to better implement new external providers. Since the provider is set before media.setup is called, there is no reason why not just call this.provider.setup.

Also moving specific configuration of speed (youtube.js and vimeo.js) here. So the speed availability is always automatically set according to the provider speed available and the options configured.
Fixing the new way to call the methods for HTML5Provider.

this.provider is not a string anymore but PlyrProvider class. So we call Plyr.getProvider(provider) to get the class corresponding to the provider string.
New provider class. Every new plugin should inherit this class and provide the mandatory methods. Other methods have default values and can be omitted.
Typescript definition for the new PlyrProvider class
Vimeo is now a class inheriting PlyrProvider. Besides replacing the use of "this" by the "player" parameter, there are the mandatory methods and the vimeo config added here.
Same as vimeo, youtube has now its config set here. It is possible to change the youtube config by modifying the static property.

There is a beforeSetup event for youtube due to the playsinline url parameter.
HTML5 is also a provider in the same way vimeo and youtube are. Besides the replacing of "this" by "player" instance, there getQualityOptions which is implemented as a static method now.
At every new instance, each provider specific config and events are added to it.

getProviderByUrl is now a static method of Plyr.

this.config.playsinline is true by default and is now modified in the beforeSetup static method for YouTube.

New getProvider static method to get the PyrProvider class by its name.

As long as now provider is found, this.provider is undefined.

Type depend on what the provider decides it to be. Some external provider might be of Audio types.

HTML5Provider can be of Video or Audio type, therefore the static method decides it. This is also an example for provider that have both types.

When destroying a player, the static method destroy is called on the provider asyncally. When it's done, the callback is called to finish destroying.
Definitions based on my previous PR. This enables external providers to augment the ProviderEventMap interface with their own specific events.
@hirbod
Copy link

hirbod commented Mar 17, 2021

Sad.. This was actually a pretty good PR. I was hoping to add my own plugin for "youku"...

@akuma06
Copy link
Contributor Author

akuma06 commented Mar 18, 2021

I could potentially update this pr to the last commit. However with no feedback from anyone I don't want to work on it for nothing :). If @sampotts wants at some point to implement this, I will do it though.

@hirbod
Copy link

hirbod commented Mar 22, 2021

@akuma06 it kinda feels like this repo is somehow dead, considering PRs wont get attention since a year..

@sampotts
Copy link
Owner

@akuma06 it kinda feels like this repo is somehow dead, considering PRs wont get attention since a year..

It's been quieter than usual, yes. Dead, not really. A lot of PRs were merged in December and January.
https://github.com/sampotts/plyr/pulls?q=is%3Apr+is%3Aclosed

I'm concentrating on a major development for the next version of Plyr which will mean a total codebase change. I can't reveal too much just yet, suffice to say it will be a major change.

@hirbod
Copy link

hirbod commented Mar 22, 2021

@sampotts thanks for clarification, didn't meant to be rude or anything. Good news so far. Will there be a plugin system? There is indeed need for other providers and it would be lovely to be able to extend this.

Since I'm not sure when the new major release will be out, it might a good idea to implement this PR though (if it meets your requirements)

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.

None yet

3 participants