blob: 8d2e4f3f0cfeea007bf6bc999f15e51e8b3f9e0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<script lang="ts">
import type { Video } from '@jet-app/app-store/api/models';
import VideoPlayer from '../VideoPlayer.svelte';
import HlsJsDecorator from '../decorators/HlsJSDecorator.svelte';
import { buildPoster } from '~/utils/video-poster';
import { generateUuid } from '@amp/web-apps-utils/src';
import type { NamedProfile } from 'src/config/components/artwork';
import type { Profile } from '@amp/web-app-components/src/components/Artwork/types';
import mediaQueries from '~/utils/media-queries';
import { colorAsString } from '~/utils/color';
export let video: Video;
export let autoplay: boolean = false;
export let loop: boolean = false;
export let muted: boolean = true;
export let useControls: boolean = true;
export let profile: NamedProfile | Profile;
export let autoplayVisibilityThreshold: number = 0;
export let videoPlayerRef: InstanceType<typeof VideoPlayer> | null = null;
export let shouldSuperimposePosterImage: boolean = false;
$: poster =
video.preview && buildPoster(video.preview, profile, $mediaQueries);
$: backgroundColor = video.preview.backgroundColor
? colorAsString(video.preview.backgroundColor)
: '#f1f1f1';
$: metricsTemplate = video?.templateMediaEvent ?? {};
const uuid = generateUuid();
</script>
<HlsJsDecorator let:HLS>
<VideoPlayer
{HLS}
{loop}
{muted}
{autoplay}
{useControls}
{autoplayVisibilityThreshold}
{metricsTemplate}
{shouldSuperimposePosterImage}
id={uuid}
src={video.videoUrl}
poster={poster ?? undefined}
--aspect-ratio={video.preview.width / video.preview.height}
bind:this={videoPlayerRef}
/>
<div
class="loader"
slot="loading-component"
style:--aspect-ratio={video.preview.width / video.preview.height}
style:--background-image={`url(${poster})`}
style:--background-color={backgroundColor}
/>
</HlsJsDecorator>
<style>
.loader {
aspect-ratio: var(--aspect-ratio);
width: 100%;
background-image: var(--background-image);
background-color: var(--background-color);
background-size: cover;
}
</style>
|