mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
Merge pull request #283 from MajorBreakfast/patch-1
fix(useAudio): src change should reset isPlaying state
This commit is contained in:
commit
913e12e4eb
@ -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];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user