forked from jeromexiong/audio_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.md
60 lines (50 loc) · 1.47 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# audio_manager
A flutter plugin for music playback, including notification handling.
> This plugin for android is based on mediaplayer, iOS is based on AVPlayer development
<img src="./screenshots/android.png" height="300"><img src="./screenshots/iOS.png" height="300">
## iOS
Add the following permissions in the `info.plist` file
```
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
```
## Android
Since `Android9.0 (API 28)`, the application disables HTTP plaintext requests by default. To allow requests, add `android:usesCleartextTraffic="true"` in `AndroidManifest.xml`
```
<application
...
android:usesCleartextTraffic="true"
...
>
```
## How to use?
The `audio_manager` plugin is developed in singleton mode. You only need to get`AudioManager.instance` in the method to quickly start using it.
## Quick start
⚠️ you can use local `assets` resources or `network` resources
```
// Initial playback. Preloaded playback information
AudioManager.instance
.start(
"assets/audio.mp3",
// "network mp3 resource"
"title",
desc: "desc",
cover: "assets/ic_launcher.png",
// cover: "network cover image resource")
.then((err) {
print(err);
});
// Play or pause; that is, pause if currently playing, otherwise play
AudioManager.instance.playOrPause()
// events callback
AudioManager.instance.onEvents((events, args) {
print("$events, $args");
}
```