Skip to content

Commit c8a114b

Browse files
committed
specify transient audio focus
closes #26
1 parent dbe3af6 commit c8a114b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/widgets/timer_page.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class TimerPageState extends State<TimerPage>
4444
Timer? _notificationUpdateTimer;
4545
late String sessionKey;
4646
static final AudioPlayer _audioPlayer = AudioPlayer();
47+
static final AudioContext _audioContext = AudioContext(
48+
android: AudioContextAndroid(
49+
usageType: AndroidUsageType.media,
50+
audioFocus: AndroidAudioFocus.gainTransient,
51+
),
52+
);
4753
static FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
4854
FlutterLocalNotificationsPlugin();
4955

@@ -65,7 +71,7 @@ class TimerPageState extends State<TimerPage>
6571

6672
@pragma('vm:entry-point')
6773
static _ring() async {
68-
await _audioPlayer.play(AssetSource(audioResourceName));
74+
await _audioPlayer.play(AssetSource(audioResourceName), ctx: _audioContext);
6975
}
7076

7177
_updateProgressNotification() async {

0 commit comments

Comments
 (0)