Video
Multi-platform video embedding plugin, supporting Bilibili, YouTube, AcFun, and ArtPlayer.
Installation
sh
pnpm add vitepress-plugin-videosh
npm install vitepress-plugin-videosh
bun add vitepress-plugin-videosh
deno add vitepress-plugin-videosh
yarn add vitepress-plugin-videoUsage
vitepress-tuck Mode Recommended
ts
import { defineConfig } from 'vitepress-tuck'
import video from 'vitepress-plugin-video'
export default defineConfig({
plugins: [
video({
// All optional, default to true
artplayer: true,
youtube: true,
bilibili: true,
acfun: true,
}),
],
})Learn more about vitepress-tuck
Native Mode
ts
import { defineConfig } from 'vitepress'
import { videoMarkdownPlugin } from 'vitepress-plugin-video'
export default defineConfig({
markdown: {
config: (md) => {
md.use(videoMarkdownPlugin, {
artplayer: true,
youtube: true,
bilibili: true,
acfun: true,
})
},
},
})ts
import type { Theme } from 'vitepress'
import { enhanceAppWithVideo } from 'vitepress-plugin-video/client'
import DefaultTheme from 'vitepress/theme'
export default {
extends: DefaultTheme,
enhanceApp(ctx) {
enhanceAppWithVideo(ctx)
},
} satisfies ThemeSyntax
Bilibili
Embed Bilibili videos:
md
@[bilibili](bvid)
@[bilibili](aid cid)
@[bilibili p2 autoplay time=30](bvid)| Option | Type | Description |
|---|---|---|
p{number} | - | Video part number |
autoplay | boolean | Auto play |
time | number | string | Start time, seconds or HH:MM:SS format |
YouTube
Embed YouTube videos:
md
@[youtube](video_id)
@[youtube autoplay loop start=10 end=120](video_id)| Option | Type | Description |
|---|---|---|
autoplay | boolean | Auto play |
loop | boolean | Loop playback |
start | number | Start time in seconds |
end | number | End time in seconds |
AcFun
Embed AcFun videos:
md
@[acfun](ac_id)ArtPlayer
Use ArtPlayer to embed local or remote videos:
md
@[artPlayer](/videos/demo.mp4)
@[artPlayer muted autoplay poster="/cover.jpg" width="800px"](/videos/demo.mp4)| Option | Type | Default | Description |
|---|---|---|---|
autoplay | boolean | false | Auto play |
muted | boolean | false | Muted |
loop | boolean | false | Loop playback |
volume | number | 0.75 | Volume level |
poster | string | - | Cover image URL |
autoMini | boolean | false | Auto mini mode |
width | string | "100%" | Player width |
height | string | - | Player height |
ratio | string | - | Aspect ratio, e.g. "16:9" |
Supports mp4, mp3, webm, ogg, mkv, mov formats.
If your video is in mpd or dash format, you'll also need to install dashjs:
sh
pnpm add dashjssh
npm i dashjssh
bun add dashjssh
deno add dashjssh
yarn add dashjsIf your video is in m3u8 or hls format, you'll also need to install hls.js:
sh
pnpm add hls.jssh
npm i hls.jssh
bun add hls.jssh
deno add hls.jssh
yarn add hls.jsIf your video is in ts or flv format, you'll also need to install mpegts.js:
sh
pnpm add mpegts.jssh
npm i mpegts.jssh
bun add mpegts.jssh
deno add mpegts.jssh
yarn add mpegts.jsConfiguration
ts
interface VideoPluginOptions {
/**
* Enable ArtPlayer
* @default true
*/
artplayer?: boolean
/**
* Enable YouTube video embedding
* @default true
*/
youtube?: boolean
/**
* Enable Bilibili video embedding
* @default true
*/
bilibili?: boolean
/**
* Enable AcFun video embedding
* @default true
*/
acfun?: boolean
}Examples
Bilibili
md
@[bilibili](BV1EZ42187Hg)YouTube
md
@[youtube](0JJPfz5dg20)AcFun
md
@[acfun](ac47431669)ArtPlayer
md
@[artPlayer](https://artplayer.org/assets/sample/video.mp4)