import{_ as a,c as l,o as p,V as s,z as n}from"./chunks/framework.5c8808ab.js";const K=JSON.parse('{"title":"Advanced Properties","description":"","frontmatter":{},"headers":[],"relativePath":"en/advanced/built-in.md","filePath":"en/advanced/built-in.md","lastUpdated":1700976201000}'),o={name:"en/advanced/built-in.md"},e=s('

Advanced Properties ​

The advanced properties here refer to the secondary attributes mounted on the instance, which are less commonly used

option ​

Options for the player

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

console.info(art.option);

Reminder

If you directly modify this option object, the player will not respond immediately.

template ​

Manages all of the DOM elements of the player

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

console.info(art.template);
console.info(art.template.$video);

Warning

To easily distinguish between DOM elements and plain objects, all DOM elements in the player are named starting with a $

Here is the definition of all DOM elements: artplayer/types/template.d.ts

events ​

Manages all DOM events in the player, which is essentially a proxy for addEventListener and removeEventListener. When using the following methods to handle events, the event will also be automatically destroyed when the player is destroyed.

`,5),y=n("div",{className:"run-code"},"▶ Run Code",-1),F=s(`
js
var container = document.querySelector('.artplayer-app');

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

art.events.proxy(container, 'click', event => {
    console.info('click', event);
});

art.events.hover(container, (event) => {
    console.info('mouseenter', event);
}, (event) => {
    console.info('mouseleave', event);
});

art.events.loadImg('/assets/sample/poster.jpg').then(img => {
    console.info('loadImg', img);
});

Warning

If you need some DOM events to only exist during the lifecycle of the player, it is strongly recommended to use these functions to avoid causing memory leaks

storage ​

Manages the local storage of the player

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

art.storage.set('test', { foo: 'bar' });
const test = art.storage.get('test');
console.info(test);
art.storage.del('test');
art.storage.clear();

Warning

By default, all player instances share the same localStorage, and the default key is artplayer_settings

If you want different players to use different localStorage, you can modify art.storage.name accordingly

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

art.storage.name = 'your-storage-key';
art.storage.set('test', { foo: 'bar' });

icons ​

Manage all the svg icons of the player

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

console.info(art.icons.loading);

This is the definition of all icons:

artplayer/types/icons.d.ts

i18n ​

Manage the player's i18n

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

console.info(art.i18n.get('Play'));

art.i18n.update({
    'zh-cn': {
        Play: 'Your Play'
    }
});

WARNING

Using art.i18n.update can only update i18n after instantiation. If you want to update i18n before instantiation, please use the i18n from the basic options for the update.

notice ​

Manage the player's notices, there's only one show property used to display notices.

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

art.on('ready', () => {
    art.notice.show = 'Video Ready To Play';
})

WARNING

To immediately hide the display of notice: art.notice.show = '';

layers ​

Manage the layers of the player

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

art.on('ready', () => {
    art.layers.add({
        html: 'Some Text',
    });

	setTimeout(() => {
		art.layers.show = false;
	}, 1000);
});

Component configuration Please refer to the following address:

/component/layers.html

controls ​

Manage the player's controllers

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

art.on('ready', () => {
    art.controls.add({
        html: 'Some Text',
        position: 'left',
    });

	setTimeout(() => {
		art.controls.show = false;
	}, 1000);
});

Component Configuration Please refer to the following address:

/component/controls.html

contextmenu ​

Manage the right-click context menu of the player

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

art.on('ready', () => {
    art.contextmenu.add({
        html: 'Some Text',
    });

    art.contextmenu.show = true;
    setTimeout(() => {
        art.contextmenu.show = false;
    }, 1000);
});

Component Configuration Please refer to the following address:

/component/contextmenu.html

subtitle ​

Manage the subtitle features of the player

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

art.on('ready', () => {
    art.subtitle.url = '/assets/sample/subtitle.srt'
    art.subtitle.style({
        color: 'red',
    });
});

loading ​

Manage the loading layer of the player

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

art.on('ready', () => {
    art.loading.show = true;
	setTimeout(() => {
		art.loading.show = false;
	}, 1000);
});

hotkey ​

Manage the hotkey functionality of the player

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

function hotkeyEvent(event) {
    console.info('click', event);
}

art.on('ready', () => {
    art.hotkey.add(32, hotkeyEvent);
    setTimeout(() => {
		art.hotkey.remove(32, hotkeyEvent);
	}, 5000);
});

Warning

Shortcut keys will only work after the player has gained focus (e.g., after clicking on the player).

mask ​

Manage the player's mask layer

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

art.on('ready', () => {
    art.mask.show = false;
    setTimeout(() => {
        art.mask.show = true;
    }, 1000);
});

setting ​

Manage the player's settings panel

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

art.on('ready', () => {
    art.setting.show = true;
	setTimeout(() => {
		art.setting.show = false;
	}, 1000);
});

Settings Panel Please refer to the following link

/component/setting.html

plugins ​

Manage the player's plugin features, with only one method add to dynamically add plugins

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

function myPlugin(art) {
    console.info(art);
    return {
        name: 'myPlugin',
        something: 'something',
        doSomething: function () {
            console.info('doSomething');
        },
    };
}

art.on('ready', () => {
    art.plugins.add(myPlugin);
});
`,1),$=[e,t,r,c,D,y,F,i,A,C,d,u,m,b,h,_,g,v,T,E,f,k,w,P,S,I,N,R,V,x,j,q,M,O,W];function z(B,G,L,U,H,J){return p(),l("div",null,$)}const Q=a(o,[["render",z]]);export{K as __pageData,Q as default};