vue-youtube-embed icon indicating copy to clipboard operation
vue-youtube-embed copied to clipboard

Failed to execute 'postMessage' on 'DOMWindow'

Open Demy opened this issue 7 years ago • 5 comments

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.

Demy avatar Aug 06 '18 15:08 Demy

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',
    ...
  }

SDVII avatar Sep 12 '18 09:09 SDVII

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

Anploe avatar Oct 02 '18 10:10 Anploe

<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>

renetik avatar May 21 '19 00:05 renetik

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

dezignhero avatar May 14 '20 07:05 dezignhero

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

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

sioniks avatar Dec 17 '20 15:12 sioniks