2020-09-05 16:25:28 +00:00
|
|
|
<template>
|
2020-09-06 17:09:02 +00:00
|
|
|
<div class="bday">
|
2020-09-06 00:44:39 +00:00
|
|
|
<h1>Alles Gute zu Deinem Geburtstag!</h1>
|
2020-09-06 17:09:02 +00:00
|
|
|
<div ref="plyrContainer" class="plyrContainer">
|
|
|
|
<img
|
|
|
|
ref="play"
|
|
|
|
class="play"
|
|
|
|
src="../assets/play.png"
|
|
|
|
usemap="#play"
|
|
|
|
v-show="playVisible"
|
|
|
|
@click="playClicked"
|
|
|
|
/>
|
|
|
|
<map name="#play">
|
|
|
|
<area shape="circle" coords="50, 50, 50" @click="playClicked" />
|
|
|
|
</map>
|
|
|
|
<vue-plyr
|
|
|
|
ref="plyr"
|
|
|
|
:options="plyrOptions"
|
|
|
|
:emit="['timeupdate', 'ready']"
|
|
|
|
@timeupdate="videoTimeUpdated"
|
|
|
|
@ready="videoLoaded"
|
|
|
|
>
|
|
|
|
<!-- inserted dynamically -->
|
|
|
|
<video poster="../assets/poster.png" />
|
|
|
|
</vue-plyr>
|
|
|
|
</div>
|
2020-09-06 00:44:39 +00:00
|
|
|
</div>
|
2020-09-05 16:25:28 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2020-09-07 00:16:05 +00:00
|
|
|
name: "Gratulation",
|
2020-09-06 00:44:39 +00:00
|
|
|
|
2020-09-06 00:58:00 +00:00
|
|
|
data: () => ({
|
2020-09-06 16:12:22 +00:00
|
|
|
videoQueue: ["part1", "part2"],
|
|
|
|
currentVideo: -1,
|
2020-09-06 15:32:49 +00:00
|
|
|
|
|
|
|
playVisible: true,
|
2020-09-06 14:52:05 +00:00
|
|
|
|
2020-09-06 15:14:51 +00:00
|
|
|
plyrOptions: {
|
2020-09-06 00:58:00 +00:00
|
|
|
clickToPlay: false,
|
|
|
|
keyboard: { focused: false, global: false },
|
|
|
|
controls: ["mute", "volume", "settings", "airplay", "fullscreen"],
|
|
|
|
settings: ["quality"],
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
|
2020-09-06 15:14:51 +00:00
|
|
|
computed: {
|
|
|
|
player() {
|
|
|
|
return this.$refs.plyr.player;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-09-06 14:52:05 +00:00
|
|
|
methods: {
|
2020-09-06 15:32:49 +00:00
|
|
|
getVideoSource: function (index) {
|
2020-09-06 15:14:51 +00:00
|
|
|
let source = {
|
|
|
|
type: "video",
|
|
|
|
sources: [],
|
|
|
|
};
|
|
|
|
|
|
|
|
for (const height of [240, 360, 480]) {
|
|
|
|
source.sources.push({
|
2020-09-06 16:12:22 +00:00
|
|
|
src: "/fake_api/" + this.videoQueue[index] + "_" + height + ".mp4",
|
2020-09-06 15:14:51 +00:00
|
|
|
type: "video/mp4",
|
|
|
|
size: height,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return source;
|
|
|
|
},
|
|
|
|
|
2020-09-07 00:16:05 +00:00
|
|
|
videoTimeUpdated() {
|
2020-09-06 15:32:49 +00:00
|
|
|
// show play button after 3 seconds, then disable this event
|
2020-09-06 16:12:22 +00:00
|
|
|
if (this.player.currentTime > 3) {
|
2020-09-06 15:14:51 +00:00
|
|
|
this.playVisible = true;
|
2020-09-06 14:52:05 +00:00
|
|
|
this.videoTimeUpdated = () => true;
|
|
|
|
}
|
2020-09-06 15:14:51 +00:00
|
|
|
},
|
2020-09-06 15:32:49 +00:00
|
|
|
|
2020-09-07 00:16:05 +00:00
|
|
|
videoLoaded() {
|
2020-09-06 17:09:02 +00:00
|
|
|
this.placePlay();
|
2020-09-06 16:12:22 +00:00
|
|
|
if (this.currentVideo >= 0) {
|
|
|
|
this.player.play();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-09-07 00:16:05 +00:00
|
|
|
playClicked() {
|
2020-09-06 15:32:49 +00:00
|
|
|
this.playVisible = false;
|
|
|
|
|
2020-09-06 16:12:22 +00:00
|
|
|
this.currentVideo += 1;
|
|
|
|
this.player.source = this.getVideoSource(this.currentVideo);
|
2020-09-06 15:32:49 +00:00
|
|
|
},
|
2020-09-06 17:09:02 +00:00
|
|
|
|
2020-09-07 00:16:05 +00:00
|
|
|
placePlay() {
|
2020-09-06 17:09:02 +00:00
|
|
|
let top = (this.$refs.plyrContainer.offsetHeight - 100) / 2;
|
|
|
|
let left = (this.$refs.plyrContainer.offsetWidth - 100) / 2;
|
|
|
|
|
|
|
|
console.log(left, top);
|
|
|
|
|
|
|
|
this.$refs.play.style.top = top + "px";
|
|
|
|
this.$refs.play.style.left = left + "px";
|
|
|
|
},
|
2020-09-06 14:52:05 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2020-09-06 00:44:39 +00:00
|
|
|
document.title = "Herzlichen Glückwunsch!";
|
2020-09-06 17:09:02 +00:00
|
|
|
window.addEventListener("resize", this.placePlay);
|
2020-09-06 00:44:39 +00:00
|
|
|
},
|
|
|
|
};
|
2020-09-05 16:25:28 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2020-09-06 17:09:02 +00:00
|
|
|
div.bday {
|
2020-09-06 00:44:39 +00:00
|
|
|
margin: auto;
|
2020-09-06 17:09:02 +00:00
|
|
|
max-width: 854px;
|
|
|
|
}
|
|
|
|
|
|
|
|
div.plyrContainer {
|
2020-09-06 14:52:05 +00:00
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
2020-09-06 17:09:02 +00:00
|
|
|
img.play {
|
2020-09-06 14:52:05 +00:00
|
|
|
outline: none;
|
|
|
|
|
2020-09-06 15:14:51 +00:00
|
|
|
-webkit-user-select: none; /* Safari */
|
2020-09-06 14:52:05 +00:00
|
|
|
-moz-user-select: none; /* Firefox */
|
|
|
|
-ms-user-select: none; /* IE10+/Edge */
|
|
|
|
user-select: none; /* Standard */
|
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1001;
|
|
|
|
}
|
|
|
|
|
2020-09-06 15:14:51 +00:00
|
|
|
map area {
|
2020-09-06 14:52:05 +00:00
|
|
|
outline: none;
|
|
|
|
cursor: pointer;
|
2020-09-05 16:25:28 +00:00
|
|
|
}
|
2020-09-05 17:28:34 +00:00
|
|
|
</style>
|