西瓜播放器 HTML5 video video.js 播放器 HTML5播放器 mp4 hls hls.js flv flv.js dash dash.js 无缝切换

Known issues about Autoplay

Autoplay in mobile browsers

For most of mobile webview and browsers, autoplay with sound is prevented by default, even if config.autoplay is configured with the value of true. Listen to Events.AUTOPLAY_PREVENTED if you want to know when the autoplay was prevented

import Player, { Events } from 'xgplayer'
const player = new Player({
  ...,
  autoplay: true
})

player.on(Events.AUTOPLAY_PREVENTED, () => {
  console.log('autoplay was prevented!!')
})

Since autoplay with sound is generally prevented, another way to make media source start playing without is to set config.autoplayMuted to true for a muted playback

var player = new Player({
  ...,
  autoplayMuted: true,
  autoplay: true
})

There are serveral way for native app developers to customrize the webview for autoplay support

  • IOS

mediaplaybackrequiresuseraction

IOS10+ TypesRequiringUserActionForPlayback

Notice

For IOS devices in low power mode, autoplay are prevented in any case

  • Android

[setMediaPlaybackRequiresUserGesture](https://developer.android.com/reference/android/webkit/WebSettings#setMediaPlaybackRequiresUserGesture( Boolean))

Autoplay in PC browsers

  1. for PC playback, autoplayMuted is supported widely
var player = new Player({
  ...,
  autoplayMuted: true,
  autoplay: true
})
  1. For chrome users, visit chrome://media-engagement/ to see if current site is allowed for autoplay with sound

  2. For safari users, site could be Authorized for autoplay with sound by configurating permissions of the site

  3. Listen to Events.AUTOPLAY_PREVENTED if you want to know when the autoplay was prevented

import Player, { Events } from 'xgplayer'
const player = new Player({
  ...,
  autoplay: true
})

player.on(Events.AUTOPLAY_PREVENTED, () => {
  console.log('autoplay was prevented!!')
})