mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-05-18 15:26:36 +00:00
fix(video-embed): refactor URL generation and prevent Bilibili autoplay
This commit is contained in:
parent
95eed59c26
commit
e490f1bcea
@ -3,25 +3,19 @@ interface VideoEmbedProps {
|
||||
id: string;
|
||||
}
|
||||
|
||||
const platformSrcMap: Record<VideoEmbedProps["platform"], string> = {
|
||||
youtube: "https://www.youtube.com/embed/",
|
||||
bilibili: "https://player.bilibili.com/player.html?bvid=",
|
||||
};
|
||||
|
||||
export function VideoEmbed({
|
||||
platform,
|
||||
id,
|
||||
}: VideoEmbedProps) {
|
||||
const src = platformSrcMap[platform] + id;
|
||||
const platformSrcMap = {
|
||||
youtube: (id: string) => `https://www.youtube.com/embed/${id}`,
|
||||
bilibili: (id: string) =>
|
||||
`https://player.bilibili.com/player.html?bvid=${id}&autoplay=0`,
|
||||
} as const;
|
||||
|
||||
export function VideoEmbed({ platform, id }: VideoEmbedProps) {
|
||||
return (
|
||||
<div>
|
||||
<iframe
|
||||
className="aspect-video w-full"
|
||||
src={src}
|
||||
title={`${platform} Video Player`}
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"
|
||||
/>
|
||||
</div>
|
||||
<iframe
|
||||
className="aspect-video w-full"
|
||||
src={platformSrcMap[platform](id)}
|
||||
title={`${platform} Video Player`}
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user