react-native-video: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.media.MediaPlayer.getCurrentPosition()'

Bug

Platform

Which player are you experiencing the problem on:

  • Android ExoPlayer
  • Android MediaPlayer

Environment info

React native info output:

info Fetching system and libraries information...
System:
    OS: macOS Mojave 10.14.4
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
    Memory: 2.63 GB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 13.8.0 - /usr/local/bin/node
    npm: 6.13.7 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
    Android SDK:
      API Levels: 23, 25, 26, 27, 28, 29
      Build Tools: 28.0.3, 29.0.3
      System Images: android-27 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5

Library version: 5.0.2

Error log - From Sentry.io

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.media.MediaPlayer.getCurrentPosition()' on a null object reference
    at com.yqritc.scalablevideoview.ScalableVideoView.getCurrentPosition(ScalableVideoView.java:200)
    at android.widget.MediaController.setProgress(MediaController.java:438)
    at android.widget.MediaController.show(MediaController.java:358)
    at android.widget.MediaController.show(MediaController.java:314)
    at com.brentvatne.react.ReactVideoView$2.run(ReactVideoView.java:572)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6820)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)

Screenshot 2020-05-03 at 1 06 28 PM

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Easy to reproduce with react-navigation.

I had video, which automatically start playing on some screen. (tab in my case) When I navigate to different screen, crash immediately appears.

Temporary solved by:

  const isFocused = useIsFocused()
  if (!isFocused) return null

Any workarounds for this issue ? still facing it.

@tomheo11233aA the easiest is to switch on v6.0.0-beta.9

This problem make android version very unstable.

Meantime, I switched to exoplayer. And issue gone.