Closed dy closed 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.
This has been fixed and merged in main
.
Release 4.0.1
is available ! 🎉
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.
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.
new Vlitejs(document.getElementById('player'));
−Uncaught TypeError: Cannot destructure property 'options' of 'undefined' as it is undefined.
new Vlitejs(document.getElementById('player'), {});
−Uncaught TypeError: vlitejs :: The element or selector supplied is not valid.
new Vlitejs('#player', {})
−Cannot read property 'autoplay' of undefined
new Vlitejs('#player',{options:{}})
− just hangsnew Vlitejs('#player', {options:{}, provider:'youtube'})
−Uncaught Error: vlitejs :: Unknown provider "youtube"
Basically blocked