Skip to content

Commit 4b0e99d

Browse files
authored
Merge pull request #57 from yosemiteyss/feat/merge-dev-to-main
merge dev to main
2 parents df51b89 + 4373aec commit 4b0e99d

File tree

7 files changed

+37
-11
lines changed

7 files changed

+37
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.2.7
2+
* Fixed audio session not activated with ambient state on iOS.
3+
14
## 1.2.6
25
* Added volume slider example.
36
* Updated documentation.

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ EXTERNAL SOURCES:
2121
SPEC CHECKSUMS:
2222
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
2323
flutter_volume_controller: e4d5832f08008180f76e30faf671ffd5a425e529
24-
integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5
24+
integration_test: 13825b8a9334a850581300559b8839134b124670
2525

2626
PODFILE CHECKSUM: ec7bdfce9f82e8314b94d9cd1cfee2974a0e1c97
2727

28-
COCOAPODS: 1.11.3
28+
COCOAPODS: 1.12.1

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
files = (
205205
);
206206
inputPaths = (
207+
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
207208
);
208209
name = "Thin Binary";
209210
outputPaths = (

example/lib/main.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ class _HomeState extends State<Home> {
3333
@override
3434
void initState() {
3535
super.initState();
36+
WidgetsBinding.instance.addPostFrameCallback((_) async {
37+
if (Platform.isIOS) {
38+
await _loadIOSAudioSessionCategory();
39+
}
40+
if (Platform.isAndroid) {
41+
await _loadAndroidAudioStream();
42+
}
43+
});
3644
FlutterVolumeController.addListener((volume) {
3745
setState(() {
3846
_currentVolume = volume;
@@ -279,4 +287,22 @@ class _HomeState extends State<Home> {
279287
),
280288
);
281289
}
290+
291+
Future<void> _loadIOSAudioSessionCategory() async {
292+
final category = await FlutterVolumeController.getIOSAudioSessionCategory();
293+
if (category != null) {
294+
setState(() {
295+
_audioSessionCategory = category;
296+
});
297+
}
298+
}
299+
300+
Future<void> _loadAndroidAudioStream() async {
301+
final audioStream = await FlutterVolumeController.getAndroidAudioStream();
302+
if (audioStream != null) {
303+
setState(() {
304+
_audioStream = _audioStream;
305+
});
306+
}
307+
}
282308
}

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ packages:
102102
path: ".."
103103
relative: true
104104
source: path
105-
version: "1.2.6"
105+
version: "1.2.7"
106106
fuchsia_remote_debug_protocol:
107107
dependency: transitive
108108
description: flutter

ios/Classes/VolumeController.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,33 @@ class VolumeController {
2424
}
2525

2626
func getVolume() throws -> Float {
27-
try audioSession.setActive(true)
27+
try audioSession.activate(with: VolumeController.defaultCategory)
2828
let volume = audioSession.outputVolume
2929
return volume
3030
}
3131

3232
func setVolume(_ volume: Double, showSystemUI: Bool) throws {
33-
try audioSession.setActive(true)
3433
setShowSystemUI(showSystemUI)
3534
volumeView.setVolume(volume)
3635
}
3736

3837
func raiseVolume(_ step: Double?, showSystemUI: Bool) throws {
39-
try audioSession.setActive(true)
4038
setShowSystemUI(showSystemUI)
4139
volumeView.raiseVolume(step ?? VolumeController.defaultStep)
4240
}
4341

4442
func lowerVolume(_ step: Double?, showSystemUI: Bool) throws {
45-
try audioSession.setActive(true)
4643
setShowSystemUI(showSystemUI)
4744
volumeView.lowerVolume(step ?? VolumeController.defaultStep)
4845
}
4946

5047
func getMute() throws -> Bool {
51-
try audioSession.setActive(true)
48+
try audioSession.activate(with: VolumeController.defaultCategory)
5249
return audioSession.outputVolume == 0
5350
}
5451

5552
func setMute(_ isMuted: Bool, showSystemUI: Bool) throws {
56-
try audioSession.setActive(true)
53+
try audioSession.activate(with: VolumeController.defaultCategory)
5754

5855
// Save current volume level before mute.
5956
if isMuted {
@@ -79,7 +76,6 @@ class VolumeController {
7976
}
8077

8178
func getAudioSessionCategory() throws -> AudioSessionCategory? {
82-
try audioSession.setActive(true)
8379
return AudioSessionCategory.allCases.first { category in category.categoryType == audioSession.category }
8480
}
8581

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_volume_controller
22
description: A Flutter plugin to control system volume and listen for volume changes on different platforms.
3-
version: 1.2.6
3+
version: 1.2.7
44
homepage: https://github.com/yosemiteyss/flutter_volume_controller
55

66
environment:

0 commit comments

Comments
 (0)