Compare commits
2 commits
5a3a26139a
...
ad4493380a
Author | SHA1 | Date | |
---|---|---|---|
ad4493380a | |||
4ac92d972c |
1 changed files with 54 additions and 43 deletions
|
@ -1,20 +1,30 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="bday">
|
<div class="bday">
|
||||||
<h1>Alles Gute zu Deinem Geburtstag!</h1>
|
<h1>Alles Gute zu Deinem Geburtstag!</h1>
|
||||||
<img id="play" src="../assets/play.png" usemap="#play" v-if="playVisible" />
|
<div ref="plyrContainer" class="plyrContainer">
|
||||||
|
<img
|
||||||
|
ref="play"
|
||||||
|
class="play"
|
||||||
|
src="../assets/play.png"
|
||||||
|
usemap="#play"
|
||||||
|
v-show="playVisible"
|
||||||
|
@click="playClicked"
|
||||||
|
/>
|
||||||
<map name="#play">
|
<map name="#play">
|
||||||
<area shape="circle" coords="50, 50, 50" @click="playClicked" />
|
<area shape="circle" coords="50, 50, 50" @click="playClicked" />
|
||||||
</map>
|
</map>
|
||||||
<vue-plyr
|
<vue-plyr
|
||||||
ref="plyr"
|
ref="plyr"
|
||||||
:options="plyrOptions"
|
:options="plyrOptions"
|
||||||
:emit="['timeupdate']"
|
:emit="['timeupdate', 'ready']"
|
||||||
@timeupdate="videoTimeUpdated"
|
@timeupdate="videoTimeUpdated"
|
||||||
|
@ready="videoLoaded"
|
||||||
>
|
>
|
||||||
<!-- inserted dynamically -->
|
<!-- inserted dynamically -->
|
||||||
<video />
|
<video poster="../assets/poster.png" />
|
||||||
</vue-plyr>
|
</vue-plyr>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -22,8 +32,8 @@ export default {
|
||||||
name: "BDay",
|
name: "BDay",
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
sourceNames: ["part1", "part2"],
|
videoQueue: ["part1", "part2"],
|
||||||
playing: null,
|
currentVideo: -1,
|
||||||
|
|
||||||
playVisible: true,
|
playVisible: true,
|
||||||
|
|
||||||
|
@ -45,13 +55,12 @@ 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.sourceNames[index] + "_" + height + ".mp4",
|
src: "/fake_api/" + this.videoQueue[index] + "_" + height + ".mp4",
|
||||||
type: "video/mp4",
|
type: "video/mp4",
|
||||||
size: height,
|
size: height,
|
||||||
});
|
});
|
||||||
|
@ -60,53 +69,57 @@ export default {
|
||||||
return source;
|
return source;
|
||||||
},
|
},
|
||||||
|
|
||||||
videoTimeUpdated: function (event) {
|
videoTimeUpdated: function () {
|
||||||
// show play button after 3 seconds, then disable this event
|
// show play button after 3 seconds, then disable this event
|
||||||
if (event.timeStamp > 3000) {
|
if (this.player.currentTime > 3) {
|
||||||
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;
|
||||||
|
|
||||||
switch (this.playing) {
|
this.currentVideo += 1;
|
||||||
case null:
|
this.player.source = this.getVideoSource(this.currentVideo);
|
||||||
// nothing playing: play first source
|
},
|
||||||
this.playing = 0;
|
|
||||||
this.player.play();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0:
|
placePlay: function () {
|
||||||
// first source playing: play second source
|
let top = (this.$refs.plyrContainer.offsetHeight - 100) / 2;
|
||||||
this.playing = 1;
|
let left = (this.$refs.plyrContainer.offsetWidth - 100) / 2;
|
||||||
this.player.source = this.getVideoSource(1);
|
|
||||||
this.player.play();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
console.log(left, top);
|
||||||
console.log("ERROR: Stranger things are starting to begin!");
|
|
||||||
break;
|
this.$refs.play.style.top = top + "px";
|
||||||
}
|
this.$refs.play.style.left = left + "px";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
document.title = "Herzlichen Glückwunsch!";
|
document.title = "Herzlichen Glückwunsch!";
|
||||||
this.player.source = this.getVideoSource(0);
|
window.addEventListener("resize", this.placePlay);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
div#bday {
|
div.bday {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
width: 854px;
|
max-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 */
|
||||||
|
@ -115,8 +128,6 @@ img#play {
|
||||||
user-select: none; /* Standard */
|
user-select: none; /* Standard */
|
||||||
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 190px;
|
|
||||||
left: 377px;
|
|
||||||
z-index: 1001;
|
z-index: 1001;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue