@mundogamernetwork/shared-ui 1.11.2 → 1.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,6 +4,7 @@ interface Video {
|
|
|
4
4
|
title: string;
|
|
5
5
|
url: string;
|
|
6
6
|
type?: string;
|
|
7
|
+
thumbnail_url?: string;
|
|
7
8
|
is_primary?: boolean;
|
|
8
9
|
sort_order?: number;
|
|
9
10
|
}
|
|
@@ -14,21 +15,27 @@ interface Props {
|
|
|
14
15
|
|
|
15
16
|
const props = defineProps<Props>();
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
// Initialize synchronously so direct public-page loads also have a player
|
|
19
|
+
// during SSR, instead of waiting for client hydration.
|
|
20
|
+
const selectedVideoId = ref<number | null>(
|
|
21
|
+
(props.videos.find(v => v.is_primary) || props.videos[0])?.id ?? null,
|
|
22
|
+
);
|
|
23
|
+
const activeVideo = computed(() =>
|
|
24
|
+
props.videos.find(v => v.id === selectedVideoId.value) || props.videos[0] || null,
|
|
25
|
+
);
|
|
23
26
|
|
|
24
27
|
function getEmbedUrl(url: string) {
|
|
25
|
-
const ytMatch = url.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]
|
|
28
|
+
const ytMatch = url.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/);
|
|
26
29
|
if (ytMatch) return `https://www.youtube.com/embed/${ytMatch[1]}`;
|
|
27
30
|
const vimeoMatch = url.match(/vimeo\.com\/(\d+)/);
|
|
28
31
|
if (vimeoMatch) return `https://player.vimeo.com/video/${vimeoMatch[1]}`;
|
|
29
32
|
return url;
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
function isDirectVideo(url: string) {
|
|
36
|
+
return /\.(mp4|webm|ogg)(?:[?#].*)?$/i.test(url);
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
function formatType(type?: string) {
|
|
33
40
|
if (!type) return '';
|
|
34
41
|
return type.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
|
|
@@ -40,7 +47,9 @@ function formatType(type?: string) {
|
|
|
40
47
|
<h3 class="section-title">{{ $t('press_kit.videos') }}</h3>
|
|
41
48
|
|
|
42
49
|
<div v-if="activeVideo" class="video-embed">
|
|
50
|
+
<video v-if="isDirectVideo(activeVideo.url)" :src="activeVideo.url" :poster="activeVideo.thumbnail_url || undefined" controls preload="metadata" />
|
|
43
51
|
<iframe
|
|
52
|
+
v-else
|
|
44
53
|
:src="getEmbedUrl(activeVideo.url)"
|
|
45
54
|
frameborder="0"
|
|
46
55
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
@@ -53,7 +62,7 @@ function formatType(type?: string) {
|
|
|
53
62
|
v-for="video in videos"
|
|
54
63
|
:key="video.id"
|
|
55
64
|
:class="['video-item', { active: activeVideo?.id === video.id }]"
|
|
56
|
-
@click="
|
|
65
|
+
@click="selectedVideoId = video.id"
|
|
57
66
|
>
|
|
58
67
|
<MGIcon icon="videos" />
|
|
59
68
|
<div class="video-meta">
|
|
@@ -86,6 +95,12 @@ function formatType(type?: string) {
|
|
|
86
95
|
width: 100%;
|
|
87
96
|
height: 100%;
|
|
88
97
|
}
|
|
98
|
+
|
|
99
|
+
video {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 100%;
|
|
102
|
+
object-fit: contain;
|
|
103
|
+
}
|
|
89
104
|
}
|
|
90
105
|
|
|
91
106
|
.video-list {
|