kaorun343 / vue-youtube-embed

Vue.js and YouTube
https://www.npmjs.com/package/vue-youtube-embed
MIT License
424 stars 53 forks source link

Failed to execute 'postMessage' on 'DOMWindow' #51

Open Demy opened 6 years ago

Demy commented 6 years ago

Embedding video to the page causes this error in the console: Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin (*host name*)

"Angular YouTube Embed" has the same problem.

SDVII commented 6 years ago

I think adding a host to the YouTube Player object could fix the issue:

  this$1.player = new YouTube.Player(this$1.elementId, {
    ...
    host: 'https://www.youtube.com',
    ...
  }
Anploe commented 5 years ago

i yust had the same issue and at least in my local enviroment setting :player-vars="{origin:'http://mydomain.local'}" seems to solve the issue

renetik commented 5 years ago
<template>
  <iframe :height="height" :src="youtubeUrl()" :width="width"/>
</template>

<script lang="ts">
  import { Component, Prop, Vue } from 'vue-property-decorator'

  @Component
  export default class CSYoutubeVideo extends Vue {

    @Prop({ required: true }) videoId!: string
    @Prop({ required: true }) width!: string
    @Prop({ required: true }) height!: string

    youtubeUrl(): string {
      return `https://www.youtube.com/embed/${this.videoId}?modestbranding=1&playsinline=0
      &showinfo=0&enablejsapi=1&origin=${window.location.origin}&widgetid=1`
    }
  }
</script>
dezignhero commented 4 years ago

for playerVars setting origin: window.location.origin worked for me.

sioniks commented 3 years ago

for playerVars setting origin: window.location.origin worked for me.

for me worked to, but window.location.origin i set like String