Reputation: 1158
I am using plugin in xamarin to play songs on iOS and Android device which is working out perfectly.My problem is that I am unable to find way to listen to next and previous button press in control centre.
I have read blog for reference,but it doesn't seem to provide enough info to achieve solution.
Upvotes: 1
Views: 500
Reputation: 2258
You can find the related information in its README.md.
- If you want to enable RemoteControl features, you will have to override
UIApplication.RemoteControlReceived(UIEvent)
and forward the event to theMediaManagerImplementation.MediaRemoteControl.RemoteControlReceived(UIEvent)
method. See the sample application for more details.
Follow these steps:
Create a SampleApplication class inherit from UIApplication To implement RemoteControlReceived(UIEvent)
as its sample code, like this:
using Foundation;
using Plugin.MediaManager;
using UIKit;
namespace MediaSample.iOS
{
[Register("SampleApplication")]
public class SampleApplication: UIApplication
{
private MediaManagerImplementation MediaManager => (MediaManagerImplementation) CrossMediaManager.Current;
public override void RemoteControlReceived(UIEvent uiEvent)
{
MediaManager.MediaRemoteControl.RemoteControlReceived(uiEvent);
}
}
}
MediaManager.MediaRemoteControl.RemoteControlReceived(uiEvent)
helps you to handle the next/previous/pause/play events. To see how it works, you can refer here.
Don't foget to add the SampleApplication to UIApplication.Main()
in Main.cs like this:
UIApplication.Main(args, "SampleApplication", "AppDelegate");
Upvotes: 1