2016-07-30 15:32:17 +00:00
|
|
|
|
<template>
|
2016-11-15 07:54:41 +00:00
|
|
|
|
<section id="youtubeWrapper">
|
2016-07-30 15:32:17 +00:00
|
|
|
|
<h1 class="heading"><span>YouTube Video</span></h1>
|
|
|
|
|
<div id="player">
|
|
|
|
|
<p class="none">Your YouTube video will be played here.<br/>
|
|
|
|
|
You can start a video playback from the right sidebar. When a song is playing, that is.<br>
|
|
|
|
|
It might also be worth noting that video’s volume, progress and such are controlled from within
|
|
|
|
|
the video itself, and not via Koel’s controls.</p>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2016-11-26 03:25:35 +00:00
|
|
|
|
import { event } from '../../../utils'
|
|
|
|
|
import { playback } from '../../../services'
|
|
|
|
|
import YouTubePlayer from 'youtube-player'
|
2016-07-30 15:32:17 +00:00
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
|
let player
|
2016-07-30 15:32:17 +00:00
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'main-wrapper--main-content--youtube-player',
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
/**
|
|
|
|
|
* Initialize the YouTube player. This should only be called once.
|
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
|
initPlayer () {
|
2016-07-30 15:32:17 +00:00
|
|
|
|
if (!player) {
|
|
|
|
|
player = YouTubePlayer('player', {
|
|
|
|
|
width: '100%',
|
2016-11-26 03:25:35 +00:00
|
|
|
|
height: '100%'
|
|
|
|
|
})
|
2016-07-30 15:32:17 +00:00
|
|
|
|
|
|
|
|
|
player.on('stateChange', event => {
|
|
|
|
|
// Pause song playback when video is played
|
2016-11-26 03:25:35 +00:00
|
|
|
|
event.data === 1 && playback.pause()
|
|
|
|
|
})
|
2016-07-30 15:32:17 +00:00
|
|
|
|
}
|
2016-11-26 03:25:35 +00:00
|
|
|
|
}
|
2016-07-30 15:32:17 +00:00
|
|
|
|
},
|
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
|
created () {
|
2016-07-30 15:32:17 +00:00
|
|
|
|
event.on({
|
|
|
|
|
'youtube:play': id => {
|
2016-11-26 03:25:35 +00:00
|
|
|
|
this.initPlayer()
|
|
|
|
|
player.loadVideoById(id)
|
|
|
|
|
player.playVideo()
|
2016-07-30 15:32:17 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stop video playback when a song is played/resumed.
|
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
|
'song:played': () => player && player.pauseVideo()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-30 15:32:17 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
|
<style lang="scss" scoped>
|
2016-07-30 15:32:17 +00:00
|
|
|
|
@import "../../../../sass/partials/_vars.scss";
|
|
|
|
|
@import "../../../../sass/partials/_mixins.scss";
|
|
|
|
|
|
|
|
|
|
.none {
|
|
|
|
|
color: $color2ndText;
|
|
|
|
|
padding: 16px 24px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|