Skip to content
This repository was archived by the owner on May 2, 2026. It is now read-only.

Commit 79ab96f

Browse files
committed
refactor: change load
1 parent 16d8f0d commit 79ab96f

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/components/client/client.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,26 @@
4141
</div>
4242
</div>
4343

44-
<script>
44+
<script type="module">
45+
import { VidstackPlayer, VidstackPlayerLayout } from '/client/vidstack.js';
46+
4547
function generateImg(src, displayFull) {
4648
return '<img id="message-img" ' + (displayFull ? 'class="aspect-auto w-full h-full max-w-[100vw] max-h-[100vh]"' : '') + ' src="' + src + '" />';
4749
}
4850

4951
function generateAudioVideo(src, displayFull, mediaIsShort) {
50-
return '<media-player id="message-player" ' + (displayFull ? "class='h-[100vh] " + (mediaIsShort ? "is-short mx-auto" : "aspect-contain w-[100vw] ") + "'" : "class='aspect-contain " + (mediaIsShort ? "is-short" : "") + "'") + ' src="' + src + '" autoPlay load="eager" logLevel="debug">' +
51-
'<media-provider></media-provider>' +
52-
'<media-audio-layout></media-audio-layout>' +
53-
'<media-video-layout></media-video-layout>' +
54-
'</media-player>';
52+
setTimeout(() => {
53+
54+
const player = VidstackPlayer.create({
55+
target: '#message-player',
56+
src: src,
57+
layout: new VidstackPlayerLayout({
58+
}),
59+
});
60+
}, 100);
61+
62+
return '<div id="message-player" data-autoplay data-load="eager" ' + (displayFull ? "class='h-[100vh] " + (mediaIsShort ? "is-short mx-auto" : "aspect-contain w-[100vw] ") + "'" : "class='aspect-contain " + (mediaIsShort ? "is-short" : "") + "'") + ' >' +
63+
'</div>';
5564
}
5665

5766
function displayAuthor(authorUsername, authorPictureURL) {

0 commit comments

Comments
 (0)