From 200ebd13e045ae69256c309dd4dcb0129441d162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Sun, 6 Sep 2020 17:14:51 +0200 Subject: [PATCH] dynamic plyr source --- ui/src/components/BDay.vue | 55 ++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/ui/src/components/BDay.vue b/ui/src/components/BDay.vue index 0637366..4ff25e9 100644 --- a/ui/src/components/BDay.vue +++ b/ui/src/components/BDay.vue @@ -1,16 +1,18 @@ @@ -20,9 +22,9 @@ export default { name: "BDay", data: () => ({ - play_visible: false, + playVisible: false, - plyr_options: { + plyrOptions: { autoplay: true, clickToPlay: false, keyboard: { focused: false, global: false }, @@ -31,18 +33,43 @@ export default { }, }), + computed: { + player() { + return this.$refs.plyr.player; + }, + }, + methods: { + getVideoSource: function (name) { + let source = { + type: "video", + poster: "../assets/poster.png", + sources: [], + }; + + for (const height of [240, 360, 480]) { + source.sources.push({ + src: "/fake_api/" + name + "_" + height + ".mp4", + type: "video/mp4", + size: height, + }); + } + + return source; + }, + videoTimeUpdated: function (event) { // show play button after 3 seconds, then disable event if (event.timeStamp > 3000) { - this.play_visible = true; + this.playVisible = true; this.videoTimeUpdated = () => true; } - } + }, }, mounted() { document.title = "Herzlichen Glückwunsch!"; + this.player.source = this.getVideoSource("part1"); }, }; @@ -57,7 +84,7 @@ div#bday { img#play { outline: none; - -webkit-user-select: none; /* Safari */ + -webkit-user-select: none; /* Safari */ -moz-user-select: none; /* Firefox */ -ms-user-select: none; /* IE10+/Edge */ user-select: none; /* Standard */ @@ -68,7 +95,7 @@ img#play { z-index: 1001; } -map area{ +map area { outline: none; cursor: pointer; }