2021-08-09 14:26:11 +02:00
|
|
|
<template>
|
|
|
|
<div class="youtube">
|
|
|
|
<div class="youtube-video" v-if="videoID">
|
|
|
|
<iframe
|
|
|
|
width="100%"
|
|
|
|
height="100%"
|
|
|
|
:src="`https://www.youtube.com/embed/${videoID}`"
|
|
|
|
title="YouTube video player"
|
|
|
|
frameborder="0"
|
|
|
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
|
|
allowfullscreen
|
|
|
|
></iframe>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
<script lang="ts" setup>
|
2021-08-09 14:26:11 +02:00
|
|
|
import { IEventMetadataDescription } from "@/types/event-metadata";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { computed } from "vue";
|
2021-08-09 14:26:11 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const props = defineProps<{ metadata: IEventMetadataDescription }>();
|
2021-08-09 14:26:11 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const videoID = computed((): string | null => {
|
|
|
|
if (props.metadata.pattern) {
|
|
|
|
const matches = props.metadata.pattern.exec(props.metadata.value);
|
|
|
|
if (matches && matches[1]) {
|
|
|
|
return matches[1];
|
2021-08-09 14:26:11 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
return null;
|
|
|
|
});
|
2021-08-09 14:26:11 +02:00
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.youtube {
|
|
|
|
.youtube-video {
|
|
|
|
padding-top: 56.25%;
|
|
|
|
position: relative;
|
|
|
|
height: 0;
|
|
|
|
|
|
|
|
iframe {
|
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
top: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|