Last updated:
0 purchases
simple audio player
simple_audio_player #
A simple audio player for Flutter.
Install Started #
Add this to your pubspec.yaml file:
dependencies:
simple_audio_player: ^1.0.2
copied to clipboard
Install it
$ flutter packages get
copied to clipboard
Normal usage #
@override
void initState() {
super.initState();
simpleAudioPlayer = SimpleAudioPlayer();
simpleAudioPlayer.songStateStream.listen((event) {
print("song event : $event");
});
focusManager.audioFocusStream.listen((event) {
print("focus event : $event");
});
focusManager.becomingNoisyStream.listen((event) {
print("becoming noisy event : $event");
});
notificationManager.notificationStream.listen((event) {
print("notification event : $event");
});
}
// ...
CupertinoButton(
child: Text("requestAudioFocus"),
onPressed: () {
SimpleAudioFocusManager().tryToGetAudioFocus().then((value) {
print("tryToGetAudioFocus $value");
});
},
),
CupertinoButton(
child: Text("giveUpAudioFocus"),
onPressed: () {
SimpleAudioFocusManager().giveUpAudioFocus();
},
),
CupertinoButton(
child: Text("prepare"),
onPressed: () {
simpleAudioPlayer.prepare(
uri: "https://96.f.1ting.com/local_to_cube_202004121813/96kmp3/2021/04/16/16b_am/01.mp3");
},
),
CupertinoButton(
child: Text("play"),
onPressed: () {
simpleAudioPlayer.play();
},
),
CupertinoButton(
child: Text("pause"),
onPressed: () {
simpleAudioPlayer.pause();
},
),
CupertinoButton(
child: Text("stop"),
onPressed: () {
simpleAudioPlayer.stop();
},
),
CupertinoButton(
child: Text("showNotification"),
onPressed: () => notificationManager.showNotification(player: player, title: "title", artist: "artist", clipArt: ""),
),
CupertinoButton(
child: Text("cancelNotification"),
onPressed: () => notificationManager.cancelNotification(),
),
copied to clipboard
Feature #
✅ audio focus manager
✅ play online mp3 file
✅ play local mp3 file
✅ play assets mp3 file
✅ audio notification manager
✅ observe becoming noisy
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.