From ea3410a3daadc0453aa0feb68caf58011a79301a Mon Sep 17 00:00:00 2001
From: Oliver <oliver.henry.walters@gmail.com>
Date: Tue, 17 Dec 2024 17:46:48 +1100
Subject: [PATCH] Sounds fix (#583)

* Prevent notification sounds from pausing external media

- Closes https://github.com/inventree/inventree-app/issues/582

* Bump release notes

* Bump version number

* Update release notes
---
 assets/release_notes.md |  6 ++++++
 lib/helpers.dart        | 11 +++++++++++
 pubspec.yaml            |  2 +-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/assets/release_notes.md b/assets/release_notes.md
index 004e1158..91c6b49a 100644
--- a/assets/release_notes.md
+++ b/assets/release_notes.md
@@ -1,3 +1,9 @@
+### 0.17.2 - December 2024
+---
+
+- Prevent notification sounds from pause media playback
+- Updated translations
+
 ### 0.17.1 - December 2024
 ---
 
diff --git a/lib/helpers.dart b/lib/helpers.dart
index 993814f1..3a35d73b 100644
--- a/lib/helpers.dart
+++ b/lib/helpers.dart
@@ -107,6 +107,17 @@ Future<void> playAudioFile(String path) async {
   }
 
   final player = AudioPlayer();
+
+  // Specify context options for the audio player
+  // Ref: https://github.com/inventree/inventree-app/issues/582
+  player.setAudioContext(AudioContext(
+    android: AudioContextAndroid(
+      usageType: AndroidUsageType.notification,
+      audioFocus: AndroidAudioFocus.none,
+    ),
+    iOS: AudioContextIOS()
+  ));
+
   player.play(AssetSource(path));
 }
 
diff --git a/pubspec.yaml b/pubspec.yaml
index 84572dd5..c9091d55 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
 name: inventree
 description: InvenTree stock management
 
-version: 0.17.1+93
+version: 0.17.2+94
 
 environment:
   sdk: ">=2.19.5 <3.13.0"