mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 23:33:21 -08:00
2.2 KiB
2.2 KiB
title, sidebar_position, slug
| title | sidebar_position | slug |
|---|---|---|
| 实例属性 | 3 | /zh-cn/propertie |
play
- 类型:
Function
播放视频
▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
muted: true,
});
art.on('ready', () => {
art.play();
})
pause
- 类型:
Function
暂停视频
▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
muted: true,
});
art.on('ready', () => {
art.play();
setTimeout(() => {
art.pause();
}, 3000);
})
toggle
- 类型:
Function
切换视频的播放和暂停
▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
muted: true,
});
art.on('ready', () => {
art.toggle();
setTimeout(() => {
art.toggle();
}, 3000);
})
seek
- 类型:
Setter
视频时间跳转,单位秒
▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
});
art.on('ready', () => {
art.seek = 5;
})
forward
- 类型:
Setter
视频时间快进,单位秒
▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
});
art.on('ready', () => {
art.forward = 5;
})
backward
- 类型:
Setter
视频时间快退,单位秒
▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
});
art.on('ready', () => {
art.seek = 5;
setTimeout(() => {
art.backward = 2;
}, 3000);
})
volume
- 类型:
Setter/Getter
设置和获取视频音量,范围在:[0, 1]
▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
});
art.on('ready', () => {
art.volume = 0.5;
console.log(art.volume);
})