assets_audio_player 包 手机锁屏时的音乐控制
我正在构建一个音乐播放器应用程序,一切正常,但是当手机屏幕锁定时,通知被禁用 在此处输入图像描述
getSongs() async {
List<SongInfo> artists =
await audioQuery.getSongs(sortType: SongSortType.RECENT_YEAR);
for (var i = 0; i < artists.length; i++) {
int rr = math.Random().nextInt(9);
songs.add(Audio.file(artists[i].filePath,
metas: Metas(
title: artists[i].title,
artist: artists[i].artist,
image: MetasImage.file(artists[i].albumArtwork),
onImageLoadFail: MetasImage.asset('assets/$rr.jpg'))));
infos.add(artists[i]);
}
assetsAudioPlayer.open(Playlist(audios: songs),
showNotification: true,
autoStart: false,
loopMode: LoopMode.playlist,
playInBackground: PlayInBackground.enabled,
forceOpen: true,
notificationSettings: NotificationSettings(
playPauseEnabled: true,
nextEnabled: true,
prevEnabled: true,
stopEnabled: true,
seekBarEnabled: true,
)
// headPhoneStrategy: HeadPhoneStrategy.pauseOnUnplug,
);
}
我使用assets_audio_player包
此问题仅在 Android 9 及以上版本中出现
请帮我解决办法?
I am building a music player application, everything works fine, but when the phone screen is locked, the notification is disabled enter image description here
getSongs() async {
List<SongInfo> artists =
await audioQuery.getSongs(sortType: SongSortType.RECENT_YEAR);
for (var i = 0; i < artists.length; i++) {
int rr = math.Random().nextInt(9);
songs.add(Audio.file(artists[i].filePath,
metas: Metas(
title: artists[i].title,
artist: artists[i].artist,
image: MetasImage.file(artists[i].albumArtwork),
onImageLoadFail: MetasImage.asset('assets/$rr.jpg'))));
infos.add(artists[i]);
}
assetsAudioPlayer.open(Playlist(audios: songs),
showNotification: true,
autoStart: false,
loopMode: LoopMode.playlist,
playInBackground: PlayInBackground.enabled,
forceOpen: true,
notificationSettings: NotificationSettings(
playPauseEnabled: true,
nextEnabled: true,
prevEnabled: true,
stopEnabled: true,
seekBarEnabled: true,
)
// headPhoneStrategy: HeadPhoneStrategy.pauseOnUnplug,
);
}
i use assets_audio_player package
This problem is only in Android 9 and above
Please help me what is the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论