react-native-video: HLS stream Android 4.4 - error (-38, 0)

Expected behaviour:

The video component receives a m3u8 file and plays the stream (Android 4.4).

Actual behaviour:

The video component shows nothing (black box), there is no error in the JS console, or in the app.

The Android logcat gives this error:

E/MediaPlayer: Should have subtitle controller already set
E/MediaPlayer: error (-38, 0)
E/MediaPlayer: start called in state 0
    error (-38, 0)
E/MediaPlayer: Error (-38,0)
E/MediaPlayer: Error (-38,0)

This is the only thing I can find related to to the mediaplayer. Normal videos, or devices with Android 5+ are working fine.

Environment:

react-native info returns:

Environment: OS: macOS High Sierra 10.13.4 Node: 9.4.0 Yarn: Not Found npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.3 Build version 9E145 Android Studio: 3.1 AI-173.4697961

Packages: (wanted => installed) react: ^16.2.0 => 16.2.0 react-native: ^0.53.3 => 0.53.3

Device OS: Android 4.4(.2).

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 26 (12 by maintainers)

Most upvoted comments

@cobarx I’m having issues with the Exoplayer. When switching between videos it will switch to an infinite buffer state. It is easy to reproduce. Just change the sourceUri a several times and after a few times it will will freeze.

No error in both the logcat, or React Native. Is this a known issue? Because it seems to fix the Android 4.4 problem. But I can’t use the Exoplayer with this bug.

Hey, Can update that we’ve found a direction - the buffering problem is happening only in HTTPS & HLS videos.

We’re now using http only for exoplayer. Hope it’ll help someone

It might be possible that we have to trust our SSL certificate manually. https://github.com/square/okhttp/wiki/HTTPS#customizing-trusted-certificates

When looking at other Exoplayer implementations and the official docs I saw them using the DefaultHttpDataSourceFactory instead of the OkHttpDataSourceFactory. Is there a reason why RNVideo is using this?

In DataSourceUtil.java this seems to work for me. But I don’t know if it can lead to other problems if we change it to this.

 private static HttpDataSource.Factory buildHttpDataSourceFactory(ReactContext context, DefaultBandwidthMeter bandwidthMeter, Map<String, String> requestHeaders) {
       DefaultHttpDataSourceFactory factory = new DefaultHttpDataSourceFactory(getUserAgent(context), bandwidthMeter);

       // Add request headers
       if (requestHeaders != null) {
           for (Map.Entry<String, String> entry : requestHeaders.entrySet())
           {
               factory.setDefaultRequestProperty(entry.getKey(), entry.getValue());
           }
       }

       return factory;
   }

Hey, I’ve updated to 2.1.1, and the player still gets stuck in buffering mode at X times of loading.

you can see a reproducing repository here.

Click on the green field for X times (here it’s sometimes 5, sometimes 30) and eventually it won’t play anymore. Tested on Samsung Galaxy S8, OnePlus 5 and LG K10

Please let us know if we can do something!!

cc @cobarx

@eyalcohen4 No, I still have the issue and I can’t find a solution. I’m still looking into it so I’ll let you know when I know more.