Compare commits

..

No commits in common. "ad4493380a934a1e4ea1bdb3a524234d03d39311" and "5a3a26139acf15aa687dbb76f85431b95dc41f43" have entirely different histories.

View file

@ -1,29 +1,19 @@
<template> <template>
<div class="bday"> <div id="bday">
<h1>Alles Gute zu Deinem Geburtstag!</h1> <h1>Alles Gute zu Deinem Geburtstag!</h1>
<div ref="plyrContainer" class="plyrContainer"> <img id="play" src="../assets/play.png" usemap="#play" v-if="playVisible" />
<img <map name="#play">
ref="play" <area shape="circle" coords="50, 50, 50" @click="playClicked" />
class="play" </map>
src="../assets/play.png" <vue-plyr
usemap="#play" ref="plyr"
v-show="playVisible" :options="plyrOptions"
@click="playClicked" :emit="['timeupdate']"
/> @timeupdate="videoTimeUpdated"
<map name="#play"> >
<area shape="circle" coords="50, 50, 50" @click="playClicked" /> <!-- inserted dynamically -->
</map> <video />
<vue-plyr </vue-plyr>
ref="plyr"
:options="plyrOptions"
:emit="['timeupdate', 'ready']"
@timeupdate="videoTimeUpdated"
@ready="videoLoaded"
>
<!-- inserted dynamically -->
<video poster="../assets/poster.png" />
</vue-plyr>
</div>
</div> </div>
</template> </template>
@ -32,8 +22,8 @@ export default {
name: "BDay", name: "BDay",
data: () => ({ data: () => ({
videoQueue: ["part1", "part2"], sourceNames: ["part1", "part2"],
currentVideo: -1, playing: null,
playVisible: true, playVisible: true,
@ -55,12 +45,13 @@ export default {
getVideoSource: function (index) { getVideoSource: function (index) {
let source = { let source = {
type: "video", type: "video",
poster: "../assets/poster.png",
sources: [], sources: [],
}; };
for (const height of [240, 360, 480]) { for (const height of [240, 360, 480]) {
source.sources.push({ source.sources.push({
src: "/fake_api/" + this.videoQueue[index] + "_" + height + ".mp4", src: "/fake_api/" + this.sourceNames[index] + "_" + height + ".mp4",
type: "video/mp4", type: "video/mp4",
size: height, size: height,
}); });
@ -69,57 +60,53 @@ export default {
return source; return source;
}, },
videoTimeUpdated: function () { videoTimeUpdated: function (event) {
// show play button after 3 seconds, then disable this event // show play button after 3 seconds, then disable this event
if (this.player.currentTime > 3) { if (event.timeStamp > 3000) {
this.playVisible = true; this.playVisible = true;
this.videoTimeUpdated = () => true; this.videoTimeUpdated = () => true;
} }
}, },
videoLoaded: function () {
this.placePlay();
if (this.currentVideo >= 0) {
this.player.play();
}
},
playClicked: function () { playClicked: function () {
this.playVisible = false; this.playVisible = false;
this.currentVideo += 1; switch (this.playing) {
this.player.source = this.getVideoSource(this.currentVideo); case null:
}, // nothing playing: play first source
this.playing = 0;
this.player.play();
break;
placePlay: function () { case 0:
let top = (this.$refs.plyrContainer.offsetHeight - 100) / 2; // first source playing: play second source
let left = (this.$refs.plyrContainer.offsetWidth - 100) / 2; this.playing = 1;
this.player.source = this.getVideoSource(1);
console.log(left, top); this.player.play();
break;
this.$refs.play.style.top = top + "px";
this.$refs.play.style.left = left + "px"; default:
console.log("ERROR: Stranger things are starting to begin!");
break;
}
}, },
}, },
mounted() { mounted() {
document.title = "Herzlichen Glückwunsch!"; document.title = "Herzlichen Glückwunsch!";
window.addEventListener("resize", this.placePlay); this.player.source = this.getVideoSource(0);
}, },
}; };
</script> </script>
<style scoped> <style scoped>
div.bday { div#bday {
margin: auto; margin: auto;
max-width: 854px; width: 854px;
}
div.plyrContainer {
position: relative; position: relative;
} }
img.play { img#play {
outline: none; outline: none;
-webkit-user-select: none; /* Safari */ -webkit-user-select: none; /* Safari */
@ -128,6 +115,8 @@ img.play {
user-select: none; /* Standard */ user-select: none; /* Standard */
position: absolute; position: absolute;
bottom: 190px;
left: 377px;
z-index: 1001; z-index: 1001;
} }