From 6698c34946f8ec0deabfe552deb5ea1a2dc0e02e Mon Sep 17 00:00:00 2001
From: Tristan Roux
Date: Wed, 12 Dec 2018 18:03:59 +0100
Subject: [PATCH] Cas notification added.
---
.../Resources/Portable Class/CastProvider.cs | 17 ++++++++++++++---
.../Resources/Portable Class/MusicPlayer.cs | 1 -
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/MusicApp/Resources/Portable Class/CastProvider.cs b/MusicApp/Resources/Portable Class/CastProvider.cs
index bc0f249..8001180 100644
--- a/MusicApp/Resources/Portable Class/CastProvider.cs
+++ b/MusicApp/Resources/Portable Class/CastProvider.cs
@@ -12,12 +12,23 @@ namespace MusicApp
{
public CastOptions GetCastOptions(Context appContext)
{
- //NotificationOptions notification = new NotificationOptions.Builder()
- // .
- //Customise (or disable) build in notification here.
+ NotificationOptions notification = new NotificationOptions.Builder()
+ .SetActions(new List { MediaIntentReceiver.ActionSkipPrev, MediaIntentReceiver.ActionTogglePlayback, MediaIntentReceiver.ActionSkipNext }, new int[] { 1 })
+ .SetTargetActivityClassName(Java.Lang.Class.FromType(typeof(MainActivity)).Name)
+ .SetSmallIconDrawableResId(Resource.Drawable.MusicIcon)
+ .SetSkipPrevDrawableResId(Resource.Drawable.SkipPrevious)
+ .SetPauseDrawableResId(Resource.Drawable.Pause)
+ .SetPlayDrawableResId(Resource.Drawable.Play)
+ .SetSkipNextDrawableResId(Resource.Drawable.SkipNext)
+ .Build();
+
+ CastMediaOptions media = new CastMediaOptions.Builder()
+ .SetNotificationOptions(notification)
+ .Build();
CastOptions options = new CastOptions.Builder()
.SetReceiverApplicationId(CastMediaControlIntent.DefaultMediaReceiverApplicationId)
+ .SetCastMediaOptions(media)
.SetStopReceiverApplicationWhenEndingSession(true)
.Build();
return options;
diff --git a/MusicApp/Resources/Portable Class/MusicPlayer.cs b/MusicApp/Resources/Portable Class/MusicPlayer.cs
index 236bd85..32424e2 100644
--- a/MusicApp/Resources/Portable Class/MusicPlayer.cs
+++ b/MusicApp/Resources/Portable Class/MusicPlayer.cs
@@ -23,7 +23,6 @@ using Com.Google.Android.Exoplayer2.Source.Hls;
using Com.Google.Android.Exoplayer2.Trackselection;
using Com.Google.Android.Exoplayer2.Upstream;
using Com.Google.Android.Exoplayer2.Util;
-using Java.Lang;
using MusicApp.Resources.values;
using SQLite;
using Square.Picasso;