Closed AlexV525 closed 4 years ago
when you tell current playing audio
, it's for example "youtube music player" ?
Yes, just like the one in the screenshot.
Ok thanks that's my next bug to fix !
found, it's because of the requestAudioFocus
, used to pause the media player on phone call
maybe I can make this optional, like "requestAudioFocus: true" on open method (by default), which enable to listen audio focus & stop on phone call
setting it to false will solve your issue, but recieving a phone call will not pause the audio !
or maybe migrate to https://stackoverflow.com/questions/5948961/how-to-know-whether-i-am-in-a-call-on-android, to only pause on phone call :) I'll look for this
this solution requires runtime permission :/ it's not a good solution for the user
found, it's because of the
requestAudioFocus
, used to pause the media player on phone call
This sounds good. How if we can requestAudioFocus
only when we start the first play?
If we do this, it will stop the other media player at the start, like your qq music player
I think you'll need to make a choice,
make this media player require focus (pause others players, intercept phone call state)
Don't mind if audio focus : don't pause other players, but don't know if the phone is receiving a call
- make this media player require focus (pause others players, intercept phone call state)
Am I missing something? I mean pause other players when the app which calling this package to play an audio. This behaviour is fine because it calls by user's request.
e.g. I'm playing some music with QQMusic, then I start my flutter app, choose an audio and try to play it, at that time it should stop my music and play the audio I requested.
Oh ok I see, I just have to move the request audio, sorry ^^ I'll do that today
I fixed this, can you try the ^1.6.2+5
?
I close it but if this does not work, reopen it please :)
Thanks for your rapid response! And it's been resolved through I tested with my devices.
Hi @AlexV525 , current I'm using version assets_audio_player: ^2.0.13+8. But when I play a AssetsAudioPlayerGroup. Sound play normally but when I go to background and open app again. Sound auto stopped. I check log when I open app again see that: D/AudioManager(16302): dispatching onAudioFocusChange(-1) to android.media.AudioManager@f3d4723com.github.florent37.assets_audio_player.stopwhencall.StopWhenCallAudioFocus$sam$i$android_media_AudioManager_OnAudioFocusChangeListener$0@682fee7
Please help me check it. Thanks
@vinh-savvycom can you paste your open method here ?
@kalismeras61 here is code init AssetsAudioPlayerGroup
AudioPlayer() {
playerGroup = AssetsAudioPlayerGroup(
updateNotification: (player, audios) async {
return PlayerGroupMetas(
title: currentSong.title,
subTitle: currentSong.categoryName,
image: MetasImage.network(
getUrlFromServer(currentSong.thumb.path, currentSong.thumb.uuid)),
);
},
respectSilentMode: true,
showNotification: true,
notificationStopEnabled: false,
onNotificationPause: (player, audios) {
togglePlay();
},
onNotificationPlay: (player, audios) {
togglePlay();
},
);
}
and here sample code add audio and play
Audio audio = Audio.network(
getMediaURLFromServer(soundData.path, soundData.uuid),
metas: Metas(
title: song.title,
album: song.categoryName,
image: MetasImage.network(
getUrlFromServer(song.thumb.path, song.thumb.uuid),
),
),
);
playerGroup.add(
audio,
volume: soundData.fileVolume / 100.0,
loopMode: LoopMode.single,
);
I used this command for play sound
playerGroup.playOrPause();
I have issue on Android real device and debug mode.
Thanks
Flutter Version
My version : 1.17.1
Lib Version
My version : 1.6.0+4
Platform (Android / iOS / web) + version
Platform : Android (iOS not tested) Device Model: OnePlus 8 Pro (IN2020) / OnePlus 6T (A6010)
Describe the bug
When a flutter app implemented this package (e.g. just import it), start the app will pause the current playing audio (Music that was playing).
Step to reproduce
assets_audio_player: ^1.6.0+4
intopubspec.yaml
.