diff --git a/LICENSE b/LICENSE index 27a8b32..6948574 100644 --- a/LICENSE +++ b/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 diff --git a/example/pubspec.lock b/example/pubspec.lock index 87f7303..d8514c6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -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 diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6414fd1..29a7f20 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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 diff --git a/lib/just_audio.dart b/lib/just_audio.dart index 23e5373..6968878 100644 --- a/lib/just_audio.dart +++ b/lib/just_audio.dart @@ -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 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 diff --git a/pubspec.lock b/pubspec.lock index d83cb24..c9697d2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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 diff --git a/pubspec.yaml b/pubspec.yaml index 32b9ed2..4b35913 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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