Skip to content

Parameters

Parameters passed to the player constructor can be provided during player initialization:

js
import Player from 'qier-player'

const player = new Player({
  src: '/test-video_1080p.mp4',
})

console.log('player parameters', player.options)

player.mount(document.body)

Parameter Descriptions

Parameter NameDescriptionType
containerThe container element where the player is mounted, the same as the parameter passed to the mount method. If no parameter is provided to mount, this will be used. When this parameter is a string, it will automatically find the corresponding element.string | HTMLElement
videoThe video tag element provided by the user.HTMLVideoElement
srcThe video URL, passed to the src attribute of the video tag element.string
themeColorThe theme color that will affect the visual theme of the entire player.string
videoPropsProperties for the video tag element.Record<string, any>
posterOptionsConfiguration related to the poster, see IPosterOptions for details.IPosterOptions
loadingOptionsConfiguration related to the loading indicator, see ILoadingOptions for details.ILoadingOptions
controllerConfiguration related to the controller, see IController for details.IController
progressOptionsConfiguration related to the progress bar, see IProgressOptions for details.IProgressOptions
thumbnailConfiguration related to thumbnails, see IThumbnail for details.IThumbnail
settingsConfiguration related to the settings menu, see ISettingItem for details.(ISettingItem | string)[]
menusConfiguration related to the right-click menu, see IMenuItem for details.(IMenuItem | string)[]
showDefaultMenuDetermines whether to show the native right-click menu. When set to true, the browser's native right-click menu will be shown on the second click instead of the custom player right-click menu. When set to false, the browser's right-click menu will never be displayed.boolean
shortcutOptionsConfiguration related to keyboard shortcuts, see IShortcut for details.IShortcut

IPosterOptions

Parameter NameDescriptionType
disabledWhether to disable the poster.boolean
urlThe URL of the poster image.string
autoFillWhether the poster image automatically fills the entire video container.boolean
bgColorThe background color for the poster image. This is necessary if your image has transparency.string

ILoadingOptions

Parameter NameDescriptionType
disabledWhether to disable the loading indicator.boolean
spinnerCustom indicator.HTMLElement
typeBuilt-in indicator animations, two animations to choose from.wave | circle

IController

Parameter NameDescriptionType
progressProgress bar configuration.`(IControllerEle
elesControl bar configuration.`(IControllerEle
ts
interface IControllerEle {
  el: HTMLElement;
  id?: any;
  tip?: string;
  tooltip?: Tooltip;
  mounted?: boolean;
  init?: (player: Player, tooltip: Tooltip) => void;
  dispose?: () => void;
  [key: string]: any;
}

IProgressOptions

Parameter NameDescriptionType
dotElement to represent the end of the progress bar; can be a custom elementHTMLElement
playedBgColor of the already played portion of the progress barstring
buffBgColor of the buffered portion of the progress barstring
indicatorWhether to show an indicator on the progress barboolean

IThumbnail

Parameter NameDescriptionType
startSecondStart time for the thumbnailnumber
gapSecondInterval time for thumbnail generationnumber
rowNumber of rows in the sprite sheetnumber
colNumber of columns in the sprite sheetnumber
widthWidth of the thumbnailnumber
heightHeight of the thumbnailnumber
imagesArray of sprite sheet linksstring[]

ISettingItem

ts
interface ISettingItem<T = any> {
  id?: any;
  html?: string;
  type?: 'switch' | 'select';
  checked?: boolean;
  options?: ISettingItemOption<T>[];
  value?: T;
  init?: (player: Player, item: ISettingItem) => void;
  change?: (value: T, player: Player, item: ISettingItem) => void;
  _switch?: Switch;
  _selectedEl?: HTMLElement;
  _optionEls?: HTMLElement[];
  _optionEl?: HTMLElement;
  [key: string]: any;
}
ts
interface ISettingItemOption<T = any> {
  html?: string;
  selectedText?: string;
  value?: T;
}

For detailed usage, refer to Custom Setting Menu Items.

IMenuItem

ts
interface IMenuItem {
  id?: string;
  html?: string;
  hidden?: boolean;
  disabled?: boolean;
  checked?: boolean;
  init?: (player: Player, item: IMenuItem) => void;
  show?: (player: Player, item: IMenuItem) => void;
  click?: (player: Player, item: IMenuItem) => void;
}

For detailed usage, refer to Context Menu.

IShortcut

Parameter NameDescriptionType
disabledWhether the shortcut is disabledboolean
seekStepStep length for fast forward or rewind when using shortcuts, e.g., 5 secondsnumber
volumeStepStep size for increasing or decreasing volume with shortcuts, e.g., 0.1number
showToastWhether to display a toast notification indicating the current actionboolean
toastDelayDuration for which the toast notification is displayednumber

Default Values

ts
const defaultOptions = {
  posterOptions: {
    disabled: true,
    autoFill: true,
  },
  loadingOptions: {
    disabled: false,
    type: 'circle',
  },
  controller: {
    progress: ['progress'],
    eles: ['play', 'time', 'spacer', 'volume', 'settings', 'web-fullscreen', 'fullscreen'],
  },
  settings: ['mirroring', 'speed'],
  menus: ['loop'],
  showDefaultMenu: true,
  videoProps: {
    crossorigin: 'anonymous',
    preload: 'auto',
    playsinline: 'true',
  },
  progressOptions: {
    indicator: true,
  },
  shortcutOptions: {
    disabled: false,
    seekStep: 5,
    volumeStep: 0.1,
    showToast: true,
    toastDelay: 500,
  },
}

Released under the MIT License.