Use audio_session from pub.dev.
This commit is contained in:
parent
520bbb8656
commit
a7cf6c103f
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019-2020 Ryan Heise.
|
||||
Copyright (c) 2019-2020 Ryan Heise and the project contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -11,9 +11,9 @@ packages:
|
|||
audio_session:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../../audio_session"
|
||||
relative: true
|
||||
source: path
|
||||
name: audio_session
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
|
|
|
@ -7,8 +7,7 @@ environment:
|
|||
flutter: ">=1.12.8 <2.0.0"
|
||||
|
||||
dependencies:
|
||||
audio_session:
|
||||
path: ../../audio_session
|
||||
audio_session: ^0.0.1
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ class AudioPlayer {
|
|||
case AudioInterruptionType.unknown:
|
||||
if (playing) {
|
||||
pause();
|
||||
// Although pause is asyncand sets _playInterrupted = false,
|
||||
// Although pause is async and sets _playInterrupted = false,
|
||||
// this is done in the sync portion.
|
||||
_playInterrupted = true;
|
||||
}
|
||||
|
@ -532,12 +532,17 @@ class AudioPlayer {
|
|||
/// [stop] playback on completion, you can call either method as soon as
|
||||
/// [processingState] becomes [ProcessingState.completed] by listening to
|
||||
/// [processingStateStream].
|
||||
///
|
||||
/// This method activates the audio session before playback, and will do
|
||||
/// nothing if activation of the audio session fails for any reason.
|
||||
Future<void> play() async {
|
||||
if (playing) return;
|
||||
_playInterrupted = false;
|
||||
_playingSubject.add(true);
|
||||
await AudioSession.ensurePrepared(ensureActive: true);
|
||||
await _invokeMethod('play');
|
||||
final audioSession = await AudioSession.instance;
|
||||
if (await audioSession.setActive(true)) {
|
||||
_playingSubject.add(true);
|
||||
await _invokeMethod('play');
|
||||
}
|
||||
}
|
||||
|
||||
/// Pauses the currently playing media. This method does nothing if
|
||||
|
|
|
@ -11,9 +11,9 @@ packages:
|
|||
audio_session:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../audio_session"
|
||||
relative: true
|
||||
source: path
|
||||
name: audio_session
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
|
|
|
@ -8,8 +8,7 @@ environment:
|
|||
flutter: ">=1.12.8 <2.0.0"
|
||||
|
||||
dependencies:
|
||||
audio_session:
|
||||
path: ../audio_session
|
||||
audio_session: ^0.0.1
|
||||
rxdart: ^0.24.1
|
||||
path: ^1.6.4
|
||||
path_provider: ^1.6.10
|
||||
|
|
Loading…
Reference in New Issue