-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCastOptionsProvider.cs
69 lines (61 loc) · 2.4 KB
/
CastOptionsProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using Android.Content;
using Android.Gms.Cast;
using Android.Gms.Cast.Framework;
using Android.Gms.Cast.Framework.Media;
using Android.Gms.Cast.Framework.Media.Widget;
using Android.Gms.Common.Images;
using Android.Runtime;
namespace XamCast.Droid
{
[Register("XamCast/Android/CastOptionsProvider")]
public class CastOptionsProvider : Java.Lang.Object, IOptionsProvider
{
public IList<SessionProvider> GetAdditionalSessionProviders(Context appContext)
{
return null;
}
public CastOptions GetCastOptions(Context appContext)
{
var notificationOptions = new NotificationOptions.Builder()
.SetActions(new List<string>() { MediaIntentReceiver.ActionSkipNext, MediaIntentReceiver.ActionTogglePlayback, MediaIntentReceiver.ActionStopCasting }, new int[] { 1, 2 })
.SetTargetActivityClassName("com.google.android.gms.cast.framework.media.widget.ExpandedControllerActivity")
.Build();
var mediaOptions = new CastMediaOptions.Builder()
.SetImagePicker(new ImagePickerImpl())
.SetNotificationOptions(notificationOptions)
.SetExpandedControllerActivityClassName("com.google.android.gms.cast.framework.media.widget.ExpandedControllerActivity")
.Build();
var launchOptions = new LaunchOptions.Builder()
.Build();
var castOptions = new CastOptions.Builder()
.SetLaunchOptions(launchOptions)
.SetReceiverApplicationId("0A6928D1")
.SetCastMediaOptions(mediaOptions)
.Build();
return castOptions;
}
}
public partial class ImagePickerImpl : ImagePicker
{
public override WebImage OnPickImage(MediaMetadata mediaMetadata, ImageHints hints)
{
var type = hints.Type;
if ((mediaMetadata == null) || !mediaMetadata.HasImages)
{
return null;
}
var images = mediaMetadata.Images;
if (images.Count == 1)
return images[0];
else
{
if (type == ImagePicker.ImageTypeMediaRouteControllerDialogBackground)
return images[0];
else
return images[1];
}
}
}
}