Closed manojvsp12 closed 4 years ago
I don't know how to add this, can you find some sources (swift) about it
the player i'm using : AVPlayer on ios
if it's using MPRemoteCommandCenter, it's already implemented
https://stackoverflow.com/questions/49024682/how-can-i-control-my-headset-for-my-music-player
looking at the Music.swift code :
func setupMediaPlayerNotificationView(currentSongDuration: Any) {
UIApplication.shared.beginReceivingRemoteControlEvents()
let commandCenter = MPRemoteCommandCenter.shared()
//commandCenter.playCommand.isEnabled = self.playing
self.setupNotificationView(currentSongDuration: currentSongDuration)
self.deinitMediaPlayerNotifEvent()
// Add handler for Play Command
commandCenter.playCommand.isEnabled = true
self.targets["play"] = commandCenter.playCommand.addTarget { [unowned self] event in
self.play();
return .success
}
// Add handler for Pause Command
commandCenter.pauseCommand.isEnabled = true
self.targets["pause"] = commandCenter.pauseCommand.addTarget { [unowned self] event in
self.pause();
return .success
}
// Add handler for Pause Command
commandCenter.previousTrackCommand.isEnabled = true
self.targets["prev"] = commandCenter.previousTrackCommand.addTarget { [unowned self] event in
self.channel.invokeMethod(Music.METHOD_PREV, arguments: [])
return .success
}
// Add handler for Pause Command
commandCenter.nextTrackCommand.isEnabled = true
self.targets["next"] = commandCenter.nextTrackCommand.addTarget { [unowned self] event in
self.channel.invokeMethod(Music.METHOD_NEXT, arguments: [])
return .success
}
}
I cannot try this because it's not available on simulator & I don't have any device to try
Is this support provided in Android?
I did not try it, I'll check tomorrow
I implemented it today on android, I'll push it soon before this I had to try it on ios !
the code above is already implemented on ios, I'll let user try & create an issue if this does not work
I pushed it in 1.6.0
, can you try ?
you have to set showNotification: true,
when you open your media to make it work
Android: Tried in bluetooth headset and Car with version 1.6.0. Not working.
What's you Android version ?
Android 10 Device: Oneplus 6
Also I am using livestream for playback
Ok Its the same device as me, I'll try again , it worked with my JBL Bluetooth headset (play pause)
I tried with oneplus bullets wireless, boat bluetooth headset and connected to volkswagen car media player
I tried again with another device, an external bluetooth speaker, & my oneplus 6
It's the sample main.dart, can you pull the project from the github & launch the sample, then click on "all as playlist" then try the bluetooth actions ?
I made a small fix on bluetooth play/pause (for livestream) in 1.6.0+2
maybe this will fix you issue, btw try the main.dart
you did not tell me if you opened with notification
_assetsAudioPlayer.open(Playlist(audios: audios), showNotification: true, autoStart: true);
Works on my boat bluetooth headset, play/pause works when I click play/pause in my oneplus bullets wireless but magnetic control not working and not able to control from car media
it's wierd, maybe I have to add some code to make it works everywhere, but don't know what
Noticed something. When I am running my app in debug mode (flutter run), I am able to control app using media buttons (check my previous comment) but when I build as apk for release (flutter build apk --release), install apk manually and tried to control, I am unable to control.
Oh looks wired, I'll check this !
Thanks to have noticed this
I've created https://github.com/florent37/Flutter-AssetsAudioPlayer/issues/129 for the debug/release issue
and linked to #117 which is surely the same bug, will try to find a fix soon, but it's hard to try
I pushed some code around bluetooth can you try the 1.6.3+1
?
*Describe the feature you'd like If this feature is already present please let me know.
I'd like to control AssetsAudioPlayer using media button presses from devices such as bluetooth headset, car etc.
Controlling such as play/pause/previous/next.
Thanks in advance.