Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wangyng/simple_audio_player
A simple audio player for Flutter.
https://github.com/wangyng/simple_audio_player
flutter
Last synced: about 2 months ago
JSON representation
A simple audio player for Flutter.
- Host: GitHub
- URL: https://github.com/wangyng/simple_audio_player
- Owner: WangYng
- License: bsd-3-clause
- Created: 2021-08-06T09:33:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-01T07:32:24.000Z (10 months ago)
- Last Synced: 2024-03-01T08:36:09.454Z (10 months ago)
- Topics: flutter
- Language: Objective-C
- Homepage:
- Size: 2.45 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# simple_audio_player
A simple audio player for Flutter.
## Install Started
1. Add this to your **pubspec.yaml** file:
```yaml
dependencies:
simple_audio_player: ^1.0.2
```2. Install it
```bash
$ flutter packages get
```## Normal usage
```dart
@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(),
),
```## Feature
- [x] audio focus manager
- [x] play online mp3 file
- [x] play local mp3 file
- [x] play assets mp3 file
- [x] audio notification manager
- [x] observe becoming noisy