Closed Shawlee76 closed 3 years ago
Hi, there are no methods for this, you can do it without, like this example:
<div id="player" class="vlite-js" data-youtube-id="C4qgAaxB_pc"></div>
<button id="button">Change video</button>
import 'vlitejs/dist/vlite.css';
import Vlitejs from 'vlitejs';
import VlitejsYoutube from 'vlitejs/dist/providers/youtube';
Vlitejs.registerProvider('youtube', VlitejsYoutube)
const vlite = new Vlitejs('#player', { provider: 'youtube' })
document.getElementById('button').addEventListener('click', (e) => {
e.preventDefault()
vlite.destroy()
document
.querySelector('body')
.insertAdjacentHTML(
'beforeend',
'<div id="player" class="vlite-js" data-youtube-id="1VIZ89FEjYI"></div>'
)
const newVlite = new Vlitejs('#player', {
provider: 'youtube',
onReady: (player) => {
player.play()
}
})})
Hi how can I load another youtube video to replace the current one which is being played ? I don't understand which methods I have to use in order to : 1- Stop or unload the video, 2- replace the youtube key by another 3- Play the new video.
Thanks by advance. Charlie