diff --git a/src/players/Base.js b/src/players/Base.js index d6ad690..c180312 100644 --- a/src/players/Base.js +++ b/src/players/Base.js @@ -9,6 +9,7 @@ export default class Base extends Component { static defaultProps = defaultProps isReady = false startOnPlay = true + durationOnPlay = false componentDidMount () { if (this.props.url) { this.load(this.props.url) @@ -55,7 +56,10 @@ export default class Base extends Component { this.seekTo(this.seekOnReady) this.seekOnReady = null } - this.props.onDuration(this.getDuration()) + if (this.durationOnPlay) { + this.props.onDuration(this.getDuration()) + this.durationOnPlay = false + } } onReady = () => { this.isReady = true @@ -68,6 +72,12 @@ export default class Base extends Component { this.play() } } + const duration = this.getDuration() + if (duration) { + this.props.onDuration(duration) + } else { + this.durationOnPlay = true + } } onEnded = () => { if (this.props.loop) {