This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathExtensions.cs
503 lines (392 loc) · 15 KB
/
Extensions.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
using System;
using System.Runtime.InteropServices;
using ObjCRuntime;
using Foundation;
using UIKit;
namespace Google.Cast
{
static class Helper
{
public static nuint [] GetNUintArray (NSArray nsArray)
{
var items = new nuint [nsArray.Count];
for (nuint i = 0; (int)i < items.Length; i++)
items [i] = nsArray.GetItem<NSNumber> (i).NUIntValue;
return items;
}
}
public partial class DiscoveryCriteria : NSObject
{
public DiscoveryCriteria (string [] namespaces) : base (NSObjectFlag.Empty)
{
NSString [] nsNamespaces = new NSString [namespaces.Length];
for (int i = 0; i < namespaces.Length; i++)
nsNamespaces [i] = new NSString (namespaces [i]);
var nsSet = new NSSet<NSString> (nsNamespaces);
Handle = _InitWithNamespaces (nsSet);
}
public DiscoveryCriteria (NSSet<NSString> namespaces) : base (NSObjectFlag.Empty) => Handle = _InitWithNamespaces (namespaces);
}
[Obsolete ("Implement ILoggerDelegate interface and override LogMessage method instead.")]
public class LoggerHandler : NSObject, ILoggerDelegate
{
public delegate void UserLogImplementation (string function, string message);
UserLogImplementation implementation;
public LoggerHandler (UserLogImplementation implementation)
{
this.implementation = implementation;
}
public void _Log (IntPtr function, string message)
{
var func = Marshal.PtrToStringAnsi (function);
if (implementation != null)
implementation (func, message);
}
public void SetLogImplementation (UserLogImplementation implementation)
{
this.implementation = implementation;
}
}
public partial class MediaCommon
{
// GCK_EXTERN BOOL GCKIsValidTimeInterval(NSTimeInterval timeInterval);
[DllImport ("__Internal", EntryPoint = "GCKIsValidTimeInterval")]
extern internal static bool _IsValidTimeInterval (double timeInterval);
public static bool IsValidTimeInterval (double timeInterval) => _IsValidTimeInterval (timeInterval);
}
public enum MediaInformationBuilderParameterType
{
[Obsolete ("Use the Constructor (NSUrl) or the Constructor (string, MediaInformationBuilderParameterType.IsEntity) constructors instead.")]
IsContentId,
IsEntity
}
public partial class MediaInformationBuilder : NSObject
{
[Advice ("Pass a contenId or entity value as the first param and specify the information kind with the second param.")]
public MediaInformationBuilder (string contentIdOrEntity, MediaInformationBuilderParameterType parameterType) : base (NSObjectFlag.Empty)
{
if (contentIdOrEntity == null)
throw new ArgumentNullException (nameof (contentIdOrEntity));
if (parameterType == MediaInformationBuilderParameterType.IsContentId) {
Handle = _InitWithContentId (contentIdOrEntity);
} else {
Handle = _InitWithEntity (contentIdOrEntity);
}
}
}
public partial class MediaLoadOptions
{
public nuint [] ActiveTrackIds {
get {
NSArray activeTracksIdsArray = _ActiveTrackIds;
nuint [] activeTracksIds = null;
if (activeTracksIdsArray != null)
activeTracksIds = Helper.GetNUintArray (activeTracksIdsArray);
return activeTracksIds;
}
set {
_ActiveTrackIds = value != null ? NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), value) : null;
}
}
}
public partial class MediaLoadRequestData {
public nuint [] ActiveTrackIds {
get {
NSArray activeTracksIdsArray = _ActiveTrackIds;
nuint [] activeTracksIds = null;
if (activeTracksIdsArray != null)
activeTracksIds = Helper.GetNUintArray (activeTracksIdsArray);
return activeTracksIds;
}
}
}
public partial class MediaLoadRequestDataBuilder {
public nuint [] ActiveTrackIds {
get {
NSArray activeTracksIdsArray = _ActiveTrackIds;
nuint [] activeTracksIds = null;
if (activeTracksIdsArray != null)
activeTracksIds = Helper.GetNUintArray (activeTracksIdsArray);
return activeTracksIds;
}
set {
_ActiveTrackIds = value != null ? NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), value) : null;
}
}
}
public partial class MediaQueueItem : NSObject
{
public nuint [] ActiveTrackIds {
get {
NSArray activeTracksIdsArray = _ActiveTrackIds;
nuint [] activeTracksIds = null;
if (activeTracksIdsArray != null)
activeTracksIds = Helper.GetNUintArray (activeTracksIdsArray);
return activeTracksIds;
}
}
public MediaQueueItem (MediaInformation mediaInformation, bool autoplay, double startTime, double preloadTime, nuint [] activeTrackIds, NSObject customData) : base (NSObjectFlag.Empty)
{
if (mediaInformation == null)
throw new ArgumentNullException (nameof (mediaInformation));
var activeTracksIdsObjC = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), activeTrackIds);
Handle = _InitWithMediaInformation (mediaInformation, autoplay, startTime, preloadTime, activeTracksIdsObjC, customData);
}
[DesignatedInitializer]
public MediaQueueItem (MediaInformation mediaInformation, bool autoplay, double startTime, double playbackDuration, double preloadTime, nuint [] activeTrackIds, NSObject customData) : base (NSObjectFlag.Empty)
{
if (mediaInformation == null)
throw new ArgumentNullException (nameof (mediaInformation));
var activeTracksIdsObjC = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), activeTrackIds);
Handle = _InitWithMediaInformation (mediaInformation, autoplay, startTime, playbackDuration, preloadTime, activeTracksIdsObjC, customData);
}
}
public partial class MediaQueueItemBuilder
{
public nuint [] ActiveTrackIds {
get {
NSArray activeTracksIdsArray = _ActiveTrackIds;
nuint [] activeTracksIds = null;
if (activeTracksIdsArray != null)
activeTracksIds = Helper.GetNUintArray (activeTracksIdsArray);
return activeTracksIds;
}
set {
_ActiveTrackIds = value != null ? NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), value) : null;
}
}
}
public partial class MediaStatus
{
public nuint [] ActiveTrackIds {
get {
NSArray activeTracksIdsArray = _ActiveTrackIds;
nuint [] activeTracksIds = null;
if (activeTracksIdsArray != null)
activeTracksIds = Helper.GetNUintArray (activeTracksIdsArray);
return activeTracksIds;
}
}
}
public partial class RemoteMediaClient
{
[Obsolete ("Use LoadMedia (MediaLoadRequestData) overloaded method instead.")]
public Request LoadMedia (MediaInformation mediaInfo, bool autoplay, double playPosition, nuint [] activeTrackIds)
{
if (mediaInfo == null)
throw new ArgumentNullException (nameof (mediaInfo));
NSArray activeTrackIdsArray = null;
if (activeTrackIds != null)
activeTrackIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), activeTrackIds);
return _LoadMedia (mediaInfo, autoplay, playPosition, activeTrackIdsArray);
}
[Obsolete ("Use LoadMedia (MediaInformation, MediaLoadOptions) overloaded method instead.")]
public Request LoadMedia (MediaInformation mediaInfo, bool autoplay, double playPosition, nuint [] activeTrackIds, NSObject customData)
{
if (mediaInfo == null)
throw new ArgumentNullException (nameof (mediaInfo));
NSArray activeTrackIdsArray = null;
if (activeTrackIds != null)
activeTrackIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), activeTrackIds);
return _LoadMedia (mediaInfo, autoplay, playPosition, activeTrackIdsArray, customData);
}
public Request SetActiveTrackIds (nuint [] activeTrackIds)
{
NSArray activeTrackIdsArray = null;
if (activeTrackIds != null)
activeTrackIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), activeTrackIds);
return _SetActiveTrackIds (activeTrackIdsArray);
}
public Request QueueFetchItems (nuint [] queueItemIds)
{
if (queueItemIds == null)
throw new ArgumentNullException (nameof (queueItemIds));
NSArray queueItemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), queueItemIds);
return _QueueFetchItems (queueItemIdsArray);
}
public Request QueueRemoveItems (nuint [] itemIds)
{
if (itemIds == null)
throw new ArgumentNullException (nameof (itemIds));
NSArray itemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), itemIds);
return _QueueRemoveItems (itemIdsArray);
}
public Request QueueRemoveItems (nuint [] itemIds, NSObject customData)
{
if (itemIds == null)
throw new ArgumentNullException (nameof (itemIds));
NSArray itemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), itemIds);
return _QueueRemoveItems (itemIdsArray, customData);
}
public Request QueueReorderItems (nuint [] queueItemIds, nuint beforeItemId)
{
if (queueItemIds == null)
throw new ArgumentNullException (nameof (queueItemIds));
NSArray queueItemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), queueItemIds);
return _QueueReorderItems (queueItemIdsArray, beforeItemId);
}
public Request QueueReorderItems (nuint [] queueItemIds, nuint beforeItemId, NSObject customData)
{
if (queueItemIds == null)
throw new ArgumentNullException (nameof (queueItemIds));
NSArray queueItemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), queueItemIds);
return _QueueReorderItems (queueItemIdsArray, beforeItemId, customData);
}
}
public static partial class RemoteMediaClient_Protected
{
public static void NotifyDidReceiveQueueItemIds (this RemoteMediaClient instance, nuint [] itemIds)
{
if (itemIds == null)
throw new ArgumentNullException (nameof (itemIds));
NSArray itemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), itemIds);
_NotifyDidReceiveQueueItemIds (instance, itemIdsArray);
}
public static void NotifyDidInsertQueueItems (this RemoteMediaClient instance, nuint [] itemIds, nuint beforeItemId)
{
if (itemIds == null)
throw new ArgumentNullException (nameof (itemIds));
NSArray itemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), itemIds);
_NotifyDidInsertQueueItems (instance, itemIdsArray, beforeItemId);
}
public static void NotifyDidUpdateQueueItems (this RemoteMediaClient instance, nuint [] itemIds)
{
if (itemIds == null)
throw new ArgumentNullException (nameof (itemIds));
NSArray itemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), itemIds);
_NotifyDidUpdateQueueItems (instance, itemIdsArray);
}
public static void NotifyDidRemoveQueueItems (this RemoteMediaClient instance, nuint [] itemIds)
{
if (itemIds == null)
throw new ArgumentNullException (nameof (itemIds));
NSArray itemIdsArray = NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), itemIds);
_NotifyDidRemoveQueueItems (instance, itemIdsArray);
}
}
public partial class UIDeviceVolumeController
{
static UIControlState? muteOff;
[Obsolete ("Use MuteOffState property with UIMultistateButton class.")]
public static UIControlState MuteOff {
get {
if (muteOff == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "GCKUIControlStateMuteOff");
muteOff = (UIControlState)Marshal.PtrToStructure (ptr, typeof (UIControlState));
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return muteOff.Value;
}
}
static UIControlState? muteOn;
[Obsolete ("Use MuteOnState property with UIMultistateButton class.")]
public static UIControlState MuteOn {
get {
if (muteOn == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "GCKUIControlStateMuteOn");
muteOn = (UIControlState)Marshal.PtrToStructure (ptr, typeof (UIControlState));
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return muteOn.Value;
}
}
}
public partial class UIMediaController
{
static UIControlState? repeatOff;
[Obsolete ("Use RepeatOffState property with UIMultistateButton class.")]
public static UIControlState RepeatOff {
get {
if (repeatOff == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "GCKUIControlStateRepeatOff");
repeatOff = (UIControlState)Marshal.PtrToStructure (ptr, typeof (UIControlState));
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return repeatOff.Value;
}
}
static UIControlState? repeatAll;
[Obsolete ("Use RepeatAllState property with UIMultistateButton class.")]
public static UIControlState RepeatAll {
get {
if (repeatAll == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "GCKUIControlStateRepeatAll");
repeatAll = (UIControlState)Marshal.PtrToStructure (ptr, typeof (UIControlState));
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return repeatAll.Value;
}
}
static UIControlState? repeatSingle;
[Obsolete ("Use RepeatSingleState property with UIMultistateButton class.")]
public static UIControlState RepeatSingle {
get {
if (repeatSingle == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "GCKUIControlStateRepeatSingle");
repeatSingle = (UIControlState)Marshal.PtrToStructure (ptr, typeof (UIControlState));
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return repeatSingle.Value;
}
}
static UIControlState? play;
[Obsolete ("Use PlayState property with UIMultistateButton class.")]
public static UIControlState Play {
get {
if (play == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "GCKUIControlStatePlay");
play = (UIControlState)Marshal.PtrToStructure (ptr, typeof (UIControlState));
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return play.Value;
}
}
static UIControlState? pause;
[Obsolete ("Use PauseState property with UIMultistateButton class.")]
public static UIControlState Pause {
get {
if (pause == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "GCKUIControlStatePause");
pause = (UIControlState)Marshal.PtrToStructure (ptr, typeof (UIControlState));
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return pause.Value;
}
}
static UIControlState? shuffle;
[Obsolete ("Use ShuffleState property with UIMultistateButton class.")]
public static UIControlState Shuffle {
get {
if (shuffle == null) {
IntPtr RTLD_MAIN_ONLY = Dlfcn.dlopen (null, 0);
IntPtr ptr = Dlfcn.dlsym (RTLD_MAIN_ONLY, "GCKUIControlStateShuffle");
shuffle = (UIControlState)Marshal.PtrToStructure (ptr, typeof (UIControlState));
Dlfcn.dlclose (RTLD_MAIN_ONLY);
}
return shuffle.Value;
}
}
}
public partial class UIMediaTrackSelectionViewController
{
nuint [] SelectedTrackIds {
get {
NSArray selectedTrackIdsArray = _SelectedTrackIds;
nuint [] selectedTrackIds = null;
if (selectedTrackIdsArray != null)
selectedTrackIds = Helper.GetNUintArray (selectedTrackIdsArray);
return selectedTrackIds;
}
set {
_SelectedTrackIds = value != null ? NSArray.FromNSObjects ((arg) => NSNumber.FromNUInt (arg), value) : null;
}
}
}
}