Attribute
The NPlayer attribute is divided into instance properties and static properties.
#
Instance PropertiesYou can access these properties by player
instance objects.
container: HTMLElement
#
Player container element (container
parameter or mount()
parameter).
el: HTMLElement
#
Player DOM element.
opts: PlayerOptions
#
Player parameters.
mounted: boolean
#
Whether the player is mounted.
video: HTMLVideoElement
#
Player video element.
rect: Rect
#
Player size.
rect.width
player widthrect.height
player heightrect.x
playerx
rect.y
playery
rect.update()
update player size
一般情况不要调用 player.rect.update()
方法,而是触发 UpdateSize
事件, player.emit('UpdateSize')
。
loading: Loading
#
Player loading object.
loading.el
loading DOM elementsloading.isActive
is currently visibleloading.show()
show loadingloading.hide()
hide loading
poster: Poster
#
Player poster.
poster.el
poster DOM elementposter.isActive
is currently visibleposter.show()
show posterposter.hide()
hide poster
toast: Toast
#
Player toast.
show(html: string, position?: Position, timeout = 3000): ToastItem
显示一个提示,返回提示对象
close(toastItem?: ToastItem): void
手动关闭一个提示,或者全部提示
fullscreen: Fullscreen
#
Player Fullscreen Object
isActive
当前是否是全屏状态enableDblclick()
启用双击进入全屏disableDblclick()
禁用双击进入全屏enter()
进入全屏exit()
退出全屏toggle()
进入或退出全屏
webFullscreen: WebFullscreen
#
播放器网页全屏对象。
isActive
当前是否是全屏状态enter()
进入全屏exit()
退出全屏toggle()
进入或退出全屏
shortcut: Shortcut
#
播放器快捷键对象。
register(keyCode: number, handler: (player: Player) => void)
注册自定义快捷键处理器unregister(keyCode: number)
取消注册enable()
启用快捷键disable()
禁用快捷键
control: Control
#
播放器进度条对象。
currentBp
当前断点值isActive
当前是否显示控制条show()
显示控制条hide()
隐藏控制条showTransient()
显示控制条,但是到一定时间会尝试自动隐藏tryHide()
尝试隐藏控制条,比如当前视频暂停状态,调用该方法就不会隐藏require()
添加一个控制条显示请求,tryHide
会判断是否有请求,如果则也不会隐藏release()
释放一个请求,如果调用require
,没有调用该方法,则可能导致控制条不会自动隐藏。updateItems()
更新控制条项,同player.updateControlItems()
contextmenu: ContextMenu
#
播放器右键菜单。
isActive
当前是否显示hide()
隐藏右键菜单
touch: Touch
#
触屏交互,如果 isTouch
参数是 true
时会启用。请查看播放器参数。
enable()
启用触屏交互disable()
禁用触屏交互
currentTime: number
[get/set]#
获取和设置当前视频时间。[get/set]
表示该属性可以同时被获取和设置新的值。
duration: number
[get]#
获取当前视频长度。
buffered: TimeRanges
[get]#
通 video 元素的 buffered。
volume: number
[get/set]#
获取和设置视频音量,音量会被持久化。
muted: boolean
[get/set]#
获取和设置视频是否静音。
playbackRate: number
[get/set]#
获取和设置视频播放速率。
ended: boolean
[get]#
当前视频是否播放结束。
paused: boolean
[get]#
当前视频是否暂停。
playing: boolean
[get]#
当前视频是否在播放中。
loop: boolean
[get/set]#
获取和设置视频是否循环播放。
#
PlayerPlayer class.
#
EVENTEvent object.For more information, see events
#
Static Properties#
EVENTEvent object.For more information, see events
#
I18nInternationalize object.
t(key: string, lang?: string)
: string to return translation textadd(lang: string, transData: Record<string, string>)
add translationsetCurrentLang(lang?: string)
set current languagesetDefaultLang(lang?: string)
set default language
如果当前是中文环境时会返回 网页全屏
。The other language environment returns the key
string directly.
#
IconIcon object.For more information, see custom themes
#
componentsBuilt-in components.For more information see the built-in component.
#
PlayerPlayer class.