Prevent play/pause from loading when preload=false.

This commit is contained in:
Ryan Heise 2020-12-21 12:57:57 +11:00
parent 62c369527f
commit 6e283966de
1 changed files with 4 additions and 6 deletions

View File

@ -513,10 +513,8 @@ class AudioPlayer {
/// By default, this method will immediately start loading audio and return
/// its duration as soon as it is known, or `null` if that information is
/// unavailable. Set [preload] to `false` if you would prefer to delay loading
/// until some later point, either via an explicit call to [load] or
/// implicitly on demand when you use a method such as [play] which requires
/// audio to be loaded. If [preload] is `false`, a `null` duration will be
/// returned.
/// until some later point, via an explicit call to [load]. If [preload] is
/// `false`, a `null` duration will be returned.
///
/// Optionally specify [initialPosition] and [initialIndex] to seek to an
/// initial position within a particular item (defaulting to position zero of
@ -679,7 +677,7 @@ class AudioPlayer {
Future<void> play() async {
if (_disposed) return;
if (playing) return;
_setPlatformActive(_audioSource != null);
//_setPlatformActive(_audioSource != null);
_playInterrupted = false;
final audioSession = await AudioSession.instance;
if (await audioSession.setActive(true)) {
@ -693,7 +691,7 @@ class AudioPlayer {
Future<void> pause() async {
if (_disposed) return;
if (!playing) return;
_setPlatformActive(true);
//_setPlatformActive(true);
_playInterrupted = false;
// Update local state immediately so that queries aren't surprised.
_playbackEvent = _playbackEvent.copyWith(