forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractive_media_ads.g.dart
More file actions
4908 lines (4635 loc) · 193 KB
/
Copy pathinteractive_media_ads.g.dart
File metadata and controls
4908 lines (4635 loc) · 193 KB
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
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.2.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'package:flutter/foundation.dart'
show ReadBuffer, WriteBuffer, immutable, protected;
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;
PlatformException _createConnectionError(String channelName) {
return PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel: "$channelName".',
);
}
List<Object?> wrapResponse(
{Object? result, PlatformException? error, bool empty = false}) {
if (empty) {
return <Object?>[];
}
if (error == null) {
return <Object?>[result];
}
return <Object?>[error.code, error.message, error.details];
}
/// An immutable object that serves as the base class for all ProxyApis and
/// can provide functional copies of itself.
///
/// All implementers are expected to be [immutable] as defined by the annotation
/// and override [pigeon_copy] returning an instance of itself.
@immutable
abstract class PigeonInternalProxyApiBaseClass {
/// Construct a [PigeonInternalProxyApiBaseClass].
PigeonInternalProxyApiBaseClass({
this.pigeon_binaryMessenger,
PigeonInstanceManager? pigeon_instanceManager,
}) : pigeon_instanceManager =
pigeon_instanceManager ?? PigeonInstanceManager.instance;
/// Sends and receives binary data across the Flutter platform barrier.
///
/// If it is null, the default BinaryMessenger will be used, which routes to
/// the host platform.
@protected
final BinaryMessenger? pigeon_binaryMessenger;
/// Maintains instances stored to communicate with native language objects.
@protected
final PigeonInstanceManager pigeon_instanceManager;
/// Instantiates and returns a functionally identical object to oneself.
///
/// Outside of tests, this method should only ever be called by
/// [PigeonInstanceManager].
///
/// Subclasses should always override their parent's implementation of this
/// method.
@protected
PigeonInternalProxyApiBaseClass pigeon_copy();
}
/// Maintains instances used to communicate with the native objects they
/// represent.
///
/// Added instances are stored as weak references and their copies are stored
/// as strong references to maintain access to their variables and callback
/// methods. Both are stored with the same identifier.
///
/// When a weak referenced instance becomes inaccessible,
/// [onWeakReferenceRemoved] is called with its associated identifier.
///
/// If an instance is retrieved and has the possibility to be used,
/// (e.g. calling [getInstanceWithWeakReference]) a copy of the strong reference
/// is added as a weak reference with the same identifier. This prevents a
/// scenario where the weak referenced instance was released and then later
/// returned by the host platform.
class PigeonInstanceManager {
/// Constructs a [PigeonInstanceManager].
PigeonInstanceManager({required void Function(int) onWeakReferenceRemoved}) {
this.onWeakReferenceRemoved = (int identifier) {
_weakInstances.remove(identifier);
onWeakReferenceRemoved(identifier);
};
_finalizer = Finalizer<int>(this.onWeakReferenceRemoved);
}
// Identifiers are locked to a specific range to avoid collisions with objects
// created simultaneously by the host platform.
// Host uses identifiers >= 2^16 and Dart is expected to use values n where,
// 0 <= n < 2^16.
static const int _maxDartCreatedIdentifier = 65536;
/// The default [PigeonInstanceManager] used by ProxyApis.
///
/// On creation, this manager makes a call to clear the native
/// InstanceManager. This is to prevent identifier conflicts after a host
/// restart.
static final PigeonInstanceManager instance = _initInstance();
// Expando is used because it doesn't prevent its keys from becoming
// inaccessible. This allows the manager to efficiently retrieve an identifier
// of an instance without holding a strong reference to that instance.
//
// It also doesn't use `==` to search for identifiers, which would lead to an
// infinite loop when comparing an object to its copy. (i.e. which was caused
// by calling instanceManager.getIdentifier() inside of `==` while this was a
// HashMap).
final Expando<int> _identifiers = Expando<int>();
final Map<int, WeakReference<PigeonInternalProxyApiBaseClass>>
_weakInstances = <int, WeakReference<PigeonInternalProxyApiBaseClass>>{};
final Map<int, PigeonInternalProxyApiBaseClass> _strongInstances =
<int, PigeonInternalProxyApiBaseClass>{};
late final Finalizer<int> _finalizer;
int _nextIdentifier = 0;
/// Called when a weak referenced instance is removed by [removeWeakReference]
/// or becomes inaccessible.
late final void Function(int) onWeakReferenceRemoved;
static PigeonInstanceManager _initInstance() {
WidgetsFlutterBinding.ensureInitialized();
final _PigeonInternalInstanceManagerApi api =
_PigeonInternalInstanceManagerApi();
// Clears the native `PigeonInstanceManager` on the initial use of the Dart one.
api.clear();
final PigeonInstanceManager instanceManager = PigeonInstanceManager(
onWeakReferenceRemoved: (int identifier) {
api.removeStrongReference(identifier);
},
);
_PigeonInternalInstanceManagerApi.setUpMessageHandlers(
instanceManager: instanceManager);
BaseDisplayContainer.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdDisplayContainer.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdsLoader.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdsManagerLoadedEvent.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdErrorEvent.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdError.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdsRequest.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
ContentProgressProvider.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdsManager.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
BaseManager.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdEvent.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
ImaSdkFactory.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
ImaSdkSettings.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
VideoProgressUpdate.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdMediaInfo.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdPodInfo.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
FrameLayout.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
ViewGroup.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
VideoView.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
View.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager);
MediaPlayer.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
VideoAdPlayerCallback.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
VideoAdPlayer.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdsLoadedListener.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdErrorListener.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
AdEventListener.pigeon_setUpMessageHandlers(
pigeon_instanceManager: instanceManager);
return instanceManager;
}
/// Adds a new instance that was instantiated by Dart.
///
/// In other words, Dart wants to add a new instance that will represent
/// an object that will be instantiated on the host platform.
///
/// Throws assertion error if the instance has already been added.
///
/// Returns the randomly generated id of the [instance] added.
int addDartCreatedInstance(PigeonInternalProxyApiBaseClass instance) {
final int identifier = _nextUniqueIdentifier();
_addInstanceWithIdentifier(instance, identifier);
return identifier;
}
/// Removes the instance, if present, and call [onWeakReferenceRemoved] with
/// its identifier.
///
/// Returns the identifier associated with the removed instance. Otherwise,
/// `null` if the instance was not found in this manager.
///
/// This does not remove the strong referenced instance associated with
/// [instance]. This can be done with [remove].
int? removeWeakReference(PigeonInternalProxyApiBaseClass instance) {
final int? identifier = getIdentifier(instance);
if (identifier == null) {
return null;
}
_identifiers[instance] = null;
_finalizer.detach(instance);
onWeakReferenceRemoved(identifier);
return identifier;
}
/// Removes [identifier] and its associated strongly referenced instance, if
/// present, from the manager.
///
/// Returns the strong referenced instance associated with [identifier] before
/// it was removed. Returns `null` if [identifier] was not associated with
/// any strong reference.
///
/// This does not remove the weak referenced instance associated with
/// [identifier]. This can be done with [removeWeakReference].
T? remove<T extends PigeonInternalProxyApiBaseClass>(int identifier) {
return _strongInstances.remove(identifier) as T?;
}
/// Retrieves the instance associated with identifier.
///
/// The value returned is chosen from the following order:
///
/// 1. A weakly referenced instance associated with identifier.
/// 2. If the only instance associated with identifier is a strongly
/// referenced instance, a copy of the instance is added as a weak reference
/// with the same identifier. Returning the newly created copy.
/// 3. If no instance is associated with identifier, returns null.
///
/// This method also expects the host `InstanceManager` to have a strong
/// reference to the instance the identifier is associated with.
T? getInstanceWithWeakReference<T extends PigeonInternalProxyApiBaseClass>(
int identifier) {
final PigeonInternalProxyApiBaseClass? weakInstance =
_weakInstances[identifier]?.target;
if (weakInstance == null) {
final PigeonInternalProxyApiBaseClass? strongInstance =
_strongInstances[identifier];
if (strongInstance != null) {
final PigeonInternalProxyApiBaseClass copy =
strongInstance.pigeon_copy();
_identifiers[copy] = identifier;
_weakInstances[identifier] =
WeakReference<PigeonInternalProxyApiBaseClass>(copy);
_finalizer.attach(copy, identifier, detach: copy);
return copy as T;
}
return strongInstance as T?;
}
return weakInstance as T;
}
/// Retrieves the identifier associated with instance.
int? getIdentifier(PigeonInternalProxyApiBaseClass instance) {
return _identifiers[instance];
}
/// Adds a new instance that was instantiated by the host platform.
///
/// In other words, the host platform wants to add a new instance that
/// represents an object on the host platform. Stored with [identifier].
///
/// Throws assertion error if the instance or its identifier has already been
/// added.
///
/// Returns unique identifier of the [instance] added.
void addHostCreatedInstance(
PigeonInternalProxyApiBaseClass instance, int identifier) {
_addInstanceWithIdentifier(instance, identifier);
}
void _addInstanceWithIdentifier(
PigeonInternalProxyApiBaseClass instance, int identifier) {
assert(!containsIdentifier(identifier));
assert(getIdentifier(instance) == null);
assert(identifier >= 0);
_identifiers[instance] = identifier;
_weakInstances[identifier] =
WeakReference<PigeonInternalProxyApiBaseClass>(instance);
_finalizer.attach(instance, identifier, detach: instance);
final PigeonInternalProxyApiBaseClass copy = instance.pigeon_copy();
_identifiers[copy] = identifier;
_strongInstances[identifier] = copy;
}
/// Whether this manager contains the given [identifier].
bool containsIdentifier(int identifier) {
return _weakInstances.containsKey(identifier) ||
_strongInstances.containsKey(identifier);
}
int _nextUniqueIdentifier() {
late int identifier;
do {
identifier = _nextIdentifier;
_nextIdentifier = (_nextIdentifier + 1) % _maxDartCreatedIdentifier;
} while (containsIdentifier(identifier));
return identifier;
}
}
/// Generated API for managing the Dart and native `PigeonInstanceManager`s.
class _PigeonInternalInstanceManagerApi {
/// Constructor for [_PigeonInternalInstanceManagerApi].
_PigeonInternalInstanceManagerApi({BinaryMessenger? binaryMessenger})
: pigeonVar_binaryMessenger = binaryMessenger;
final BinaryMessenger? pigeonVar_binaryMessenger;
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
static void setUpMessageHandlers({
bool pigeon_clearHandlers = false,
BinaryMessenger? binaryMessenger,
PigeonInstanceManager? instanceManager,
}) {
{
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (pigeon_clearHandlers) {
pigeonVar_channel.setMessageHandler(null);
} else {
pigeonVar_channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_identifier = (args[0] as int?);
assert(arg_identifier != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference was null, expected non-null int.');
try {
(instanceManager ?? PigeonInstanceManager.instance)
.remove(arg_identifier!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
}
Future<void> removeStrongReference(int identifier) async {
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(<Object?>[identifier]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
/// Clear the native `PigeonInstanceManager`.
///
/// This is typically called after a hot restart.
Future<void> clear() async {
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.clear';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(null) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
}
class _PigeonInternalProxyApiBaseCodec extends _PigeonCodec {
const _PigeonInternalProxyApiBaseCodec(this.instanceManager);
final PigeonInstanceManager instanceManager;
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is PigeonInternalProxyApiBaseClass) {
buffer.putUint8(128);
writeValue(buffer, instanceManager.getIdentifier(value));
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
return instanceManager
.getInstanceWithWeakReference(readValue(buffer)! as int);
default:
return super.readValueOfType(type, buffer);
}
}
}
/// The types of error that can be encountered.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.AdErrorCode.html.
enum AdErrorCode {
/// Ads player was not provided.
adsPlayerWasNotProvided,
/// There was a problem requesting ads from the server.
adsRequestNetworkError,
/// A companion ad failed to load or render.
companionAdLoadingFailed,
/// There was a problem requesting ads from the server.
failedToRequestAds,
/// An error internal to the SDK occurred.
internalError,
/// Invalid arguments were provided to SDK methods.
invalidArguments,
/// An overlay ad failed to load.
overlayAdLoadingFailed,
/// An overlay ad failed to render.
overlayAdPlayingFailed,
/// Ads list was returned but ContentProgressProvider was not configured.
playlistNoContentTracking,
/// Ads loader sent ads loaded event when it was not expected.
unexpectedAdsLoadedEvent,
/// The ad response was not understood and cannot be parsed.
unknownAdResponse,
/// An unexpected error occurred and the cause is not known.
unknownError,
/// No assets were found in the VAST ad response.
vastAssetNotFound,
/// A VAST response containing a single `<VAST>` tag with no child tags.
vastEmptyResponse,
/// Assets were found in the VAST ad response for a linear ad, but none of
/// them matched the video player's capabilities.
vastLinearAssetMismatch,
/// At least one VAST wrapper ad loaded successfully and a subsequent wrapper
/// or inline ad load has timed out.
vastLoadTimeout,
/// The ad response was not recognized as a valid VAST ad.
vastMalformedResponse,
/// Failed to load media assets from a VAST response.
vastMediaLoadTimeout,
/// Assets were found in the VAST ad response for a nonlinear ad, but none of
/// them matched the video player's capabilities.
vastNonlinearAssetMismatch,
/// No Ads VAST response after one or more wrappers.
vastNoAdsAfterWrapper,
/// The maximum number of VAST wrapper redirects has been reached.
vastTooManyRedirects,
/// Trafficking error.
///
/// Video player received an ad type that it was not expecting and/or cannot
/// display.
vastTraffickingError,
/// There was an error playing the video ad.
videoPlayError,
/// The error code is not recognized by this wrapper.
unknown,
}
/// Specifies when the error was encountered, during either ad loading or playback.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.AdErrorType.html.
enum AdErrorType {
/// Indicates that the error was encountered when the ad was being loaded.
load,
/// Indicates that the error was encountered after the ad loaded, during ad play.
play,
/// The error is not recognized by this wrapper.
unknown,
}
/// Types of events that can occur during ad playback.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventType.html.
enum AdEventType {
/// Fired when an ad break in a stream ends.
adBreakEnded,
/// Fired when an ad break will not play back any ads.
adBreakFetchError,
/// Fired when an ad break is ready from VMAP or ad rule ads.
adBreakReady,
/// Fired when an ad break in a stream starts.
adBreakStarted,
/// Fired when playback stalls while the ad buffers.
adBuffering,
/// Fired when an ad period in a stream ends.
adPeriodEnded,
/// Fired when an ad period in a stream starts.
adPeriodStarted,
/// Fired to inform of ad progress and can be used by publisher to display a
/// countdown timer.
adProgress,
/// Fired when the ads manager is done playing all the valid ads in the ads
/// response, or when the response doesn't return any valid ads.
allAdsCompleted,
/// Fired when an ad is clicked.
clicked,
/// Fired when an ad completes playing.
completed,
/// Fired when content should be paused.
contentPauseRequested,
/// Fired when content should be resumed.
contentResumeRequested,
/// Fired when VOD stream cuepoints have changed.
cuepointsChanged,
/// Fired when the ad playhead crosses first quartile.
firstQuartile,
/// The user has closed the icon fallback image dialog.
iconFallbackImageClosed,
/// The user has tapped an ad icon.
iconTapped,
/// Fired when the VAST response has been received.
loaded,
/// Fired to enable the SDK to communicate a message to be logged, which is
/// stored in adData.
log,
/// Fired when the ad playhead crosses midpoint.
midpoint,
/// Fired when an ad is paused.
paused,
/// Fired when an ad is resumed.
resumed,
/// Fired when an ad changes its skippable state.
skippableStateChanged,
/// Fired when an ad was skipped.
skipped,
/// Fired when an ad starts playing.
started,
/// Fired when a non-clickthrough portion of a video ad is clicked.
tapped,
/// Fired when the ad playhead crosses third quartile.
thirdQuartile,
/// The event type is not recognized by this wrapper.
unknown,
}
class _PigeonCodec extends StandardMessageCodec {
const _PigeonCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is int) {
buffer.putUint8(4);
buffer.putInt64(value);
} else if (value is AdErrorCode) {
buffer.putUint8(129);
writeValue(buffer, value.index);
} else if (value is AdErrorType) {
buffer.putUint8(130);
writeValue(buffer, value.index);
} else if (value is AdEventType) {
buffer.putUint8(131);
writeValue(buffer, value.index);
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 129:
final int? value = readValue(buffer) as int?;
return value == null ? null : AdErrorCode.values[value];
case 130:
final int? value = readValue(buffer) as int?;
return value == null ? null : AdErrorType.values[value];
case 131:
final int? value = readValue(buffer) as int?;
return value == null ? null : AdEventType.values[value];
default:
return super.readValueOfType(type, buffer);
}
}
}
/// A base class for more specialized container interfaces.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseDisplayContainer.html.
class BaseDisplayContainer extends PigeonInternalProxyApiBaseClass {
/// Constructs [BaseDisplayContainer] without creating the associated native object.
///
/// This should only be used by subclasses created by this library or to
/// create copies for an [PigeonInstanceManager].
@protected
BaseDisplayContainer.pigeon_detached({
super.pigeon_binaryMessenger,
super.pigeon_instanceManager,
});
static void pigeon_setUpMessageHandlers({
bool pigeon_clearHandlers = false,
BinaryMessenger? pigeon_binaryMessenger,
PigeonInstanceManager? pigeon_instanceManager,
BaseDisplayContainer Function()? pigeon_newInstance,
}) {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_PigeonInternalProxyApiBaseCodec(
pigeon_instanceManager ?? PigeonInstanceManager.instance);
final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger;
{
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (pigeon_clearHandlers) {
pigeonVar_channel.setMessageHandler(null);
} else {
pigeonVar_channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_pigeon_instanceIdentifier = (args[0] as int?);
assert(arg_pigeon_instanceIdentifier != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance was null, expected non-null int.');
try {
(pigeon_instanceManager ?? PigeonInstanceManager.instance)
.addHostCreatedInstance(
pigeon_newInstance?.call() ??
BaseDisplayContainer.pigeon_detached(
pigeon_binaryMessenger: pigeon_binaryMessenger,
pigeon_instanceManager: pigeon_instanceManager,
),
arg_pigeon_instanceIdentifier!,
);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
}
@override
BaseDisplayContainer pigeon_copy() {
return BaseDisplayContainer.pigeon_detached(
pigeon_binaryMessenger: pigeon_binaryMessenger,
pigeon_instanceManager: pigeon_instanceManager,
);
}
}
/// A container in which to display the ads.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdDisplayContainer.
class AdDisplayContainer extends PigeonInternalProxyApiBaseClass
implements BaseDisplayContainer {
/// Constructs [AdDisplayContainer] without creating the associated native object.
///
/// This should only be used by subclasses created by this library or to
/// create copies for an [PigeonInstanceManager].
@protected
AdDisplayContainer.pigeon_detached({
super.pigeon_binaryMessenger,
super.pigeon_instanceManager,
});
static void pigeon_setUpMessageHandlers({
bool pigeon_clearHandlers = false,
BinaryMessenger? pigeon_binaryMessenger,
PigeonInstanceManager? pigeon_instanceManager,
AdDisplayContainer Function()? pigeon_newInstance,
}) {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_PigeonInternalProxyApiBaseCodec(
pigeon_instanceManager ?? PigeonInstanceManager.instance);
final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger;
{
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (pigeon_clearHandlers) {
pigeonVar_channel.setMessageHandler(null);
} else {
pigeonVar_channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_pigeon_instanceIdentifier = (args[0] as int?);
assert(arg_pigeon_instanceIdentifier != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance was null, expected non-null int.');
try {
(pigeon_instanceManager ?? PigeonInstanceManager.instance)
.addHostCreatedInstance(
pigeon_newInstance?.call() ??
AdDisplayContainer.pigeon_detached(
pigeon_binaryMessenger: pigeon_binaryMessenger,
pigeon_instanceManager: pigeon_instanceManager,
),
arg_pigeon_instanceIdentifier!,
);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
}
@override
AdDisplayContainer pigeon_copy() {
return AdDisplayContainer.pigeon_detached(
pigeon_binaryMessenger: pigeon_binaryMessenger,
pigeon_instanceManager: pigeon_instanceManager,
);
}
}
/// An object which allows publishers to request ads from ad servers or a
/// dynamic ad insertion stream.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.
class AdsLoader extends PigeonInternalProxyApiBaseClass {
/// Constructs [AdsLoader] without creating the associated native object.
///
/// This should only be used by subclasses created by this library or to
/// create copies for an [PigeonInstanceManager].
@protected
AdsLoader.pigeon_detached({
super.pigeon_binaryMessenger,
super.pigeon_instanceManager,
});
late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecAdsLoader =
_PigeonInternalProxyApiBaseCodec(pigeon_instanceManager);
static void pigeon_setUpMessageHandlers({
bool pigeon_clearHandlers = false,
BinaryMessenger? pigeon_binaryMessenger,
PigeonInstanceManager? pigeon_instanceManager,
AdsLoader Function()? pigeon_newInstance,
}) {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_PigeonInternalProxyApiBaseCodec(
pigeon_instanceManager ?? PigeonInstanceManager.instance);
final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger;
{
final BasicMessageChannel<
Object?> pigeonVar_channel = BasicMessageChannel<
Object?>(
'dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance',
pigeonChannelCodec,
binaryMessenger: binaryMessenger);
if (pigeon_clearHandlers) {
pigeonVar_channel.setMessageHandler(null);
} else {
pigeonVar_channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_pigeon_instanceIdentifier = (args[0] as int?);
assert(arg_pigeon_instanceIdentifier != null,
'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance was null, expected non-null int.');
try {
(pigeon_instanceManager ?? PigeonInstanceManager.instance)
.addHostCreatedInstance(
pigeon_newInstance?.call() ??
AdsLoader.pigeon_detached(
pigeon_binaryMessenger: pigeon_binaryMessenger,
pigeon_instanceManager: pigeon_instanceManager,
),
arg_pigeon_instanceIdentifier!,
);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
}
/// Registers a listener for errors that occur during the ads request.
Future<void> addAdErrorListener(AdErrorListener listener) async {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecAdsLoader;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.AdsLoader.addAdErrorListener';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
.send(<Object?>[this, listener]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
/// Registers a listener for the ads manager loaded event.
Future<void> addAdsLoadedListener(AdsLoadedListener listener) async {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecAdsLoader;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.AdsLoader.addAdsLoadedListener';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
.send(<Object?>[this, listener]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
/// Requests ads from a server.
Future<void> requestAds(AdsRequest request) async {
final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec =
_pigeonVar_codecAdsLoader;
final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger;
const String pigeonVar_channelName =
'dev.flutter.pigeon.interactive_media_ads.AdsLoader.requestAds';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
.send(<Object?>[this, request]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
@override
AdsLoader pigeon_copy() {
return AdsLoader.pigeon_detached(
pigeon_binaryMessenger: pigeon_binaryMessenger,
pigeon_instanceManager: pigeon_instanceManager,
);
}
}
/// An event raised when ads are successfully loaded from the ad server through an AdsLoader.
///
/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManagerLoadedEvent.html.
class AdsManagerLoadedEvent extends PigeonInternalProxyApiBaseClass {
/// Constructs [AdsManagerLoadedEvent] without creating the associated native object.
///
/// This should only be used by subclasses created by this library or to
/// create copies for an [PigeonInstanceManager].
@protected
AdsManagerLoadedEvent.pigeon_detached({
super.pigeon_binaryMessenger,
super.pigeon_instanceManager,
required this.manager,
});