0

My stream works pefectly with android.media.MediaPlayer on a number of devices: Samsung, Xiaomi, Huawei etc. However, recently devices started to receive Android 9.x updates. My stream stopped working on OnePlus 6 after installing Android 9.x update.

I'm receiving the following native error from MediaPlayer:

type: 1, code: -1004

or in other words: what: 1, extra: -1004

what: MEDIA_ERROR_UNKNOWN, extra: MEDIA_ERROR_IO

First of all: check whether you're streaming from https source.

What else could be the cause?

1 Answers1

0

From Android 9.x Opt out of cleartext traffic policy became the default one. So to enable http fallback in your apps you need to specifically define the policy in AndroidManifest.xml.

Cleartext (using the unencrypted HTTP protocol instead of HTTPS) can be restored by adding:

<application
   [...]
   android:usesCleartextTraffic="true"
   [...] /> 

Check whether the policy is turned on like this: NetworkSecurityPolicy.isCleartextTrafficPermitted()

More info here and here