Merge pull request #283 from MajorBreakfast/patch-1

fix(useAudio): src change should reset isPlaying state
This commit is contained in:
Va Da 2019-05-24 20:49:59 +02:00 committed by GitHub
commit 913e12e4eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,15 +205,16 @@ const createHTMLMediaHook = (tag: 'audio' | 'video') => {
return;
}
setState({
volume: el.volume,
muted: el.muted,
isPlaying: !el.paused,
});
// Start media, if autoPlay requested.
if (props.autoPlay && el.paused) {
controls.play();
}
setState({
volume: el.volume,
muted: el.muted,
});
}, [props.src]);
return [element, state, controls, ref];