Use audio_session from pub.dev.

This commit is contained in:
Ryan Heise 2020-08-23 18:00:16 +10:00
parent 520bbb8656
commit a7cf6c103f
6 changed files with 18 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -532,13 +532,18 @@ 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;
final audioSession = await AudioSession.instance;
if (await audioSession.setActive(true)) {
_playingSubject.add(true);
await AudioSession.ensurePrepared(ensureActive: true);
await _invokeMethod('play');
}
}
/// Pauses the currently playing media. This method does nothing if
/// ![playing].

View File

@ -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

View File

@ -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