implement automaticallyWaitsToMinimizeStalling on iOS (#49)

* implement automaticallyWaitsToMinimizeStalling on iOS

* Allow automaticallyWaitsToMinimizeStalling to be called before setUrl

Co-authored-by: ryanheise <ryan@ryanheise.com>
This commit is contained in:
Esmond Wong 2020-03-07 08:49:35 +08:00 committed by GitHub
parent f3d9a34b50
commit c79216c818
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View file

@ -83,6 +83,8 @@ class AudioPlayer {
double _speed = 1.0;
bool _automaticallyWaitsToMinimizeStalling = true;
File _cacheFile;
/// Creates an [AudioPlayer].
@ -158,6 +160,10 @@ class AudioPlayer {
/// The current speed of the player.
double get speed => _speed;
/// Whether the player should automatically delay playback in order to minimize stalling. (iOS 10.0 or later only)
bool get automaticallyWaitsToMinimizeStalling =>
_automaticallyWaitsToMinimizeStalling;
/// Loads audio media from a URL and completes with the duration of that
/// audio, or null if this call was interrupted by another call so [setUrl],
/// [setFilePath] or [setAsset].
@ -261,6 +267,16 @@ class AudioPlayer {
await _invokeMethod('setSpeed', [speed]);
}
/// Sets automaticallyWaitsToMinimizeStalling for AVPlayer in iOS 10.0 or later, defaults to true.
/// Has no effect on Android clients
Future<void> setAutomaticallyWaitsToMinimizeStalling(
final bool automaticallyWaitsToMinimizeStalling) async {
_automaticallyWaitsToMinimizeStalling =
automaticallyWaitsToMinimizeStalling;
await _invokeMethod('setAutomaticallyWaitsToMinimizeStalling',
[automaticallyWaitsToMinimizeStalling]);
}
/// Seeks to a particular position. It is legal to invoke this method from
/// any state except for [AudioPlaybackState.none] and
/// [AudioPlaybackState.connecting].