vlitejs / vlite

🦋 vLitejs is a fast and lightweight Javascript library for customizing video and audio player in Javascript with a minimalist theme (HTML5, Youtube, Vimeo, Dailymotion)
https://vlite.js.org
MIT License
268 stars 18 forks source link

Running readme issues #42

Closed dy closed 3 years ago

dy commented 3 years ago
<div id="player" class="vlite-js" data-youtube-id="EO4urNqjjRE"></div>

Basically blocked

yoriiis commented 3 years ago

All your examples are invalid if you are using the Youtube provider, check the example on this README. But, the first 4 syntaxes are valid with the HTML5 provider and there was a bug, fixed in the #43.

yoriiis commented 3 years ago

This has been fixed and merged in main. Release 4.0.1 is available ! 🎉

dy commented 3 years ago

Following the youtube readme:

<div id="player" class="vlite-js" data-youtube-id="EO4urNqjjRE"></div>
import 'vlitejs/dist/vlite.css';
import Vlitejs from 'vlitejs';
import VlitejsYoutube from 'vlitejs/dist/providers/youtube';

Vlitejs.registerProvider('youtube', VlitejsYoutube);

new Vlitejs({
  selector: '#player',
  provider: 'youtube'
});

Still getting Uncaught TypeError: vlitejs :: The element or selector supplied is not valid.

Although

new Vlitejs('#player',{
  provider: 'youtube'
});

worked.

Looking back at my experience with save-file, I'd opt for a single way arguments should go for initializing the player. Ambiguous arguments create unnecessary complexity and confuse the user, basically that's unmade decision.

yoriiis commented 3 years ago

Thanks for the report, the example is wrong in the documentation (I make the fix!). However, the examples directory is correct if necessary (I use them for my tests).

The correct syntax is this:

new Vlitejs('#player', {
  provider: 'youtube'
});

The parameters are written like this to allow the fast syntax with the default behavior:

new Vlitejs('#player');
new Vlitejs(document.getElementById('player'));

Then, the second parameter (Object) is optional, except if the player uses a provider.

yoriiis commented 3 years ago

This has been fixed and merged in main. Release 4.0.2 is available ! 🎉