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

Using vue-youtube-embed in Nuxt.js #44

Open
milospantelinac opened this issue Jun 8, 2018 · 11 comments
Open

Using vue-youtube-embed in Nuxt.js #44

milospantelinac opened this issue Jun 8, 2018 · 11 comments
Labels

Comments

@milospantelinac
Copy link

I have got problem with vue-youtube-embed. I don't know to implement in Nuxt.js project. I had install vue-youtube-embed across npm. Do anybody can to write the implementation process? PLS

@kaorun343 kaorun343 added the nuxt label Jun 15, 2018
@dandanXO
Copy link

dandanXO commented Jun 20, 2018

I solve the problem using nuxt's plugins

  1. add file in plugins folder name youtube.js(or what you want)
  2. edit youtube.js write

import Vue from 'vue'

import VueYouTubeEmbed from 'vue-youtube-embed'

Vue.use(VueYouTubeEmbed)

Vue.use(VueYouTubeEmbed, { global: true })
  1. edit nuxt.config.js write
plugins: [
    '@/plugins/vuetify',
    '@/plugins/youtube'
  ]
  1. restart npm run dev and use no-ssr way to use <youtube> component
    like this
<no-ssr  placeholder="Loading...">
             <youtube  @ready="ready" :player-vars="{ autoplay: 1 }" :player-width="100" :player-height="100" :video-id="play" />
       </no-ssr>

this is my Solution
if have better solution plz tell me.

@leofachini
Copy link

I've had to import the plugin this way to work properly in nuxt instead.

plugins: [ { src: '@/plugins/youtube.js', ssr: false } ]

Also, i didn't need the <no-ssr /> tag.

@phivk
Copy link

phivk commented Mar 20, 2019

another thing I had to change from the provided example code to make this work, was to turn

data: {
    videoId: 'videoId',
},

into:

data() {
    return {
        videoId: 'videoId'
    }
},

@catman85
Copy link

Anyone knows how to get access to these methods in nuxt.js?

  • getIdFromURL
  • getTimeFromURL

@lystun
Copy link

lystun commented Oct 13, 2020

You may want to add the plugin to the transpile build option as such:

build: { transpile : ['vue-youtube-embed'] }

That should do it.

@cam424
Copy link

cam424 commented Oct 28, 2020

@lystun That was the missing piece of the puzzle for me. Thanks!

@engrmafzaalch
Copy link

this.videoId = this.$youtube.getIdFromURL(this.link)
@catman85

@SameeranB
Copy link

Hey... for anyone still stuck here... I got it working this way:

First create a js file in the plugins directory with the following code. Mine is called vue-youtube-player.js

import VueYouTubeEmbed, {YouTubePlayer} from "vue-youtube-embed";
import Vue from "vue";

Vue.use(VueYouTubeEmbed, {global: true});

Vue.component('vue-youtube-player', YouTubePlayer)

As far as I understand why, it's because VueYouTubeEmbed is a plugin, not a component. So this way we tell Vue to use the plugin but also register the component.

Add this file to nuxt.config.js in your plugins:

  ...
  plugins: [
    '~/plugins/vue-youtube-player.js',
  ],
  ...

Then in the component or page you want to use the player:

    ...
     <client-only>
         <vue-youtube-player :video-id="videoID"></vue-youtube-player>
    </client-only>
    ...   
    
 <script>
    export default {
      data() {
          return {
              videoID: "VL_r7jtt7PA"
          }
       }
     }
</script>

Hope this helps :)

@ihsanfy
Copy link

ihsanfy commented Jun 2, 2021

how do i hide the logo and reference video in nuxt.js?

@yiyasha15
Copy link

I followed the steps but I'm getting this error!

An error occurred. Please try again later. (Playback ID: 0jp1TNFmXFgYNYmf)

Please help!

@Dan88Hus
Copy link

Dan88Hus commented Jul 29, 2021

you are trying to bind video-id so it gives error because there is no value for that.

 <youtube :video-id="ogfYd705cRs"></youtube> this example in your case must be <youtube video-id="ogfYd705cRs"></youtube>

I hope this helps if I am right to understand your problem.

I followed the steps but I'm getting this error!

An error occurred. Please try again later. (Playback ID: 0jp1TNFmXFgYNYmf)

Please help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests