audio manager music playback
a flutter plugin for music playback, including notification handling.
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 getaudiomanager.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");
}
Comments are closed.