123movies-seo/resources/js/components/Trailer.js

37 lines
963 B
JavaScript
Raw Normal View History

2024-08-24 23:08:42 +03:00
export default () => {
return {
show: false,
player: false,
init() {
// this.open();
},
open() {
if (this.player) {
this.show = true;
this.player.play();
} else {
const player = (new Plyr("#trailer", {
autoplay: true,
youtube: {
noCookie: false,
rel: 0,
showinfo: 0,
iv_load_policy: 3,
modestbranding: 1,
},
}).on("ready", (ev) => {
this.player = ev.detail.plyr;
this.show = true;
}));
}
},
close() {
this.player.pause();
this.show = false;
},
isOpen() {
return this.show === true;
},
};
};