-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toggleHowler: don't seek if no props.seek specified #57
toggleHowler: don't seek if no props.seek specified #57
Conversation
Hi @svlapin, good catch! I want to run a few tests on this then I’ll merge and publish an update. Should be in the next 24h or so. |
Great, @Stenerson, thanks ! And I've just realized - probably that's better to if (typeof props.seek !== 'undefined' && props.seek !== this.seek()) { to handle |
@thangngoc89, the following diff applied to diff --git a/examples/react/src/App.js b/examples/react/src/App.js
index a9c6ff3..695d743 100644
--- a/examples/react/src/App.js
+++ b/examples/react/src/App.js
@@ -3,6 +3,11 @@ import SourceLink from './components/SourceLink'
import { OnlyPlayPauseButton, NoPreload, SwapSource, AutoPlay, FullControl } from './players'
class App extends React.Component {
+ componentDidMount() {
+ // Make children receive props so #toggleHowler is called
+ this.setState({});
+ }
+
render () {
return (
<div className='container'>
Happens to unloaded sounds only, so works fine if |
I am able to reproduce this by adding a "seek" button to the "Preload Disabled" example that sets a render() {
return (
<div>
<ReactHowler
preload={false}
ref={ref => (this.player = ref)}
src={["sound2.ogg", "sound2.mp3"]}
playing={this.state.playing}
seek={this.state.seek}
onLoad={() => this.setState({ loadState: this.player.howlerState() })}
/>
{this.state.loadState === "unloaded" && (
<Button className="full" onClick={this.handleLoad}>
Load (Optional)
</Button>
)}
<br />
<Button onClick={this.handlePlay}>Play</Button>
<Button onClick={() => (this.setState({seek: 2}))}>Seek!</Button>
<Button onClick={this.handlePause}>Pause</Button>
</div>
); |
What if we checked the howler state before calling seek(pos = null) {
if (!this.howler || this.howlerState() === 'unloaded') {
return 0;
}
// ... etc. |
@Stenerson
If that's on current Otherwise, you're right, this PR doesn't fix the case of real attempt to seek in unloaded sound. Anyway, I'd be fine with either solution 👍 |
Ahh, yeah. I see what you're saying... 🤔 Something about this felt familiar. See goldfire/howler.js#796 & goldfire/howler.js#797 as well as #41. I initially misunderstood the problem that you were solving but now I see. Passing I think it's reasonable for us to "protect" against it though by not calling seek "accidentally." I like the second solution you came up with, to check Can you update to that method and I'll merge/publish? Thanks! |
aca2923
to
cf32412
Compare
Done |
@thangngoc89, if you’re looking for an EASY way to reproduce this for e2e tests you can just push the existing pause button before the sound is loaded on the existing no preload example. Before @svlapin’s changes - crash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Hey guys,
thanks for the nice wrapper!
I think I found a corner case when
toggleHowler
is fired and underlyinghowler._sounds
is empty (e.g.preload="false"
):As Howler itself doesn't expect to receive
seek
request when there is no underlying sound, I guess the wrapper should not try toseek
on each update unlessprops.seek
is set.