It is very handy to create a custom player based on youtube videos, checkout this website for example : https://foreignrap.com Show InstallationFirst add it to your project via yarn:
OR npm:
Then, tell Vue about the plugin (Note that the name of the variable here is up to you).
This Vue plugin gives you access to a However, you can use the component name you want by importing the component locally or globally.
How it works ?Just add the component where you want with either a ytid or yturl prop. When the prop changes, the player will automatically load the new relevant video. Component Propspropdescriptiontypedefaultytidthe youtube video id (found in the url) note: both "ytid" & "yturl" can't be used at the same timeStringnullyturlthe youtube video url (the id will be auto-detected) note: both "ytid" & "yturl" can't be used at the same timeStringnullwidththe iframe's width note: youtube asks for 200 minimumStringNumberheightthe iframe's height note: youtube asks for 200 minimumStringNumberplayerVarsthe iframe's player variables, full list: https://developers.google.com/youtube/player_parameters?hl=frObject{}Make sure to look at all player variables as this will help you remove controls from the youtube iframe. https://developers.google.com/youtube/player_parameters?hl=fr Component Eventseventdescriptionreadyfires when the player is ready and the player's instance can be usederrorfires when the player encounters an error https://developers.google.com/youtube/iframe_api_reference?hl=fr#Eventsunstartedfires when player ready but not started because no videoplayingfires when player starts playingpausedfires when player stops playing and is on pausecuedfires when a video was added to the player's queue but hasn't played yetbufferingfires when player starts buffering / loadingendedfires when player video has endedComponent MethodsYou can access these methods by adding a ref on the component. methoddescriptionparamsloadByIdprogramatically loads a new video on the player by IDid: StringloadByUrlprogramatically loads a new video on the player by URLurl: StringYoutube Player instanceYou can access the youtube player's instance by adding a ref on the component. You need to wait for the player to be ready though. When the player is not ready, the property holding the instance is null. Full list of the instance's methods you can use below: https://developers.google.com/youtube/iframe_api_reference?hl=fr#Playback_controls |