diff --git a/just_audio/CHANGELOG.md b/just_audio/CHANGELOG.md index e3a9f7d37..565d5f934 100644 --- a/just_audio/CHANGELOG.md +++ b/just_audio/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.9.27 + +* Support offload scheduling on Android. +* Fix iOS/macOS documentation for non-HTTP URLS and proxy usage. + ## 0.9.26 * Auto-correct invalid HTTP headers in proxy. diff --git a/just_audio/README.md b/just_audio/README.md index eaf370f81..662b66faf 100644 --- a/just_audio/README.md +++ b/just_audio/README.md @@ -236,7 +236,7 @@ To allow your application to access audio files on the Internet, add the followi ``` -If you wish to connect to non-HTTPS URLS, also add the following attribute to the `application` element: +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: ```xml @@ -284,15 +284,13 @@ post_install do |installer| end ``` -If you wish to connect to non-HTTPS URLS, 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 NSAppTransportSecurity NSAllowsArbitraryLoads - NSAllowsArbitraryLoadsForMedia - ``` @@ -307,15 +305,13 @@ To allow your macOS application to access audio files on the Internet, add the f ``` -If you wish to connect to non-HTTPS URLS, 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 NSAppTransportSecurity NSAllowsArbitraryLoads - NSAllowsArbitraryLoadsForMedia - ``` diff --git a/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java b/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java index de6df34fc..d31c284d2 100644 --- a/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java +++ b/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java @@ -11,6 +11,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.DefaultLivePlaybackSpeedControl; import com.google.android.exoplayer2.DefaultLoadControl; +import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.LivePlaybackSpeedControl; import com.google.android.exoplayer2.LoadControl; @@ -90,6 +91,7 @@ public class AudioPlayer implements MethodCallHandler, Player.Listener, Metadata private int errorCount; private AudioAttributes pendingAudioAttributes; private LoadControl loadControl; + private boolean offloadSchedulingEnabled; private LivePlaybackSpeedControl livePlaybackSpeedControl; private List rawAudioEffects; private List audioEffects = new ArrayList(); @@ -132,9 +134,10 @@ public void run() { } }; - public AudioPlayer(final Context applicationContext, final BinaryMessenger messenger, final String id, Map audioLoadConfiguration, List rawAudioEffects) { + public AudioPlayer(final Context applicationContext, final BinaryMessenger messenger, final String id, Map audioLoadConfiguration, List rawAudioEffects, Boolean offloadSchedulingEnabled) { this.context = applicationContext; this.rawAudioEffects = rawAudioEffects; + this.offloadSchedulingEnabled = offloadSchedulingEnabled != null ? offloadSchedulingEnabled : false; methodChannel = new MethodChannel(messenger, "com.ryanheise.just_audio.methods." + id); methodChannel.setMethodCallHandler(this); eventChannel = new BetterEventChannel(messenger, "com.ryanheise.just_audio.events." + id); @@ -727,7 +730,11 @@ private void ensurePlayerInitialized() { if (livePlaybackSpeedControl != null) { builder.setLivePlaybackSpeedControl(livePlaybackSpeedControl); } + if (offloadSchedulingEnabled) { + builder.setRenderersFactory(new DefaultRenderersFactory(context).setEnableAudioOffload(true)); + } player = builder.build(); + player.experimentalSetOffloadSchedulingEnabled(offloadSchedulingEnabled); setAudioSessionId(player.getAudioSessionId()); player.addListener(this); } diff --git a/just_audio/android/src/main/java/com/ryanheise/just_audio/MainMethodCallHandler.java b/just_audio/android/src/main/java/com/ryanheise/just_audio/MainMethodCallHandler.java index e339df5c5..ac039d0f0 100644 --- a/just_audio/android/src/main/java/com/ryanheise/just_audio/MainMethodCallHandler.java +++ b/just_audio/android/src/main/java/com/ryanheise/just_audio/MainMethodCallHandler.java @@ -34,7 +34,7 @@ public void onMethodCall(MethodCall call, @NonNull Result result) { break; } List rawAudioEffects = call.argument("androidAudioEffects"); - players.put(id, new AudioPlayer(applicationContext, messenger, id, call.argument("audioLoadConfiguration"), rawAudioEffects)); + players.put(id, new AudioPlayer(applicationContext, messenger, id, call.argument("audioLoadConfiguration"), rawAudioEffects, call.argument("androidOffloadSchedulingEnabled"))); result.success(null); break; } diff --git a/just_audio/example/ios/Runner/Info.plist b/just_audio/example/ios/Runner/Info.plist index a7d6daafb..efb7579f5 100644 --- a/just_audio/example/ios/Runner/Info.plist +++ b/just_audio/example/ios/Runner/Info.plist @@ -2,13 +2,11 @@ -NSAppTransportSecurity - - NSAllowsArbitraryLoads - - NSAllowsArbitraryLoadsForMedia - - + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable diff --git a/just_audio/lib/just_audio.dart b/just_audio/lib/just_audio.dart index e25a43b18..235418a40 100644 --- a/just_audio/lib/just_audio.dart +++ b/just_audio/lib/just_audio.dart @@ -61,6 +61,8 @@ class AudioPlayer { final AudioLoadConfiguration? _audioLoadConfiguration; + final bool _androidOffloadSchedulingEnabled; + /// This is `true` when the audio player needs to engage the native platform /// side of the plugin to decode or play audio, and is `false` when the native /// resources are not needed (i.e. after initial instantiation and after [stop]). @@ -166,13 +168,15 @@ class AudioPlayer { bool handleAudioSessionActivation = true, AudioLoadConfiguration? audioLoadConfiguration, AudioPipeline? audioPipeline, + bool androidOffloadSchedulingEnabled = false, }) : _id = _uuid.v4(), _userAgent = userAgent, _androidApplyAudioAttributes = androidApplyAudioAttributes && _isAndroid(), _handleAudioSessionActivation = handleAudioSessionActivation, _audioLoadConfiguration = audioLoadConfiguration, - _audioPipeline = audioPipeline ?? AudioPipeline() { + _audioPipeline = audioPipeline ?? AudioPipeline(), + _androidOffloadSchedulingEnabled = androidOffloadSchedulingEnabled { _audioPipeline._setup(this); if (_audioLoadConfiguration?.darwinLoadControl != null) { _automaticallyWaitsToMinimizeStalling = _audioLoadConfiguration! @@ -1290,6 +1294,7 @@ class AudioPlayer { .map((audioEffect) => audioEffect._toMessage()) .toList() : [], + androidOffloadSchedulingEnabled: _androidOffloadSchedulingEnabled, ))) : (_idlePlatform = _IdleAudioPlayer(id: _id, sequenceStream: sequenceStream)); diff --git a/just_audio/pubspec.yaml b/just_audio/pubspec.yaml index 4ddd0250e..971eba931 100644 --- a/just_audio/pubspec.yaml +++ b/just_audio/pubspec.yaml @@ -1,6 +1,6 @@ name: just_audio description: A feature-rich audio player for Flutter. Loop, clip and concatenate any sound from any source (asset/file/URL/stream) in a variety of audio formats with gapless playback. -version: 0.9.26 +version: 0.9.27 homepage: https://github.com/ryanheise/just_audio/tree/master/just_audio environment: @@ -8,7 +8,7 @@ environment: flutter: ">=1.12.13+hotfix.5" dependencies: - just_audio_platform_interface: ^4.1.0 + just_audio_platform_interface: ^4.2.0 # just_audio_platform_interface: # path: ../just_audio_platform_interface just_audio_web: ^0.4.4 diff --git a/just_audio_background/pubspec.yaml b/just_audio_background/pubspec.yaml index aeaa3f4f3..314b81f9e 100644 --- a/just_audio_background/pubspec.yaml +++ b/just_audio_background/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/ryanheise/just_audio/tree/master/just_audio_backgro version: 0.0.1-beta.7 dependencies: - just_audio_platform_interface: ^4.1.0 + just_audio_platform_interface: ^4.2.0 # just_audio_platform_interface: # path: ../just_audio_platform_interface audio_service: ^0.18.6 diff --git a/just_audio_web/pubspec.yaml b/just_audio_web/pubspec.yaml index 80e1f96e2..0c5cd2dec 100644 --- a/just_audio_web/pubspec.yaml +++ b/just_audio_web/pubspec.yaml @@ -11,7 +11,7 @@ flutter: fileName: just_audio_web.dart dependencies: - just_audio_platform_interface: ^4.1.0 + just_audio_platform_interface: ^4.2.0 # just_audio_platform_interface: # path: ../just_audio_platform_interface flutter: