redxtech / vue-plyr

A Vue component for the plyr (https://github.com/sampotts/plyr) video & audio player.
Other
770 stars 136 forks source link

Allow youtube player controls(copy link, clickable title etc) #214

Closed trosck closed 3 years ago

trosck commented 4 years ago

The problem is that I cant click on youtube top controls, which as copy link, watch later etc My solution further, hope that will be useful for someone else Works fine, but on some milliseconds shows Youtube button, which(i think) can't be fixed

VuePlyr.js

const VuePlyr = require("vue-plyr/dist/vue-plyr.cjs").VuePlyr
require("plyr/dist/plyr.css")
require("./plyr.css")

window.addEventListener("DOMContentLoaded", ( ) => {
  const plyrs = document.getElementsByClassName("plyr--youtube")

  plyrs.forEach(el => {
    el.addEventListener("click", hidePoster)

    function hidePoster() {
      const poster = el.getElementsByClassName("plyr__poster")[0]
      poster.style.display = "none"

      el.removeEventListener("click", hidePoster)
    }
  })
})

/** 
  * or you can write like here
  * https://github.com/redxtech/vue-plyr/blob/master/src/main.js
  */
VuePlyr.install = Vue => Vue.component(VuePlyr.name, VuePlyr)

module.exports = VuePlyr

plyr.css

.plyr__controls {
    padding-top: 0 !important;
}
redxtech commented 3 years ago

I'm pretty sure that's because of overlays/invisible parts of elements, sizing and such. This is most likely an issue with upstream, so I'll close this issue for now.