import{_ as n,c as l,o as p,V as s,z as a}from"./chunks/framework.5c8808ab.js";const ra=JSON.parse('{"title":"Basic Options","description":"","frontmatter":{},"headers":[],"relativePath":"en/start/option.md","filePath":"en/start/option.md","lastUpdated":1700976201000}'),e={name:"en/start/option.md"},o=s('

Basic Options ​

container ​

The DOM container where the player mounts

',4),t=a("div",{className:"run-code"},"▶ Run Code",-1),r=s(`
js
var art = new Artplayer({
    container: '.artplayer-app', 
    // container: document.querySelector('.artplayer-app'),
    url: '/assets/sample/video.mp4',
});

You may need to initialize the size of the container element, like:

css
.artplayer-app {
    width: 400px;
    height: 300px;
}

Or use aspect-ratio:

css
.artplayer-app {
    aspect-ratio: 16/9;
}

Tip

Among all options, only container is mandatory.

url ​

The video source address

`,9),c=a("div",{className:"run-code"},"▶ Run Code",-1),i=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
});

Sometimes the url is not known so quickly, in which case you can set the url asynchronously.

`,2),D=a("div",{className:"run-code"},"▶ Run Code",-1),y=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
});

setTimeout(() => {
    art.url = '/assets/sample/video.mp4';
}, 1000);

Note

The default support is for three video file formats: .mp4, .ogg, .webm.

If you need to play other formats such as .m3u8 or .flv, please refer to the Third-party Libraries on the left side.

id ​

The unique identifier of the player, currently used only for remembering playback with autoplayback

`,5),F=a("div",{className:"run-code"},"▶ Run Code",-1),C=s(`
js
var art = new Artplayer({
    id: 'your-url-id',
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
});

onReady ​

The constructor accepts a function as the second argument, which is triggered when the player is successfully initialized and the video is ready to play, similar to the ready event

`,4),A=a("div",{className:"run-code"},"▶ Run Code",-1),d=s(`
js
var art = new Artplayer(
    {
        container: '.artplayer-app',
        url: '/assets/sample/video.mp4',
        muted: true,
    },
    function onReady(art) {
        this.play()
    },
);

Equivalent to:

js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    muted: true,
});

art.on('ready', () => {
    art.play();
});

Warning

The this inside the callback function refers to the player instance, but if an arrow function is used for the callback, this will not point to the player instance.

poster ​

The poster of the video, which only appears when the player is initialized and before it starts playing.

`,7),h=a("div",{className:"run-code"},"▶ Run Code",-1),u=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    poster: '/assets/sample/poster.jpg',
});

theme ​

Player theme color, currently used for progress bar and highlight elements

`,4),b=a("div",{className:"run-code"},"▶ Run Code",-1),m=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    theme: '#ffad00',
});

volume ​

The default volume of the player

`,4),g=a("div",{className:"run-code"},"▶ Run Code",-1),_=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    volume: 0.5,
});

Warning

The player will cache the size of the last volume. When the player is initialized next time (such as refreshing the page), it will read this cached value.

isLive ​

Use live mode, which will hide the progress bar and playback time

`,5),v=a("div",{className:"run-code"},"▶ Run Code",-1),T=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    isLive: true,
});

muted ​

Whether to mute by default

`,4),f=a("div",{className:"run-code"},"▶ Run Code",-1),E=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    muted: true,
});

autoplay ​

Whether to play automatically

Autoplay

`,6),S=a("div",{className:"run-code"},"▶ Run Code",-1),w=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    autoplay: true,
    muted: true,
});

Warning

If you want the video to autoplay by default upon entering the page, muted must be set to true. For more information, please read Autoplay Policy Changes

autoSize ​

The size of the player will by default fill the entire container, which often results in black bars. This value can automatically adjust the player size to hide the black bars, similar to css's object-fit: cover;

`,5),k=a("div",{className:"run-code"},"▶ Run Code",-1),P=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    autoSize: true,
});

autoMini ​

Automatically enter mini mode when the player scrolls out of the browser viewport

`,4),R=a("div",{className:"run-code"},"▶ Run Code",-1),q=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    autoMini: true,
});

loop ​

Whether to loop the video

`,4),V=a("div",{className:"run-code"},"▶ Run Code",-1),I=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    loop: true,
});

flip ​

Whether to show the video flip feature, currently only available in Settings Panel and Context Menu

`,4),j=a("div",{className:"run-code"},"▶ Run Code",-1),N=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    flip: true,
    setting: true,
});

playbackRate ​

Whether to show the playback speed feature of the video, it will appear in Settings Panel and Context Menu

`,4),x=a("div",{className:"run-code"},"▶ Run Code",-1),B=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    playbackRate: true,
    setting: true,
});

aspectRatio ​

Displays the video aspect ratio feature, it will appear in the Settings Panel and Context Menu

`,4),W=a("div",{className:"run-code"},"▶ Run Code",-1),z=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    aspectRatio: true,
    setting: true,
});

screenshot ​

Whether to show the screenshot button, it will appear in the toolbar and context menu Display Screenshot function in the bottom control bar

`,4),O=a("div",{className:"run-code"},"▶ Run Code",-1),M=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    screenshot: true,
});

Warning

Due to browser security mechanisms, if the video source address and the website are cross-origin, screenshot failure may occur

setting ​

Display the toggle button for the Settings Panel in the bottom control bar

`,5),L=a("div",{className:"run-code"},"▶ Run Code",-1),H=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    setting: true,
});

hotkey ​

Whether to use hotkeys

`,4),U=a("div",{className:"run-code"},"▶ Run Code",-1),$=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    hotkey: true,
});
HotkeyDescription
↑Increase volume
↓Decrease volume
←Fast forward video
→Rewind video
spaceToggle play/pause

Tip

These hotkeys will only work after the player gains focus (such as after clicking on the player).

pip ​

`,5),Y=a("div",{className:"run-code"},"▶ Run Code",-1),Q=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    pip: true,
});

mutex ​

If there are multiple players on the page, should only one player be allowed to play at a time

`,4),J=a("div",{className:"run-code"},"▶ Run Code",-1),G=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    mutex: true,
});

fullscreen ​

`,3),K=a("div",{className:"run-code"},"▶ Run Code",-1),X=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    fullscreen: true,
});

fullscreenWeb ​

Display the Web Fullscreen button on the control bar at the bottom

`,4),Z=a("div",{className:"run-code"},"▶ Run Code",-1),ss=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    fullscreenWeb: true,
});

subtitleOffset ​

Subtitle time offset, the range is [-5s, 5s], appearing in the Settings panel

`,4),as=a("div",{className:"run-code"},"▶ Run Code",-1),ns=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    subtitleOffset: true,
    subtitle: {
        url: '/assets/sample/subtitle.srt',
    },
    setting: true,
});

miniProgressBar ​

Mini progress bar, only appears when the player loses focus and is playing

`,4),ls=a("div",{className:"run-code"},"▶ Run Code",-1),ps=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    miniProgressBar: true,
});

useSSR ​

Whether to use SSR (Server-Side Rendering) mount mode, useful if you want to pre-render the player's required HTML before the player mounts

You can access the player's required HTML through Artplayer.html

`,5),es=a("div",{className:"run-code"},"▶ Run Code",-1),os=s(`
js
var $container = document.querySelector('.artplayer-app');
$container.innerHTML = Artplayer.html;

var art = new Artplayer({
    container: $container,
    url: '/assets/sample/video.mp4',
    useSSR: true,
});

playsInline ​

Whether to use playsInline mode on mobile devices

`,4),ts=a("div",{className:"run-code"},"▶ Run Code",-1),rs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    playsInline: true,
});

layers ​

Initializes custom layers

`,4),cs=a("div",{className:"run-code"},"▶ Run Code",-1),is=s(`
js
var img = '/assets/sample/layer.png';
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    layers: [
        {
            name: 'poster',
            html: \`<img style="width: 100px" src="\${img}">\`,
            style: {
                position: 'absolute',
                top: '20px',
                right: '20px',
                opacity: '.9',
            },
            click: function (...args) {
                console.info('click', args);
                art.layers.show = false;
            },
            mounted: function (...args) {
                console.info('mounted', args);
            },
        },
    ],
});

Component Configuration Please refer to the following address:

/component/layers.html

settings ​

Initializes custom settings panel

`,5),Ds=a("div",{className:"run-code"},"▶ Run Code",-1),ys=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    setting: true,
    settings: [
        {
            html: 'setting01',
            selector: [
                {
                    html: 'setting01-01',
                },
                {
                    html: 'setting01-02',
                },
            ],
            onSelect: function (...args) {
                console.info(args);
            },
        },
        {
            html: 'setting02',
            selector: [
                {
                    html: 'setting02-01',
                },
                {
                    html: 'setting02-02',
                },
            ],
            onSelect: function (...args) {
                console.info(args);
            },
        },
    ],
});

Settings Panel Please refer to the following address

/component/setting.html

contextmenu ​

Initialize custom context menu

`,5),Fs=a("div",{className:"run-code"},"▶ Run Code",-1),Cs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    contextmenu: [
        {
            html: 'your-menu',
            click: function (...args) {
                console.info('click', args);
                art.contextmenu.show = false;
            },
        },
    ],
});

Component Configuration Please refer to the following address:

/component/contextmenu.html- Type:

controls ​

Initializes custom bottom control bar

`,5),As=a("div",{className:"run-code"},"▶ Run Code",-1),ds=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    controls: [
        {
            position: 'left',
            html: 'your-control',
            tooltip: 'Your Control',
            style: {
                color: 'green',
            },
            click: function (...args) {
                console.info('click', args);
            },
        },
    ],
});

Component Configuration Refer to the following address:

/component/controls.html

quality ​

Whether to show the quality selection list in the bottom control bar

PropertyTypeDescription
defaultBooleanDefault quality
htmlStringQuality name
urlStringQuality URL
`,6),hs=a("div",{className:"run-code"},"▶ Run Code",-1),us=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    quality: [
        {
            default: true,
            html: 'SD 480P',
            url: '/assets/sample/video.mp4',
        },
        {
            html: 'HD 720P',
            url: '/assets/sample/video.mp4',
        },
    ],
});

highlight ​

Show highlight information on the progress bar

PropertyTypeDescription
timeNumberHighlight time (in seconds)
textStringHighlight text
`,5),bs=a("div",{className:"run-code"},"▶ Run Code",-1),ms=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    highlight: [
        {
            time: 60,
            text: 'One more chance',
        },
        {
            time: 120,
            text: '谁でもいいはずなのに',
        },
        {
            time: 180,
            text: '夏の想い出がまわる',
        },
        {
            time: 240,
            text: 'こんなとこにあるはずもないのに',
        },
        {
            time: 300,
            text: '--终わり--',
        },
    ],
});

plugins ​

Initialize custom plugins

`,4),gs=a("div",{className:"run-code"},"▶ Run Code",-1),_s=s(`
js
function myPlugin(art) {
    console.info(art);
    return {
        name: 'myPlugin',
        something: 'something',
        doSomething: function () {
            console.info('doSomething');
        },
    };
}

var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    plugins: [myPlugin],
});

thumbnails ​

Set thumbnails on the progress bar

PropertyTypeDescription
urlStringThumbnail URL
numberNumberNumber of thumbnails
columnNumberColumns of thumbnails
widthNumberThumbnail width
heightNumberThumbnail height
`,5),vs=a("div",{className:"run-code"},"▶ Run Code",-1),Ts=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    thumbnails: {
        url: '/assets/sample/thumbnails.png',
        number: 60,
        column: 10,
    },
});

Online thumbnail generation

artplayer-tool-thumbnail

subtitle ​

Set the video subtitles, supporting subtitle formats: vtt, srt, ass

PropertyTypeDescription
nameStringSubtitle name
urlStringSubtitle URL
typeStringSubtitle type, options: vtt, srt, ass

| style | Object | Subtitle style | | encoding | String | Subtitle encoding, default utf-8 | | escape | Boolean | Whether to escape html tags, default true | | onVttLoad | Function | Function to modify vtt text |

`,7),fs=a("div",{className:"run-code"},"▶ Run Code",-1),Es=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    subtitle: {
        url: '/assets/sample/subtitle.srt',
        type: 'srt',
        encoding: 'utf-8',
        escape: true,
        style: {
            color: '#03A9F4',
            'font-size': '30px',
        },
    },
});

moreVideoAttr ​

Additional video attributes, these attributes will be directly written into the video element

`,4),Ss=a("div",{className:"run-code"},"▶ Run Code",-1),ws=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    moreVideoAttr: {
        'webkit-playsinline': true,
        playsInline: true,
    },
});

icons ​

Used to replace default icons, supports Html strings and HTMLElement

`,4),ks=a("div",{className:"run-code"},"▶ Run Code",-1),Ps=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    icons: {
        loading: '<img src="/assets/img/loading.gif">',
        state: '<img src="/assets/img/state.png">',
    },
});

Definition of all icons

artplayer/types/icons.d.ts

type ​

Used to specify the format of the video, which is used in conjunction with customType. By default, the video format is the same as the file extension of the video URL (such as .m3u8, .mkv, .ts). However, sometimes the video URL does not have the correct file extension, so it needs to be specifically stated.

`,5),Rs=a("div",{className:"run-code"},"▶ Run Code",-1),qs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.m3u8',
    type: 'm3u8',
});

Recognition of file extensions

The player can only parse this type of file extension: /assets/sample/video.m3u8

But it cannot parse this type of file extension: /assets/sample/video?type=m3u8

Therefore, if you use customType, it is best to specify type as well

customType ​

Matches the video's type to delegate the video decoding to a third-party program for processing. The processing function can receive three parameters:

`,6),Vs=a("div",{className:"run-code"},"▶ Run Code",-1),Is=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.m3u8',
    customType: {
        m3u8: function (video, url, art) {
            //
        },
    },
});

lang ​

Default display language, currently supports: en, zh-cn

`,4),js=a("div",{className:"run-code"},"▶ Run Code",-1),Ns=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    lang: 'en',
});

More language settings

/start/i18n.html

i18n ​

Custom i18n configuration, which will be deeply merged with the built-in i18n

Add your language:

`,6),xs=a("div",{className:"run-code"},"▶ Run Code",-1),Bs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    lang: 'your-lang',
    i18n: {
        'your-lang': {
            Play: 'Your Play'
        },
    },
});

Modifying the existing language

`,2),Ws=a("div",{className:"run-code"},"▶ Run Code",-1),zs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    i18n: {
        'zh-cn': {
            Play: 'Your Play'
        },
        'zh-tw': {
            Play: 'Your Play'
        },
    },
});

More language settings

/start/i18n.html

lock ​

Whether to display a lock button on mobile to hide the bottom control bar

`,5),Os=a("div",{className:"run-code"},"▶ Run Code",-1),Ms=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    lock: true,
});

fastForward ​

Whether to add fast forward function by long pressing on the video on mobile devices

`,4),Ls=a("div",{className:"run-code"},"▶ Run Code",-1),Hs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    fastForward: true,
});

autoPlayback ​

Whether to use the automatic playback feature

`,4),Us=a("div",{className:"run-code"},"▶ Run Code",-1),$s=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    id: 'your-url-id',
    autoPlayback: true,
});

Warning

Because the player by default uses url as the key to cache the playback progress

But if the url of the same video is different, then you need to use id to identify the unique key of the video

autoOrientation ​

Whether to rotate the player on mobile web pages in full screen according to the video size and the viewport dimensions

`,5),Ys=a("div",{className:"run-code"},"▶ Run Code",-1),Qs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    autoOrientation: true,
});

airplay ​

Whether to display the airplay button, currently only some browsers support this feature

`,4),Js=a("div",{className:"run-code"},"▶ Run Code",-1),Gs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    airplay: true,
});

cssVar ​

Used to change built-in CSS variables

`,4),Ks=a("div",{className:"run-code"},"▶ Run Code",-1),Xs=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    cssVar: {
        //
    },
});

Reference for cssVar syntax

artplayer/types/cssVar.d.ts

`,2),Zs=[o,t,r,c,i,D,y,F,C,A,d,h,u,b,m,g,_,v,T,f,E,S,w,k,P,R,q,V,I,j,N,x,B,W,z,O,M,L,H,U,$,Y,Q,J,G,K,X,Z,ss,as,ns,ls,ps,es,os,ts,rs,cs,is,Ds,ys,Fs,Cs,As,ds,hs,us,bs,ms,gs,_s,vs,Ts,fs,Es,Ss,ws,ks,Ps,Rs,qs,Vs,Is,js,Ns,xs,Bs,Ws,zs,Os,Ms,Ls,Hs,Us,$s,Ys,Qs,Js,Gs,Ks,Xs];function sa(aa,na,la,pa,ea,oa){return p(),l("div",null,Zs)}const ca=n(e,[["render",sa]]);export{ra as __pageData,ca as default};