react-player: [v2.10.1] `onProgress` callback is not firing when the video is playing

Be sure to search for your issue before opening a new one.

Current Behavior

onProgress callback is not called when the video is playing.

Expected Behavior

onProgress callback should be called periodically with the playback information when the video is playing.

Steps to Reproduce

  1. Use version v2.10.1 of react-player (issue does not exist in v2.10.0

  2. Add a simple player as follows that plays a webm file

    <ReactPlayer
      ref={playerRef}
      width={1024}
      height={768}
      muted
      playing={true}
      url="https://example.com/video.webm"
      onDuration={onDuration}
      onProgress={onProgress}
    />
    
  3. The onProgress callback is never called

Environment

  • URL attempting to play: Any url containing a video file (I used a webm file)
  • Browser: Chrome
  • Operating system: MacOS

Other Information

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 22 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I can also confirm the issue with "react-player": "2.10.1" and React 18 using react-scripts.

I managed to temporarily fix it by removing React.StrictMode.


Minimal reproduction: https://codesandbox.io/s/naughty-wildflower-pqvest

Expected behavior: it should log the onProgress events

Actual behavior: it does not log the onProgress events

Temporary fix: remove <StrictMode> and now it does log the onProgress events.

Looking forward to the proper fix 🙂

Version 2.10.1 was released ~90 days ago (3 months ago according to the npm repo) and the PR for this issue was merged 21 days ago. Version 2.10.1 is also the latest release. Therefore, the fix for this issue has not been released yet.

When can we expect a release on the next version of react player

I’ve taken a moment to look into this and I think replacing (src/Player.js):

  handlePlayerMount = player => {
    if (this.player) return // Prevent loading twice in strict mode
    this.player = player
    this.player.load(this.props.url)
    this.progress()
  }

with

  handlePlayerMount = player => {
    if (this.player) { // Prevent loading twice in strict mode
      this.progress()
      return
    }
    this.player = player
    this.player.load(this.props.url)
    this.progress()
  }

should fix the issue.

I’ve created a PR with this fix. Please let me know if there are any issues with the proposed fix.

Thanks!

I have the same issue.

Fixed in 2.11.0. Sorry for the delay.

@kgilliam125 turns out when I deploy the change to an environment, onProgress gets triggered:

{playedSeconds: 2.009596, played: 0, loadedSeconds: 4.44, loaded: 0}

@manishsharma004 was alluding to this earlier, so the suggestion here is to disable strict mode (thanks @manishsharma004 !)

I created this a couple days a go to help illustrate the issue. Hopefully this helps.

@kgilliam125 turns out when I deploy the change to an environment, onProgress gets triggered:

{playedSeconds: 2.009596, played: 0, loadedSeconds: 4.44, loaded: 0}

@manishsharma004 was alluding to this earlier, so the suggestion here is to disable strict mode (thanks @manishsharma004 !)