├── AutoPlay.md ├── Manual.md ├── README.md ├── examples ├── angular │ ├── .editorconfig │ ├── .gitignore │ ├── README.md │ ├── angular.json │ ├── browserslist │ ├── e2e │ │ ├── protractor.conf.js │ │ ├── src │ │ │ ├── app.e2e-spec.ts │ │ │ └── app.po.ts │ │ └── tsconfig.json │ ├── karma.conf.js │ ├── package.json │ ├── src │ │ ├── App.css │ │ ├── App.ts │ │ ├── assets │ │ │ └── .gitkeep │ │ ├── components │ │ │ └── stream-info │ │ │ │ ├── index.html │ │ │ │ └── index.ts │ │ ├── config │ │ │ └── README.md │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── main.ts │ │ ├── pages │ │ │ └── room │ │ │ │ ├── index.css │ │ │ │ ├── index.html │ │ │ │ └── index.ts │ │ ├── polyfills.ts │ │ ├── styles.css │ │ └── test.ts │ ├── tsconfig.app.json │ ├── tsconfig.json │ ├── tsconfig.spec.json │ └── tslint.json ├── pureJS │ ├── .gitignore │ ├── README.md │ ├── css │ │ ├── index.css │ │ └── mediaPlayer.css │ ├── index.html │ ├── js │ │ ├── README.md │ │ └── index.js │ ├── lib │ │ └── index.js │ └── package.json ├── react-ts │ ├── .gitignore │ ├── README.md │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── src │ │ ├── App.css │ │ ├── App.test.tsx │ │ ├── App.tsx │ │ ├── config │ │ │ └── README.md │ │ ├── index.css │ │ ├── index.tsx │ │ ├── logo.svg │ │ ├── react-app-env.d.ts │ │ ├── serviceWorker.ts │ │ └── setupTests.ts │ └── tsconfig.json ├── react │ ├── .gitignore │ ├── README.md │ ├── config-overrides.js │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ └── src │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── components │ │ └── StreamInfo │ │ │ └── index.jsx │ │ ├── config │ │ └── README.md │ │ ├── index.js │ │ ├── logo.svg │ │ ├── pages │ │ └── room │ │ │ ├── index.css │ │ │ └── index.jsx │ │ └── setupTests.js └── vue │ ├── .browserslistrc │ ├── .editorconfig │ ├── .eslintignore │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── package.json │ ├── public │ ├── favicon.ico │ └── index.html │ └── src │ ├── App.vue │ ├── assets │ └── logo.png │ ├── components │ └── StreamInfo.vue │ ├── config │ └── README.md │ ├── main.js │ └── pages │ └── Room.vue ├── lib ├── index.d.ts └── index.js └── package.json /AutoPlay.md: -------------------------------------------------------------------------------- 1 | # 关于浏览器的自动播放问题的说明及处理 2 | 3 | --- 4 | 5 | ## 问题说明 6 | 7 | 出于用户体验考虑,为了防止网页在用户非自愿的情况下主动播放声音,浏览器对 audio 或 video 标签的自动播放(autoplay)功能做了限制:需要在用户交互操作之前不允许有声音的媒体播放。 8 | 9 | 10 | ## 具体表现 11 | 12 | 不同浏览器告警或报错信息不同,基本可以归纳为两类: 13 | 14 | 1. 调用 audio 或 video 的 play 方法时,会报类似于 `DOMException: play() failed because the user didn’t interact with the document first.` 的错误信息。 15 | 16 | 2. 开启 audio 或 video 的 autoplay 时,即标签上填有 'autoplay' 属性,如 `