Guide
Player Configuration

Player Configuration

💡

@oplayer/core does not provide any ui related functions such as thumbnail, subtitles, etc. If you need these functions please install @oplayer/ui

Player.make(/* container */ '#app', {
  /** Configuration **/
  /** Here's where to fill in the configuration **/
  muted: true
  // and more ...
}).create()

container

The DOM container attached to the player.

// DOM or CSS selector
type container = HTMLElement | string

options

export interface PlayerOptions {
  source?: {
    src: string
    poster?: string
    title?: string // for screenshot, controll bar
    format?:
      | 'auto'
      /** hls.js */
      | 'hls'
      | 'm3u8'
      /** dash.js */
      | 'dash'
      | 'mpd'
      /** mpegts.js */
      | 'flv'
      | 'm2ts'
      | 'mpegts'
      /** other */
      | string
  }
  autoplay?: boolean //https://developer.chrome.com/blog/autoplay/
  autopause?: boolean //Only allow one player playing at once.
  muted?: boolean
  loop?: boolean
  volume?: number
  playbackRate?: number
  playsinline?: boolean
  preload?: 'auto' | 'metadata' | 'none'
  lang?: Lang
  isLive?: boolean
  videoAttr?: Record<string, boolean | string>
  isNativeUI?: () => boolean
}

Methonds

class Player {
  on(
    name: PlayerEventName | PlayerListener,
    listener?: PlayerListener,
    options?: {
      once: boolean
    }
  ): this
  off(name: PlayerEventName, listener: PlayerListener): void
  emit(name: PlayerEventName, payload?: PlayerEvent['payload']): void
  setPoster(poster: string): void
  play(): Promise<void> | undefined
  pause(): void
  togglePlay(): void | Promise<void>
  mute(): void
  unmute(): void
  toggleMute(): void
  setVolume(volume: number): void
  setPlaybackRate(rate: number): void
  seek(time: number): void
  setLoop(loop: boolean): void
  enterFullscreen(): Promise<void>
  exitFullscreen(): Promise<void>
  get isFullscreenEnabled(): any
  get isFullScreen(): boolean
  toggleFullScreen(): Promise<void>
  get isPipEnabled(): boolean
  enterPip(): Promise<PictureInPictureWindow>
  exitPip(): false | Promise<void>
  get isInPip(): boolean
  togglePip(): false | Promise<void> | Promise<PictureInPictureWindow>
  changeQuality(source: Omit<Source, 'poster'> | Promise<Omit<Source, 'poster'>>): Promise<void>
  changeSource(source: Source | Promise<Source>, keepPlaying?: boolean): Promise<void>
  destroy(): void
  get isNativeUI(): boolean
  get state(): number
  get isPlaying(): boolean
  get isMuted(): boolean
  get isEnded(): boolean
  get isLoop(): boolean
  get isAutoPlay(): boolean
  get duration(): number
  get buffered(): TimeRanges
  get currentTime(): number
  get volume(): number
  get playbackRate(): number
  static get version(): string
}