react-media-player icon indicating copy to clipboard operation
react-media-player copied to clipboard

Support Rendering with Audio Context Suspended

Open epihel opened this issue 6 years ago • 0 comments

As of version M71 (December 2018), Chrome has disabled autoplaying sound and video (https://goo.gl/7K7WLu). This line:

import { controls, Media, Player } from 'react-media-player';

will trigger the warning The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.

This line in render:

<Player useAudioObject />

will throw the Error:

TypeError: Cannot set property 'oncanplay' of undefined
    at HTML5.js:229
    at Array.forEach (<anonymous>)
    at ProxyComponent._bindAudioObjectEvents (HTML5.js:228)
    at ProxyComponent._bindAudioObjectEvents (react-hot-loader.development.js:693)
    at ProxyComponent.componentDidUpdate (HTML5.js:132)
    at ProxyComponent.componentDidUpdate (react-hot-loader.development.js:683)
    at commitLifeCycles (react-dom.development.js:16242)
    at commitAllLifeCycles (react-dom.development.js:17592)
    at HTMLUnknownElement.callCallback (react-dom.development.js:149)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:199)

Note that removing useAudioObject, as in:

<Player />

will not throw the Error.

epihel avatar Jan 26 '19 01:01 epihel