Skip to content

Commit

Permalink
Fix video autoplay
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-dldc committed Nov 4, 2018
1 parent bb3a459 commit c56a322
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 111 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Gobelins DataViz",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server --inline --hot --quiet",
"build": "export NODE_ENV=production && webpack --progress --hide-modules",
"start": "gulp",
"build": "export NODE_ENV=production && gulp build",
"deploy": "yarn build && gh-pages -d dist"
},
"dependencies": {
Expand Down
145 changes: 78 additions & 67 deletions src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
</template>

<script>
import Graph from './components/Graph.vue'
import Loader from './components/Loader.vue'
import Sidebar from './components/Sidebar.vue'
import AppTitle from './components/AppTitle.vue'
import Details from './components/Details.vue'
import Intro from './components/Intro.vue'
import Infos from './components/Infos.vue'
import Graph from './components/Graph.vue';
import Loader from './components/Loader.vue';
import Sidebar from './components/Sidebar.vue';
import AppTitle from './components/AppTitle.vue';
import Details from './components/Details.vue';
import Intro from './components/Intro.vue';
import Infos from './components/Infos.vue';
import { Howl } from 'howler';
export default {
Expand All @@ -74,13 +74,13 @@ export default {
AppTitle,
Details,
Intro,
Infos
Infos,
},
data () {
data() {
return {
intro: true,
main: false,
sound: true,
sound: false,
title: false,
infosData: {},
pointerCursor: false,
Expand All @@ -90,73 +90,75 @@ export default {
showDetails: false,
paramsData: {
realGeoloc: false,
hauteur: {
name: 'Rayon d\'action',
hauteur: {
name: "Rayon d'action",
slug: 'hauteur',
multiplier: 0.001,
color: 0xffffff,
user_multiplier: 1,
multiplier: 0.001,
color: 0xffffff,
user_multiplier: 1,
infos: {
title: 'La Hauteur',
description: "La Hauteur est également un facteur majeur de la solitude d’un arbre. S’il se tient plus bas que ses congénères, la frustration générée impacte sur son ressenti. Plus réservé et moins ouvert sur le monde, l’arbre s’enferme alors dans la solitude. Au contraire, s’il est plus haut des autres, l’arbre s’ouvre sur le monde, sa vision est agrandie devient plus social et heureux."
}
},
leafs: {
description:
'La Hauteur est également un facteur majeur de la solitude d’un arbre. S’il se tient plus bas que ses congénères, la frustration générée impacte sur son ressenti. Plus réservé et moins ouvert sur le monde, l’arbre s’enferme alors dans la solitude. Au contraire, s’il est plus haut des autres, l’arbre s’ouvre sur le monde, sa vision est agrandie devient plus social et heureux.',
},
},
leafs: {
arbres_align_dist: {
slug: 'arbres_align_dist',
name: "Arbres d'alignement",
multiplier: 1,
multiplier: 1,
color: 0x16f1d4,
colorLegend: '#16f1d4',
user_multiplier: 1,
max: 104025,
display: true,
colorLegend: '#16f1d4',
user_multiplier: 1,
max: 104025,
display: true,
infos: {
title: "Les Arbres d'alignement",
description: "Lorem ipsum dolor sit amet, tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat, officia deserunt mollit anim id est laborum."
}
},
bancs_dist: {
description:
'Lorem ipsum dolor sit amet, tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat, officia deserunt mollit anim id est laborum.',
},
},
bancs_dist: {
slug: 'bancs_dist',
name: 'Bancs',
color: 0x18f277,
colorLegend: '#18f277',
max: 11581,
multiplier: 1,
user_multiplier: 1,
display: true,
color: 0x18f277,
colorLegend: '#18f277',
max: 11581,
multiplier: 1,
user_multiplier: 1,
display: true,
infos: {
title: "Les Bancs",
description: "Les bancs publics redonnent à l’arbre le goût à la vie. Les bancs publiques sont des lieux de rencontre, de méditation, ou simplement de vie. L’arbre ressent alors cette vie près de lui et se sent moins seul."
}
},
poteaux_bois_dist: {
title: 'Les Bancs',
description:
'Les bancs publics redonnent à l’arbre le goût à la vie. Les bancs publiques sont des lieux de rencontre, de méditation, ou simplement de vie. L’arbre ressent alors cette vie près de lui et se sent moins seul.',
},
},
poteaux_bois_dist: {
slug: 'poteaux_bois_dist',
name: 'Poteaux en Bois',
multiplier: 1,
color: 0x1dacdd,
colorLegend: '#1dacdd',
user_multiplier: 0.5,
max: 137,
display: true,
multiplier: 1,
color: 0x1dacdd,
colorLegend: '#1dacdd',
user_multiplier: 0.5,
max: 137,
display: true,
infos: {
title: "Les Poteaux en bois",
description: "L’absence de poteaux en bois est importante pour le bien-être et le moral de l’arbre. En effet, l’arbre est plus enclin à la dépression s’il s’aperçoit qu’un des congénères morts ( un poteau en bois donc) se trouve à proximité. L’arbre peut alors se recroqueviller sur lui-même perdu dans ses pensées et souvenirs négatifs."
}
}
}
}
title: 'Les Poteaux en bois',
description:
'L’absence de poteaux en bois est importante pour le bien-être et le moral de l’arbre. En effet, l’arbre est plus enclin à la dépression s’il s’aperçoit qu’un des congénères morts ( un poteau en bois donc) se trouve à proximité. L’arbre peut alors se recroqueviller sur lui-même perdu dans ses pensées et souvenirs négatifs.',
},
},
},
},
};
},
ready() {
this.music = new Howl({
urls: ['music/ambient.mp3'],
autoplay: true,
autoplay: false,
loop: true,
volume: 0.5
volume: 0.5,
});
},
methods: {
toggleSound() {
Expand All @@ -168,33 +170,41 @@ export default {
}
this.$broadcast('sound-status', this.sound);
},
playSound() {
this.sound = true;
this.music.play();
this.$broadcast('sound-status', this.sound);
},
closeInfos() {
this.displayInfos = false;
}
},
},
events: {
'loader-off': function () {
'loader-off': function() {
this.displayLoader = false;
},
'params-update': function (params) {
'params-update': function(params) {
this.$broadcast('update-graph');
},
'tree-hover': function (infos, params) {
'tree-hover': function(infos, params) {
this.pointerCursor = true;
clearTimeout(this.hideDetailTimer);
this.details = {
infos,
params
params,
};
this.showDetails = true;
},
'tree-unhover': function () {
'tree-unhover': function() {
this.pointerCursor = false;
this.hideDetailTimer = setTimeout( () => {
this.hideDetailTimer = setTimeout(() => {
this.showDetails = false;
}, 1000);
},
'intro-end': function () {
'intro-start': function() {
this.playSound();
},
'intro-end': function() {
this.main = true;
setTimeout(() => {
this.intro = false;
Expand All @@ -205,11 +215,12 @@ export default {
setTimeout(() => {
this.title = true;
}, 600);
this.playSound();
},
'show-infos': function (infos) {
'show-infos': function(infos) {
this.infosData = infos;
this.displayInfos = true;
}
}
}
},
},
};
</script>
101 changes: 71 additions & 30 deletions src/components/Intro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@
animation-iteration-count: 1;
}
.play-intro{
position: absolute;
z-index: 1110;
color: white;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-family: 'cpcompanyregular' sans-serif;
text-transform: uppercase;
color: #8c8c8c;
-webkit-transition: 0.35s;
transition: 0.35s;
text-decoration: none;
font-size: 12px;
vertical-align: middle;
padding-top: 35px;
letter-spacing: 2px;
cursor:pointer;
}
.play-intro:hover{
color:#999999;
letter-spacing: 2.2px;
}
@keyframes wobbleright {
16.65% {
Expand Down Expand Up @@ -78,6 +102,7 @@
</video>
</div>
<p @click="skipIntro" class="skip-intro">Passer l'intro</p>
<p v-if="!playing" @click="playIntro" class="play-intro">Play Intro</p>
</div>
</template>

Expand All @@ -86,6 +111,11 @@ import $ from 'jquery';
import videojs from 'video.js';
export default {
data() {
return {
playing: false,
};
},
ready() {
let videoRatio = 16 / 9;
let screenWidth = $(this.$el).width();
Expand All @@ -96,57 +126,68 @@ export default {
// Fit height
vidHeight = screenHeight;
vidTop = 0;
vidWidth = vidHeight * (videoRatio);
vidLeft = (screenWidth - vidWidth)/2;
vidWidth = vidHeight * videoRatio;
vidLeft = (screenWidth - vidWidth) / 2;
} else {
// Fit width
vidWidth = screenWidth;
vidLeft = 0;
vidHeight = vidWidth * (1/videoRatio);
vidTop = (screenHeight - vidHeight)/2;
vidHeight = vidWidth * (1 / videoRatio);
vidTop = (screenHeight - vidHeight) / 2;
}
$(this.$el).find('.intro-video').css({
width: vidWidth,
height: vidHeight,
marginLeft: vidLeft,
marginTop: vidTop
});
$(this.$el)
.find('.intro-video')
.css({
width: vidWidth,
height: vidHeight,
marginLeft: vidLeft,
marginTop: vidTop,
});
var that = this;
videojs("video-intro", {
"autoplay": true,
"preload": "auto",
"width": vidWidth,
"height": vidHeight
//"poster": "http://video-js.zencoder.com/oceans-clip.png"
}, function () {
// Player (this) is initialized and ready.
that.player = this;
that.player.play();
that.$dispatch('loader-off');
that.player.on('ended', function() {
that.$dispatch('intro-end');
});
});
videojs(
'video-intro',
{
autoplay: false,
preload: 'auto',
width: vidWidth,
height: vidHeight,
//"poster": "http://video-js.zencoder.com/oceans-clip.png"
},
function() {
// Player (this) is initialized and ready.
that.player = this;
// that.player.play();
that.$dispatch('loader-off');
that.player.on('ended', function() {
that.$dispatch('intro-end');
});
}
);
},
methods: {
skipIntro() {
setTimeout(() => {
this.player.pause();
}, 300);
this.$dispatch('intro-end');
}
},
playIntro() {
this.player.play();
this.playing = true;
this.$dispatch('intro-start');
},
},
events: {
'sound-status': function (sound) {
'sound-status': function(sound) {
console.log(this.player);
if (sound) {
this.player.volume(0);
} else {
this.player.volume(1);
}
}
}
}
},
},
};
</script>
Loading

0 comments on commit c56a322

Please sign in to comment.