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