React-native-video: Android Not Autoplaying

Created on 22 Aug 2017  路  3Comments  路  Source: react-native-video/react-native-video

The source is not playing upon start, even though paused is set to false.

If I call the seek method during a button press the video will start playing, but not if I call seek onLoad.

This only happens on Android, and only when the source file is audio only (mp3 vs mp4). Additionally if I restart the app this bug doesn't occur on the first attempt, but will occur on all successive attempts.

"react-native": "0.47.1"
"react-native-video": "^2.0.0"

My component looks like this:

                  <Video
                    ref={(c) => this._player = c}
                    source={{ uri: this._source }}
                    resizeMode={'cover'}
                    paused={isPaused}
                    onProgress={(time) => this._setProgress(time)}
                    progressUpdateInterval={500}
                    onEnd={this._onEnd}
                    onLoad={() => this._onLoad()}
                  />

Most helpful comment

My working solution for this is:

  _onLoad() {
    ...
    if (Platform.OS === 'android' && this._isAudio) {
      setTimeout(() => this._player.seek(0), 100);
    }
  }

..although that's awful and I'd rather not have this in my prod code. This doesn't work without the Timeout.

All 3 comments

My working solution for this is:

  _onLoad() {
    ...
    if (Platform.OS === 'android' && this._isAudio) {
      setTimeout(() => this._player.seek(0), 100);
    }
  }

..although that's awful and I'd rather not have this in my prod code. This doesn't work without the Timeout.

Tried with:

"react-native": "0.47.1"
"react-native-video": "^2.0.0"

and the proposed workaround

_onLoad() {
    ...
    if (Platform.OS === 'android' && this._isAudio) {
      setTimeout(() => this._player.seek(0), 100);
    }
  }

and still, the video won't play.

*UPDATE: Made it work by updating to Android 25.

Fixed this awhile back.

Was this page helpful?
0 / 5 - 0 ratings