bday2020/ui/src/components/BDay.vue

103 lines
2 KiB
Vue
Raw Normal View History

2020-09-05 16:25:28 +00:00
<template>
2020-09-06 14:52:05 +00:00
<div id="bday">
2020-09-06 00:44:39 +00:00
<h1>Alles Gute zu Deinem Geburtstag!</h1>
2020-09-06 15:14:51 +00:00
<img id="play" v-if="playVisible" src="../assets/play.png" usemap="#play" />
2020-09-06 14:52:05 +00:00
<map name="#play">
2020-09-06 15:14:51 +00:00
<area shape="circle" coords="50, 50, 50" />
2020-09-06 14:52:05 +00:00
</map>
2020-09-06 15:14:51 +00:00
<vue-plyr
ref="plyr"
:options="plyrOptions"
:emit="['timeupdate']"
@timeupdate="videoTimeUpdated"
>
<!-- inserted dynamically -->
<video />
2020-09-06 00:44:39 +00:00
</vue-plyr>
</div>
2020-09-05 16:25:28 +00:00
</template>
<script>
export default {
2020-09-06 00:44:39 +00:00
name: "BDay",
2020-09-06 00:58:00 +00:00
data: () => ({
2020-09-06 15:14:51 +00:00
playVisible: false,
2020-09-06 14:52:05 +00:00
2020-09-06 15:14:51 +00:00
plyrOptions: {
2020-09-06 14:52:05 +00:00
autoplay: true,
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:14:51 +00:00
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;
},
2020-09-06 14:52:05 +00:00
videoTimeUpdated: function (event) {
// show play button after 3 seconds, then disable event
if (event.timeStamp > 3000) {
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 14:52:05 +00:00
},
mounted() {
2020-09-06 00:44:39 +00:00
document.title = "Herzlichen Glückwunsch!";
2020-09-06 15:14:51 +00:00
this.player.source = this.getVideoSource("part1");
2020-09-06 00:44:39 +00:00
},
};
2020-09-05 16:25:28 +00:00
</script>
<style scoped>
2020-09-06 14:52:05 +00:00
div#bday {
2020-09-06 00:44:39 +00:00
margin: auto;
2020-09-06 14:52:05 +00:00
width: 854px;
position: relative;
}
img#play {
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;
bottom: 190px;
left: 377px;
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>