Skip to content

Commit

Permalink
fix(useAudio): src change should reset isPlaying state
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorBreakfast committed May 1, 2019
1 parent cbd7be1 commit 65bffca
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/util/createHTMLMediaHook.ts
Expand Up @@ -205,15 +205,16 @@ const createHTMLMediaHook = (tag: 'audio' | 'video') => {
return;
}

// Start media, if autoPlay requested.
if (props.autoPlay && el.paused) {
controls.play();
}

setState({
volume: el.volume,
muted: el.muted,
isPlaying: !el.paused,
});

// Start media, if autoPlay requested.
if (props.autoPlay && el.paused) {
controls.play();
}
}, [props.src]);

return [element, state, controls, ref];
Expand Down

0 comments on commit 65bffca

Please sign in to comment.