Skip to content
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

[android][video] The more you replay a video, the more onPlaybackStatusUpdate will be called #6342

Closed
Fr33maan opened this issue Nov 21, 2019 · 5 comments · Fixed by #7193
Closed

Comments

@Fr33maan
Copy link

🐛 Bug Report

Environment

  Expo CLI 3.4.1 environment info:
    System:
      OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
      Shell: 4.4.20 - /bin/bash
    Binaries:
      Node: 12.10.0 - ~/.nvm/versions/node/v12.10.0/bin/node
      Yarn: 1.17.3 - ~/.nvm/versions/node/v12.10.0/bin/yarn
      npm: 6.10.3 - ~/.nvm/versions/node/v12.10.0/bin/npm
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.5791312
    npmPackages:
      @types/react: ^16.8.23 => 16.9.11 
      @types/react-native: ^0.57.65 => 0.57.65 
      expo: ^35.0.0 => 35.0.0 
      react: 16.8.3 => 16.8.3 
      react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8 
      react-navigation: ^4.0.10 => 4.0.10 
    npmGlobalPackages:
      expo-cli: 3.4.1

Target app is android, I test on Emulator Android 9.

Steps to Reproduce

Create a new app, take a video from the internet and just use my code.
The console will be flooded by numbers which will increase quicker and quicker, the more you click on the replay button.

Expected Behavior

The onPlaybackStatusUpdate calls should be consistent over video replay

Actual Behavior

Each time you click on replay button which call playAsync or replayAsync, the callback is called one more time per update.
If you push the button 10 times, instead of calling the onPlaybackStatusUpdate 1 time every 500ms, it will be called 10 times every 500ms.

Reproducible Demo

class VideoV extends React.Component {
  constructor (props) {
    super(props)
    this._replayVideo = this._replayVideo.bind(this)
    this.count = 0
  }

  _handleVideoRef = component => {
    this.playbackObject = component
  }

  _replayVideo () {
    this.playbackObject.getStatusAsync().then(({ positionMillis, durationMillis }) => {
      console.log(Object.keys(this.playbackObject))
      if (positionMillis === durationMillis) {
        this.playbackObject.playAsync()
      }
    })
  }

  render () {
    return (
      <View style={{ height: 500, width: 500 }}>
        <Video
          style={{ width: '80%', height: '80%' }}
          source={require('yourLocalVideoUrl.mp4')}
          shouldPlay
          ref={this._handleVideoRef}
          onPlaybackStatusUpdate={(params) => {
            this.count++
            console.log(this.count)
          }}
        />
        <TouchableOpacity onPress={this._replayVideo} style={{ height: 200, width: 200 }}>
          <Text style={{ color: 'white' }}>
            replay
          </Text>
        </TouchableOpacity>
      </View>
    )
  }
}

Please let me know if I can provide more details

@Fr33maan Fr33maan added the bug label Nov 21, 2019
@cruzach
Copy link
Contributor

cruzach commented Nov 21, 2019

Here's a snack that uses replayAsync, I couldn't get your snack to repro the behavior, but this one does - https://snack.expo.io/@charliecruzan/replayvideo

It looks like when replayAsync is called, the progressUpdateIntervalMillis is adding a new onPlaybackStatusUpdate call, but overwrites the original. It's more noticeable if you set the new playback status object to progressUpdateIntervalMillis: 5000.

@cruzach cruzach changed the title The more you replay a video, the more onPlaybackStatusUpdate will be called [android][video] The more you replay a video, the more onPlaybackStatusUpdate will be called Nov 21, 2019
@Fr33maan
Copy link
Author

Fr33maan commented Nov 21, 2019 via email

@pavithra-expedux
Copy link

@cruzach I'm also facing same issue with audio player. I gave progressUpdateIntervalMillis:1000. So when ever i call replayAsync or playFromPositionAsync it started to return play status more than 1 time for next few seconds.

@mczernek
Copy link
Contributor

This is not an easy error to fix, given how AV is structured, especially when it comes to playback update callback. However, will try to dig into it and fix it 🤞

@joao-gabriel-malaquias-borges

Hi! My name is Jhon and I think that I've got the same issue explainned here. Currently I'm developing a react-native project with expo which include a file that uses AV api for displaying a video. In my project for each time in an interval defined by progressUpdateIntervalMillis while video is playing I have to update other component in my application and for this I set a function that make it then I put her at onPlaybackStatusUpdate prop. However ever I invoke some of api's methods one more call than I expect is invoked to onPlaybackStatusUpdate. So what I could like know is if there are something that I can do to resolve this considering that I'm just one first-time traveler in real development and that I do not have experience with tecnologies like android and others I just have my theorical concepts from college and around two months on react-native development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants