feat: added Youtube Video component

This commit is contained in:
scmmishra 2019-03-28 13:07:48 +05:30
parent 9bfe3a0315
commit 526af9d268

View File

@ -0,0 +1,26 @@
<template>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item yvideo" :src="'https://www.youtube.com/embed/' + videoID + '?version=3&enablejsapi=1'" allowfullscreen></iframe>
</div>
</template>
<script type="text/javascript">
export default {
name: 'YoutubePlayer',
props: ['url', 'allowfullscreen'],
computed: {
videoID() {
if (!Array.prototype.last){
Array.prototype.last = function(){
return this[this.length - 1];
};
};
if (this.url.includes('v=')){
return this.url.split('v=')[1].split('&')[0]
}
else if (this.url.includes('youtu.be')) {
return this.url.split('/').last().split('?')[0]
}
}
}
};
</script>