crp是什么检查项目| 能人是什么意思| 府尹相当于现在什么官| 剪切是什么意思| 冥币是什么意思| 三个火是什么字| 胃酸有什么办法缓解| 真丝用什么洗| 手机壳什么材质最好| 齐天大圣是什么意思| 农历八月初五是什么星座| me是什么基团| 蜈蚣最怕什么东西| 七年之痒什么意思| 什么是包皮过长图片| 发小是什么| 涅盘是什么意思| 女性湿气重喝什么茶| 怀孕什么时候开始孕吐| 胃炎是什么原因引起的| 大肠杆菌是什么病| 三岁宝宝喝什么奶粉比较好| 爱出汗吃什么药好| 月经不调是什么症状| 女人腰疼是什么原因引起的| 1980属什么| 扦插是什么意思| 扁平苔藓是什么原因引起的| 中暑吃什么食物好| 刮痧的痧是什么东西| 脸上长粉刺是什么原因引起的| 尿毒症的尿是什么颜色| 行代表什么生肖| 假酒喝了有什么症状| 阴虱有什么症状| 峻字五行属什么| 豆腐鱼是什么鱼| 鸡蛋壳薄是什么原因| 脖子变粗了是什么原因| 不负卿是什么意思| 手串断了是什么预兆| 心脏跳的快什么原因| 细菌感染吃什么药好| 苟富贵勿相忘什么意思| 精神小伙是什么意思| 改户口需要什么手续| 过敏性紫癜用什么药| 农历5月是什么星座| 脾胃不好吃什么调理| 死海为什么叫死海| 查胆囊挂什么科| 好学不倦什么意思| 棠字五行属什么| 七七是什么意思| 眼睛大小不一样是什么原因| 肝脏不好吃什么药| 长期服用优甲乐有什么副作用| 聚酯纤维是什么面料| mb是什么| 荆条是什么意思| 慢性胃炎吃什么药| 镜花水月什么意思| 黄瓜含有什么营养成分| 胃底腺息肉是什么意思| 长一根白眉毛预示什么| 有个性是什么意思| 轰趴是什么意思| 耳朵蝉鸣是什么原因引起的| 条条框框是什么意思| 轻奢是什么意思| 女生肾虚是什么原因| 茵芙莎属于什么档次| 金骏眉是什么茶类| 熟地是什么| 头皮结痂抠掉又结痂是什么病| 带状疱疹长什么样| 什么病不能吃核桃| 葡萄糖升高说明什么| 焦虑症吃什么中成药| 一月19日是什么星座| 弟弟是什么意思| 梦见血是什么预兆解梦| 相亲第一次见面送什么礼物好| 阴囊瘙痒是什么原因| b型血的孩子父母是什么血型| 感冒了可以吃什么水果| 胆囊炎有什么症状| 990金是什么金| 上午十点多是什么时辰| 动脉硬化吃什么| 芒果跟什么不能一起吃| 阿卡波糖什么时候吃| 破窗效应是什么意思| 56年属什么| 又热又冷是什么原因| 吃什么可以补血| 女性私处为什么会变黑| 工作是什么意思| 吃什么可以丰胸| 小狗的尾巴有什么作用| 间接胆红素偏高是什么原因| 7月1号是什么节日| 嗓子发炎是什么原因引起的| 经是什么意思| 去韩国需要办理什么手续| 原始鳞状上皮成熟是什么意思| 慢是什么意思| 杜冷丁是什么| 火可念什么| 为什么会水肿| 陈皮和橘子皮有什么区别| 脸上突然长痣是什么原因| 炖猪排骨放什么调料| gfr医学上是什么意思| 建档立卡是什么| 不现实什么意思| 分销是什么意思| 女人出虚汗失眠吃什么药| 做背有什么好处及作用| 血癌是什么原因造成的| yuri是什么意思| 吴京为什么看上谢楠| essence是什么意思| 江字五行属什么| 什么叫烟雾病| 白蛋白偏低是什么意思| 骨挫伤是什么意思| 人大常委会副主任是什么级别| 菠菜是什么意思| 双氧水又叫什么名字| 抗原体阳性是什么意思| 检查肺部挂什么科室| 深圳副市长什么级别| 做梦梦见下大雨是什么意思| 真丝和桑蚕丝有什么区别| 肾虚吃什么补最好| 农历今天属什么生肖| 身上有斑点是什么原因| pcr医学上是什么意思| 训练有素是什么意思| 马帮是什么意思| 左室高电压是什么意思| 拆骨肉是什么肉| 利而不害为而不争是什么意思| 不言而喻的喻是什么意思| yeezy是什么牌子| 蕨根粉是什么做的| 洋葱可以炒什么| 大雄宝殿是什么意思| 系统b超主要检查什么| 血液生化检查能看出什么病| chd是什么意思| 排骨烧什么好吃| 梦见煮鱼有什么预兆| 睡觉手麻是什么原因引起的女人| 佐助是什么意思| 面子里子什么意思| 手足口病用什么药| 得了性疾病有什么症状| 经常晕倒是什么原因引起的| 劈腿是什么意思| 天五行属性是什么| 什么也不懂| 英氏属于什么档次的| 打歌是什么意思| 鼻子突然出血是什么原因| 电压不稳定是什么原因| 脓毒症是什么病| 拔罐有什么作用和功效| 菊花有什么功效| 怀孕吃什么| inf是什么意思| 为什么过敏反复发作| 什么鸡蛋营养价值最高| 细思极恐是什么意思| 梦见自己买衣服是什么意思| 多囊不能吃什么食物| 2月11日什么星座| 外阴病变有什么症状| 婴儿泡奶粉用什么水好| 下呼吸道是指什么部位| 百香果有什么功效| 双肺局限性气肿是什么病| 藏红花能治什么病| 急性荨麻疹吃什么药| 不孕不育做什么检查| 百合花是什么颜色的| 用盐水洗脸有什么好处| 纳豆是什么豆子| 喝黑豆浆有什么好处| 阴阳两虚吃什么| 流黄鼻涕吃什么药| 眼袋大是什么原因引起的| 白带多要吃什么药| 孕妇不能吃什么东西| 橘子是什么季节的水果| 户口所在地是什么意思| 什么的勇气| 南昌有什么好玩的| 做梦梦见剪头发是什么意思| 曹植是什么生肖| dos是什么| 淋症是什么意思| ca724是什么意思| 什么病会传染| 撕脱性骨折什么意思| 胃病可以吃什么水果| 感冒喝什么水好得快| 胃不好的人吃什么养胃| 上腹部饱胀是什么原因| 饽饽是什么意思| 什么发型适合自己| 闪购是什么意思| 六月出生的是什么星座| 成人打虫吃什么药| 猫最喜欢吃什么| 腰间盘突出挂什么科室| 女性什么时候排卵| 清江鱼又叫什么鱼| 明矾和白矾有什么区别| 苏州有什么特产可以带回家| 当令是什么意思| 什么是强直性脊柱炎| 为什么突然就得肝炎了| 脚底肿是什么原因引起的| 12月13号是什么星座| 心脏彩超主要检查什么| 一级甲等医院是什么意思| 经常吃豆腐有什么好处和坏处| 减肥吃什么| jewelry什么意思| 男性尿道炎是什么原因引起的| 自杀吃什么药| 七月四日是什么星座| 孕酮低是什么原因| 跌跌撞撞什么意思| 1988是什么生肖| 治癜风擦什么药好的快| 宫颈肥大是什么意思| 慢性荨麻疹是什么症状| 什么提示你怀了女宝宝| 朝阳是什么意思| 婉甸女装属于什么档次| 海王星是什么颜色| 为什么失眠| 黑白猫是什么品种| 心服口服是什么意思| 孕妇子痫是什么病| 羊癫疯是什么引起的| sku图是什么意思| ad是什么缩写| 每天吃三颗红枣有什么好处| 7月20号是什么星座| 血管瘤有什么症状| 农历六月十九是什么星座| 平衡液是什么| 献殷勤是什么意思| ace是什么| 都有什么菜好吃| 白毫银针属于什么茶| 什么样的包皮需要做手术| 景字属于五行属什么| 结膜炎是什么病| 体寒吃什么| 百度

江苏昆山送“大礼包” 有效提振台企转型发展活力

Video.js Blog

Pat O'Neill2025-08-04

Autoplay Best Practices with Video.js

tl;dr

  • Never assume autoplay will work.
  • Using the muted attribute/option will improve the chances that autoplay will succeed.
  • Prefer programmatic autoplay via the player.play() method, avoiding the autoplay attribute/option.

Introduction

There has been a lot of chatter about autoplay lately and we wanted to take a few minutes to share some best practices when using autoplay with Video.js.

This post is meant to be a source of information - not an editorial or positional statement on autoplaying video. A lot of users hate autoplay because it's annoying or it consumes precious bandwidth. And a lot of publishers providing content free of charge rely on autoplay for the preroll ads that finance their businesses. Browser vendors (and open source library authors) have to weigh these concerns based on the interests of their users, publishers across the web, and their own business. And users have to choose the browser that best reflects their preferences.

This post is not about ways to circumvent autoplay policies. That's not possible and no one should waste their time attempting it. We think it's uncontroversial to say that actively circumventing the browser's built-in user experience or user preferences is harmful.

Autoplay Policies in the Big Browsers

I'm not going to go into exhaustive detail on each browser's specific algorithms because they are subject to change and it would defeat the core point of this post: never assume autoplay will work.

Safari

As of Safari 11, which shipped in September 2017, Apple has updated their autoplay policies to prevent autoplay with sound on most websites.

Chrome

Back in September 2017, Google announced that Chrome's autoplay policy would change in April 2018 with Chrome 66, subject to a series of rules you can read about in the linked article.

Firefox

With Firefox, Mozilla has taken the position of not having a firm autoplay policy for the time being. That may change in the future. That said, Firefox today does allow users to disable autoplay with a few configuration changes.

IE11 and Edge

Microsoft's browsers have no specific/known autoplay policy - at the time of writing, autoplay just works in IE11 and Edge.

Refresher on How to Request Autoplay in Video.js

Note how the title of this section uses the word "request." That's intentional because it should be thought of as a request. Remember, never assume autoplay will work.

One of Video.js' strengths is that it is designed around the native <video> element interface; so, it will defer to the underlying playback technology (in most cases, HTML5 video) and the browser. In other words, if the browser allows it, Video.js allows it.

There are two ways to enable autoplay when using Video.js:

  1. Use the autoplay attribute on either the <video> element or the new <video-js> element.

    <video autoplay src="http://path/to/source.mp4"></video>
    <video-js autoplay src="http://path/to/source.mp4"></video-js>
  2. Use the autoplay option:

    videojs('player', {autoplay: true});

By default, you can defer to the default behavior in Video.js. If autoplay succeeds, the Video.js player will begin playing. If autoplay fails, the Video.js player will behave as if autoplay were off - i.e. it will display the "big play button" component over the poster image (or a black box).

If that works for you, your job is done!

TIP: If you want to use autoplay and improve the chances of it working, use the muted attribute (or the muted option, with Video.js).

Beyond that, there are some general practices that may be useful when dealing with autoplay: detecting whether autoplay is supported at all, or detecting whether autoplay succeeds or fails.

Detecting Autoplay Support

Similar to detecting successful or failed autoplay requests, it may be useful to perform autoplay feature detection on the browser before creating a player at all. In these cases, the can-autoplay library is the best solution. It provides a similar Promise-based API to the native player.play() method:

canAutoplay.video().then(function(obj) {
  if (obj.result === true) {
    // Can autoplay
  } else {
    // Can not autoplay
  }
});

Programmatic Autoplay and Success/Failure Detection

For those who care whether or not an autoplay request was successful, both Google and Apple have recommended the same practice for detecting autoplay success or rejection: listen to the Promise returned by the player.play() method (in browsers that support it) to determine if autoplay was successful or not.

This can be coupled with the autoplay attribute/option or performed programmatically by calling player.play(), but we recommend avoiding the autoplay attribute/option altogether and requesting autoplay programmatically:

<video-js id="player" src="http://path/to/source.mp4"></video-js>
var player = videojs('player');

player.ready(function() {
  var promise = player.play();

  if (promise !== undefined) {
    promise.then(function() {
      // Autoplay started!
    }).catch(function(error) {
      // Autoplay was prevented.
    });
  }
});

NOTE: It's important to understand that using this approach, the Video.js player.autoplay() method will return undefined or false. If you expect your users or integrators to rely on this method, consider the following section.

Programmatic Autoplay with the autoplay Attribute/Option

When building a player for others to use, you may not always have control over whether your users include the autoplay attribute/option on their instance of your player. Thankfully, combining this with programmatic autoplay doesn't seem to have a significant effect on the behavior of playback.

Based on our experimentation, even if the browser handles the actual autoplay operation, calling player.play() after it's begun playing (or failed to play) does not seem to cause current browsers to trigger an extra "play" event in either Chrome or Firefox. It does seem that Safari 11.1 triggers "playing" and "pause" events each time player.play() is called and autoplay fails.

Still, if you have full control, we recommend avoiding the autoplay attribute/option altogether and requesting autoplay programmatically.

NOTE: Even if using the autoplay attribute/option with programmatic autoplay, the player.autoplay() method will return undefined until the player is ready.

Example Use-Case

At Brightcove, one thing we've done to improve the user experience of our Video.js-based player is to hide the "big play button" for players requesting autoplay until the autoplay either succeeds or fails. This prevents a periodic situation where the "big play button" flashes on the player for a moment before autoplay kicks in.

While our actual implementation has more complexity due to specific circumstances with our player, the gist of it is the same as this functional JSBin demonstration.

Conclusion

There may be decision points in your code related to whether autoplay succeeds or not; however, the practical reality is that all the paragraphs before this boil down to a single, essential concept:

Never assume that your request to autoplay will succeed.

Keep that in mind and you're golden. Even if the browsers stop allowing autoplay entirely, our hope is that recommending this approach will be somewhat future-proof.

险资举牌什么意思 什么是丹凤眼 结节有什么症状 贵人命是什么意思 cep是什么意思
人为什么会长白头发 asa是什么意思 血小板分布宽度是什么意思 一个家庭最重要的是什么 1935年属什么生肖属相
胃胀痛吃什么药 zro是什么牌子 绅士是什么意思 男性内分泌失调有什么症状 梳子什么材质的好
芬太尼是什么药 致什么意思 冬阴功是什么意思 念珠菌性阴道炎有什么症状 十一月四日是什么星座
什么时候测量血压最准确hcv8jop4ns5r.cn ip地址是什么意思hcv8jop3ns8r.cn 空心人是什么意思hcv9jop2ns6r.cn 胆红素偏高有什么危害hcv7jop5ns1r.cn 尿不尽是什么症状hcv8jop5ns8r.cn
颈椎病挂号挂什么科hcv8jop3ns5r.cn 竹肠是什么部位hcv7jop7ns0r.cn 参乌健脑胶囊适合什么人吃hcv8jop4ns0r.cn 毛囊炎吃什么药最有效hcv8jop0ns1r.cn 撤退性出血什么意思hcv8jop2ns4r.cn
佛系是什么意思啊hcv9jop7ns4r.cn 漏尿是什么原因造成的huizhijixie.com 糖耐什么时候做hcv8jop5ns2r.cn 三月初九是什么星座hcv9jop6ns8r.cn 四面楚歌是什么生肖hcv8jop5ns1r.cn
更年期一般在什么年龄hcv8jop8ns1r.cn 阴茎长水泡是什么原因hcv8jop7ns6r.cn 胃有灼热感是什么原因hcv9jop8ns1r.cn 6月7号是什么星座hcv8jop1ns5r.cn 5月10日是什么星座hcv9jop1ns0r.cn
百度