-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extensive settings for media controls through notification (#28)
* feat: add notification settings customisation options * feat: add notification settings page and update routing
- Loading branch information
Showing
21 changed files
with
1,386 additions
and
371 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+743 Bytes
android/app/src/main/res/drawable-mdpi/ic_stat_notification_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.46 KB
android/app/src/main/res/drawable-xxhdpi/ic_stat_notification_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.78 KB
android/app/src/main/res/drawable-xxxhdpi/ic_stat_notification_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import 'package:audio_service/audio_service.dart'; | ||
import 'package:audio_session/audio_session.dart'; | ||
import 'package:just_audio_background/just_audio_background.dart' | ||
show JustAudioBackground, NotificationConfig; | ||
import 'package:just_audio_media_kit/just_audio_media_kit.dart' | ||
show JustAudioMediaKit; | ||
import 'package:vaani/settings/app_settings_provider.dart'; | ||
import 'package:vaani/settings/models/app_settings.dart'; | ||
|
||
Future<void> configurePlayer() async { | ||
// for playing audio on windows, linux | ||
JustAudioMediaKit.ensureInitialized(); | ||
|
||
// for configuring how this app will interact with other audio apps | ||
final session = await AudioSession.instance; | ||
await session.configure(const AudioSessionConfiguration.speech()); | ||
|
||
final appSettings = loadOrCreateAppSettings(); | ||
|
||
// for playing audio in the background | ||
await JustAudioBackground.init( | ||
androidNotificationChannelId: 'com.vaani.bg_demo.channel.audio', | ||
androidNotificationChannelName: 'Audio playback', | ||
androidNotificationOngoing: true, | ||
androidStopForegroundOnPause: true, | ||
androidNotificationChannelDescription: 'Audio playback in the background', | ||
androidNotificationIcon: 'drawable/ic_stat_notification_logo', | ||
rewindInterval: appSettings.notificationSettings.rewindInterval, | ||
fastForwardInterval: appSettings.notificationSettings.fastForwardInterval, | ||
androidShowNotificationBadge: false, | ||
notificationConfigBuilder: (state) { | ||
final controls = [ | ||
if (appSettings.notificationSettings.mediaControls | ||
.contains(NotificationMediaControl.skipToPreviousChapter) && | ||
state.hasPrevious) | ||
MediaControl.skipToPrevious, | ||
if (appSettings.notificationSettings.mediaControls | ||
.contains(NotificationMediaControl.rewind)) | ||
MediaControl.rewind, | ||
if (state.playing) MediaControl.pause else MediaControl.play, | ||
if (appSettings.notificationSettings.mediaControls | ||
.contains(NotificationMediaControl.fastForward)) | ||
MediaControl.fastForward, | ||
if (appSettings.notificationSettings.mediaControls | ||
.contains(NotificationMediaControl.skipToNextChapter) && | ||
state.hasNext) | ||
MediaControl.skipToNext, | ||
if (appSettings.notificationSettings.mediaControls | ||
.contains(NotificationMediaControl.stop)) | ||
MediaControl.stop, | ||
]; | ||
return NotificationConfig( | ||
controls: controls, | ||
systemActions: const { | ||
MediaAction.seek, | ||
MediaAction.seekForward, | ||
MediaAction.seekBackward, | ||
}, | ||
); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.