Skip to content

Commit

Permalink
Merge branch 'feature/cleartext_docs' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed May 16, 2023
2 parents 8f92869 + 091324e commit 79d8741
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions just_audio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,29 @@ To allow your application to access audio files on the Internet, add the followi
<uses-permission android:name="android.permission.INTERNET"/>
```

If you wish to connect to non-HTTPS URLS, or if you use a feature that depends on the proxy such as headers, caching or stream audio sources, also add the following attribute to the `application` element:
If you wish to connect to non-HTTPS URLs (typically HTTP), also add the following attribute to the `application` element:

```xml
<application ... android:usesCleartextTraffic="true">
```

Note that just_audio's proxy (used to implement features such as headers, caching and stream audio sources) runs on a `localhost` HTTP server, and this also requires cleartext access to be enabled. You can either enable this via the option above which also enables access to any non-HTTPS URL, or you can instead limit cleartext access to just `localhost` URLs by defining a network security config. To use this approach, create the file `android/app/src/main/res/xml/network_security_config.xml`:

```xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">127.0.0.1</domain>
</domain-config>
</network-security-config>
```

Then reference this network security config in your `AndroidManifest.xml` file by adding the following attribute to the `application` element:

```xml
<application ... android:networkSecurityConfig="@xml/network_security_config">
```

If you need access to the player's AudioSession ID, you can listen to `AudioPlayer.androidAudioSessionIdStream`. Note that the AudioSession ID will change whenever you set new AudioAttributes.

If there are multiple plugins in your app that use ExoPlayer to decode media, it is possible to encounter a `Duplicate class` error if those plugins use different versions of ExoPlayer. In this case you may report an issue for each respective plugin to upgrade to the latest version of ExoPlayer, or you may downgrade one or more of your app's plugins until the versions match. In some cases where a plugin uses non-breaking parts of the ExoPlayer API, you can also try forcing all plugins to use the same version of ExoPlayer by editing your own app's `android/app/build.gradle` file and inserting the dependencies for the desired Exoplayer version:
Expand Down Expand Up @@ -284,7 +301,7 @@ post_install do |installer|
end
```

If you wish to connect to non-HTTPS URLS, or if you use a feature that depends on the proxy such as headers, caching or stream audio sources, add the following to your `Info.plist` file:
If you wish to connect to non-HTTPS URLs, or if you use a feature that depends on the proxy such as headers, caching or stream audio sources, add the following to your `Info.plist` file:

```xml
<key>NSAppTransportSecurity</key>
Expand All @@ -305,7 +322,7 @@ To allow your macOS application to access audio files on the Internet, add the f
<true/>
```

If you wish to connect to non-HTTPS URLS, or if you use a feature that depends on the proxy such as headers, caching or stream audio sources, add the following to your `Info.plist` file:
If you wish to connect to non-HTTPS URLs, or if you use a feature that depends on the proxy such as headers, caching or stream audio sources, add the following to your `Info.plist` file:

```xml
<key>NSAppTransportSecurity</key>
Expand Down

0 comments on commit 79d8741

Please sign in to comment.