Video.js Options Reference

本文档详细介绍了Video.js播放器的选项,包括标准元素选项、Video.js特定选项、组件选项和技术选项。涵盖如autoplay、controls、height、width等属性,以及fluid模式、响应式布局、语言设置、自定义插件初始化等高级功能。此外,还涉及到各技术选项,如Flash技术的SWF文件位置和强制使用原生控制等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Video.js Options Reference

Standard <video> Element Options

Each of these options is also available as a standard <video> element attribute; so, they can be defined in all three manners outlined in the setup guide. Typically, defaults are not listed as this is left to browser vendors.

autoplay

Type: boolean|string NOTE: At this point, the autoplay attribute and option are NOT a guarantee that your video will autoplay. NOTE2: If there is an attribute on the media element the option will be ignored. NOTE3: You cannot pass a string value in the attribute, you must pass it in the videojs options

Instead of using the autoplay attribute you should pass an autoplay option to the videojs function. The following values are valid:

  • a boolean value of false: the same as having no attribute on the video element, won't autoplay
  • a boolean value of true: the same as having attribute on the video element, will use browsers autoplay
  • a string value of 'muted': will mute the video element and then manually call play() on loadstart. This is likely to work.
  • a string value of 'play': will call play() on loadstart, similar to browsers autoplay
  • a string value of 'any': will call play() on loadstart and if the promise is rejected it will mute the video element then call play().

To pass the option

var player = videojs('my-video', {
  autoplay: 'muted'
});

// or

player.autoplay('muted');

More info on autoplay support and changes:

controls

Type: boolean

Determines whether or not the player has controls that the user can interact with. Without controls the only way to start the video playing is with the autoplay attribute or through the Player API.

height

Type: string|number

Sets the display height of the video player in pixels.

loop

Type: boolean

Causes the video to start over as soon as it ends.

muted

Type: boolean

Will silence any audio by default.

poster

Type: string

A URL to an image that displays before the video begins playing. This is often a frame of the video or a custom title screen. As soon as the user hits "play" the image will go away.

preload

Type: string

Suggests to the browser whether or not the video data should begin downloading as soon as the <video> element is loaded. Supported values are:

'auto'

Start loading the video immediately (if the browser supports it). Some mobile devices will not preload the video in order to protect their users' bandwidth/data usage. This is why the value is called 'auto' and not something more conclusive like 'true'.

This tends to be the most common and recommended value as it allows the browser to choose the best behavior.

'metadata'

Load only the meta data of the video, which includes information like the duration and dimensions of the video. Sometimes, the meta data will be loaded by downloading a few frames of video.

'none'

Don't preload any data. The browser will wait until the user hits "play" to begin downloading.

src

Type: string

The source URL to a video source to embed.

width

Type: string|number

Sets the display width of the video player in pixels.

Video.js-specific Options

<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值