Closed dupuisdavid closed 5 years ago
For which platform are you curious about?
Android and iOS.
I would draw your attention to the MediaNotificationManagerImplementation classes for those platforms then: Android iOS
Within the Android class, there is a method called AddActionButtons
. You can see there that it is calling AddAction
on the NotificationCompat.Builder
object _builder
to add either a play or pause icon (depending on mediaIsPlaying
), and previous/next icons on whether the MediaQueue
has previous or next items. More information on NotificationCompat can be found on the Android spec here and the Xamarin spec here. There is a general overview of it for Android here, though the Android MediaNotificationManagerImplementation class in this project is arguably a better method to learn about media specific notifications. For an Oreo compatible MediaNotificationManagerImplementation class, please see here.
For iOS, you can immediately see that the MediaNotificationManagerImplementation class is inheriting from the RemoteControlNotificationManager class, that handles calls to UIApplication
to either begin or end receiving remote control events. Those events should be handled by overriding UIApplication.RemoteControlReceived(UIEvent)
as mentioned in the README.md
to this project. In terms of displaying the media notification, the MediaNotificationManagerImplementation class uses the MPNowPlayingInfoCenter
object to notify iOS regarding the media content it is playing (see here). Specifically, see the CreateNowPlayingInfo
method, which populates a MPNowPlayingInfo
object with the media metadata. This page may help explain the bare minimum required, but again the code in this project is quite useful to examine. In this platform, the format of the notification and the media buttons presented on the notification are handled by iOS, ostensibly for app consistency.
Thank you!
@thomcuddihy Can you add that to the Wiki?
Um, yeah no worries @modplug. Where the wiki at?
I don't have time to fix up the missing pieces, or the other feature requests right now. I'm available for hire to fix this up and integrate changes into your project if you or anyone else wants. Drop me an email or message and we can talk about it.
Hello guys, I'm a beginner in Xamarin and I need a full sample for notification control panel like in Hanselman application. I have examined this app but don't understand how it succeeds to display play/pause/stop button controls in the notification panel. Can you help me?
Regards.