From 905cd48d6596cc1da76fe0e30034eccbb7507e70 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:05:35 -0400 Subject: [PATCH 01/26] interface and app-facing implementation for content progress provider --- .../android_interactive_media_ads.dart | 9 ++ .../lib/src/content_progress_provider.dart | 86 +++++++++++++++++++ .../src/ios/ios_interactive_media_ads.dart | 9 ++ .../src/platform_interface/ads_request.dart | 15 +++- .../interactive_media_ads_platform.dart | 6 ++ .../platform_content_progress_provider.dart | 83 ++++++++++++++++++ .../test/ad_display_container_test.dart | 2 + .../test/ads_manager_delegate_test.dart | 2 + .../test/ads_manager_test.dart | 1 + .../test/content_progress_provider_test.dart | 27 ++++++ .../test/test_stubs.dart | 27 ++++++ 11 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 packages/interactive_media_ads/lib/src/content_progress_provider.dart create mode 100644 packages/interactive_media_ads/lib/src/platform_interface/platform_content_progress_provider.dart create mode 100644 packages/interactive_media_ads/test/content_progress_provider_test.dart diff --git a/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart b/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart index 2406520d5531..d1ad7370f412 100644 --- a/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart +++ b/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart @@ -6,6 +6,7 @@ import '../platform_interface/interactive_media_ads_platform.dart'; import '../platform_interface/platform_ad_display_container.dart'; import '../platform_interface/platform_ads_loader.dart'; import '../platform_interface/platform_ads_manager_delegate.dart'; +import '../platform_interface/platform_content_progress_provider.dart'; import 'android_ad_display_container.dart'; import 'android_ads_loader.dart'; import 'android_ads_manager_delegate.dart'; @@ -37,4 +38,12 @@ final class AndroidInteractiveMediaAds extends InteractiveMediaAdsPlatform { ) { return AndroidAdsManagerDelegate(params); } + + @override + PlatformContentProgressProvider createPlatformContentProgressProvider( + PlatformContentProgressProviderCreationParams params, + ) { + // TODO: implement createPlatformContentProgressProvider + throw UnimplementedError(); + } } diff --git a/packages/interactive_media_ads/lib/src/content_progress_provider.dart b/packages/interactive_media_ads/lib/src/content_progress_provider.dart new file mode 100644 index 000000000000..490acbc47d8c --- /dev/null +++ b/packages/interactive_media_ads/lib/src/content_progress_provider.dart @@ -0,0 +1,86 @@ +// 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. + +import 'platform_interface/platform_content_progress_provider.dart'; + +/// Allow the SDK to track progress of the content video. +/// +/// Provides updates required to enable triggering ads at configured cue points. +/// +/// ## Platform-Specific Features +/// This class contains an underlying implementation provided by the current +/// platform. Once a platform implementation is imported, the examples below +/// can be followed to use features provided by a platform's implementation. +/// +/// {@macro interactive_media_ads.ContentProgressProvider.fromPlatformCreationParams} +/// +/// Below is an example of accessing the platform-specific implementation for +/// iOS and Android: +/// +/// ```dart +/// final ContentProgressProvider provider = ContentProgressProvider(); +/// +/// if (InteractiveMediaAdsPlatform.instance is IOSInteractiveMediaAdsPlatform) { +/// final IOSContentProgressProvider iosProvider = +/// provider.platform as IOSContentProgressProvider; +/// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) { +/// final AndroidContentProgressProvider androidProvider = +/// provider.platform as AndroidContentProgressProvider; +/// } +/// ``` +class ContentProgressProvider { + /// Constructs an [ContentProgressProvider]. + /// + /// See [ContentProgressProvider.fromPlatformCreationParams] for setting + /// parameters for a specific platform. + ContentProgressProvider() + : this.fromPlatformCreationParams( + const PlatformContentProgressProviderCreationParams(), + ); + + /// Constructs an [ContentProgressProvider] from creation params for a + /// specific platform. + /// + /// {@template interactive_media_ads.ContentProgressProvider.fromPlatformCreationParams} + /// Below is an example of setting platform-specific creation parameters for + /// iOS and Android: + /// + /// ```dart + /// PlatformContentProgressProviderCreationParams params = + /// const PlatformContentProgressProviderCreationParams(); + /// + /// if (InteractiveMediaAdsPlatform.instance is IOSInteractiveMediaAdsPlatform) { + /// params = IOSContentProgressProviderCreationParams + /// .fromPlatformContentProgressProviderCreationParams( + /// params, + /// ); + /// } else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) { + /// params = AndroidContentProgressProviderCreationParams + /// .fromPlatformContentProgressProviderCreationParams( + /// params, + /// ); + /// } + /// + /// final ContentProgressProvider provider = ContentProgressProvider.fromPlatformCreationParams( + /// params, + /// ); + /// ``` + /// {@endtemplate} + ContentProgressProvider.fromPlatformCreationParams( + PlatformContentProgressProviderCreationParams params, + ) : this.fromPlatform(PlatformContentProgressProvider(params)); + + /// Constructs a [ContentProgressProvider] from a specific platform + /// implementation. + ContentProgressProvider.fromPlatform(this.platform); + + /// Implementation of [PlatformContentProgressProvider] for the current + /// platform. + final PlatformContentProgressProvider platform; + + /// Sends an update on the progress of the content video. + Future setProgress(Duration progress) { + return platform.setProgress(progress); + } +} diff --git a/packages/interactive_media_ads/lib/src/ios/ios_interactive_media_ads.dart b/packages/interactive_media_ads/lib/src/ios/ios_interactive_media_ads.dart index 013f66451eb0..574df54b3e7f 100644 --- a/packages/interactive_media_ads/lib/src/ios/ios_interactive_media_ads.dart +++ b/packages/interactive_media_ads/lib/src/ios/ios_interactive_media_ads.dart @@ -6,6 +6,7 @@ import '../platform_interface/interactive_media_ads_platform.dart'; import '../platform_interface/platform_ad_display_container.dart'; import '../platform_interface/platform_ads_loader.dart'; import '../platform_interface/platform_ads_manager_delegate.dart'; +import '../platform_interface/platform_content_progress_provider.dart'; import 'ios_ad_display_container.dart'; import 'ios_ads_loader.dart'; import 'ios_ads_manager_delegate.dart'; @@ -35,4 +36,12 @@ final class IOSInteractiveMediaAds extends InteractiveMediaAdsPlatform { ) { return IOSAdsManagerDelegate(params); } + + @override + PlatformContentProgressProvider createPlatformContentProgressProvider( + PlatformContentProgressProviderCreationParams params, + ) { + // TODO: implement createPlatformContentProgressProvider + throw UnimplementedError(); + } } diff --git a/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart b/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart index 72e4dfc69b63..38bf7cc5177b 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart @@ -2,11 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'platform_content_progress_provider.dart'; + /// An object containing the data used to request ads from the server. class AdsRequest { /// Creates an [AdsRequest]. - AdsRequest({required this.adTagUrl}); + AdsRequest({ + required this.adTagUrl, + this.contentDuration, + this.contentProgressProvider, + }); /// The URL from which ads will be requested. final String adTagUrl; + + /// The duration of the content video to be shown. + final Duration? contentDuration; + + /// A [PlatformContentProgressProvider] instance to allow scheduling of ad + /// breaks based on content progress (cue points). + final PlatformContentProgressProvider? contentProgressProvider; } diff --git a/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart b/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart index f1dac2db7d1d..fdb8593bdcb4 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/interactive_media_ads_platform.dart @@ -5,6 +5,7 @@ import 'platform_ad_display_container.dart'; import 'platform_ads_loader.dart'; import 'platform_ads_manager_delegate.dart'; +import 'platform_content_progress_provider.dart'; /// Interface for a platform implementation of the Interactive Media Ads SDKs. abstract base class InteractiveMediaAdsPlatform { @@ -29,4 +30,9 @@ abstract base class InteractiveMediaAdsPlatform { PlatformAdDisplayContainer createPlatformAdDisplayContainer( PlatformAdDisplayContainerCreationParams params, ); + + /// Creates a new [PlatformContentProgressProvider]. + PlatformContentProgressProvider createPlatformContentProgressProvider( + PlatformContentProgressProviderCreationParams params, + ); } diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_content_progress_provider.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_content_progress_provider.dart new file mode 100644 index 000000000000..24cad7bc5820 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_content_progress_provider.dart @@ -0,0 +1,83 @@ +// 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. + +import 'package:flutter/foundation.dart'; + +import 'interactive_media_ads_platform.dart'; + +/// Object specifying creation parameters for creating a +/// [PlatformContentProgressProvider]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +/// +/// This example demonstrates how to extend the +/// [PlatformContentProgressProviderCreationParams] to provide additional +/// platform specific parameters. +/// +/// When extending [PlatformContentProgressProviderCreationParams] additional +/// parameters should always accept `null` or have a default value to prevent +/// breaking changes. +/// +/// ```dart +/// class AndroidPlatformContentProgressProviderCreationParams +/// extends PlatformContentProgressProviderCreationParams { +/// AndroidPlatformContentProgressProviderCreationParams._( +/// PlatformContentProgressProviderCreationParams params, { +/// this.uri, +/// }) : super(); +/// +/// factory AndroidPlatformContentProgressProviderCreationParams.fromPlatformContentProgressProviderCreationParams( +/// PlatformContentProgressProviderCreationParams params, { +/// Uri? uri, +/// }) { +/// return AndroidPlatformContentProgressProviderCreationParams._(params, uri: uri); +/// } +/// +/// final Uri? uri; +/// } +/// ``` +@immutable +base class PlatformContentProgressProviderCreationParams { + /// Used by the platform implementation to create a new + /// [PlatformContentProgressProvider]. + const PlatformContentProgressProviderCreationParams(); +} + +/// Interface to allow the SDK to track progress of the content video. +/// +/// Provides updates required to enable triggering ads at configured cue points. +abstract class PlatformContentProgressProvider { + /// Creates a new [PlatformAdsManagerDelegate] + factory PlatformContentProgressProvider( + PlatformContentProgressProviderCreationParams params, + ) { + assert( + InteractiveMediaAdsPlatform.instance != null, + 'A platform implementation for `interactive_media_ads` has not been set. ' + 'Please ensure that an implementation of `InteractiveMediaAdsPlatform` ' + 'has been set to `InteractiveMediaAdsPlatform.instance` before use. For ' + 'unit testing, `InteractiveMediaAdsPlatform.instance` can be set with ' + 'your own test implementation.', + ); + final PlatformContentProgressProvider implementation = + InteractiveMediaAdsPlatform.instance! + .createPlatformContentProgressProvider(params); + return implementation; + } + + /// Used by the platform implementation to create a new + /// [PlatformContentProgressProvider]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformContentProgressProvider.implementation(this.params); + + /// The parameters used to initialize the [PlatformContentProgressProvider]. + final PlatformContentProgressProviderCreationParams params; + + /// Sends an update on the progress of the content video. + Future setProgress(Duration progress); +} diff --git a/packages/interactive_media_ads/test/ad_display_container_test.dart b/packages/interactive_media_ads/test/ad_display_container_test.dart index a82a16e8c4c2..c237424a806c 100644 --- a/packages/interactive_media_ads/test/ad_display_container_test.dart +++ b/packages/interactive_media_ads/test/ad_display_container_test.dart @@ -45,6 +45,8 @@ void main() { PlatformAdsManagerDelegateCreationParams params, ) { throw UnimplementedError(); + }, onCreatePlatformContentProgressProvider: (_) { + throw UnimplementedError(); }); final AdDisplayContainer adDisplayContainer = AdDisplayContainer( diff --git a/packages/interactive_media_ads/test/ads_manager_delegate_test.dart b/packages/interactive_media_ads/test/ads_manager_delegate_test.dart index ba6801dc41f3..a0d519864c43 100644 --- a/packages/interactive_media_ads/test/ads_manager_delegate_test.dart +++ b/packages/interactive_media_ads/test/ads_manager_delegate_test.dart @@ -22,6 +22,8 @@ void main() { (PlatformAdDisplayContainerCreationParams params) { throw UnimplementedError(); }, + onCreatePlatformContentProgressProvider: (_) => + throw UnimplementedError(), ); void onAdEvent(AdEvent event) {} diff --git a/packages/interactive_media_ads/test/ads_manager_test.dart b/packages/interactive_media_ads/test/ads_manager_test.dart index cb5f42ccb3f6..204b0173b5ec 100644 --- a/packages/interactive_media_ads/test/ads_manager_test.dart +++ b/packages/interactive_media_ads/test/ads_manager_test.dart @@ -66,6 +66,7 @@ AdsManager createAdsManager(PlatformAdsManager platformManager) { (PlatformAdDisplayContainerCreationParams params) { throw UnimplementedError(); }, + onCreatePlatformContentProgressProvider: (_) => throw UnimplementedError(), ); late final AdsManager manager; diff --git a/packages/interactive_media_ads/test/content_progress_provider_test.dart b/packages/interactive_media_ads/test/content_progress_provider_test.dart new file mode 100644 index 000000000000..c218a076c18a --- /dev/null +++ b/packages/interactive_media_ads/test/content_progress_provider_test.dart @@ -0,0 +1,27 @@ +// 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. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:interactive_media_ads/src/content_progress_provider.dart'; +import 'package:interactive_media_ads/src/platform_interface/platform_content_progress_provider.dart'; + +import 'test_stubs.dart'; + +void main() { + test('setProgress', () async { + final TestContentProgressProvider platformProvider = + TestContentProgressProvider( + const PlatformContentProgressProviderCreationParams(), + onSetProgress: expectAsync1((Duration progress) async { + expect(progress, equals(const Duration(seconds: 1))); + }), + ); + + final ContentProgressProvider provider = + ContentProgressProvider.fromPlatform( + platformProvider, + ); + await provider.setProgress(const Duration(seconds: 1)); + }); +} diff --git a/packages/interactive_media_ads/test/test_stubs.dart b/packages/interactive_media_ads/test/test_stubs.dart index fd59fb3073f1..ca9ea4d25e2c 100644 --- a/packages/interactive_media_ads/test/test_stubs.dart +++ b/packages/interactive_media_ads/test/test_stubs.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'package:flutter/material.dart'; +import 'package:interactive_media_ads/src/platform_interface/platform_content_progress_provider.dart'; import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart'; final class TestInteractiveMediaAdsPlatform @@ -11,6 +12,7 @@ final class TestInteractiveMediaAdsPlatform required this.onCreatePlatformAdsLoader, required this.onCreatePlatformAdsManagerDelegate, required this.onCreatePlatformAdDisplayContainer, + required this.onCreatePlatformContentProgressProvider, }); PlatformAdsLoader Function(PlatformAdsLoaderCreationParams params) @@ -24,6 +26,10 @@ final class TestInteractiveMediaAdsPlatform PlatformAdDisplayContainerCreationParams params, ) onCreatePlatformAdDisplayContainer; + PlatformContentProgressProvider Function( + PlatformContentProgressProviderCreationParams params, + ) onCreatePlatformContentProgressProvider; + @override PlatformAdsLoader createPlatformAdsLoader( PlatformAdsLoaderCreationParams params, @@ -44,6 +50,13 @@ final class TestInteractiveMediaAdsPlatform ) { return onCreatePlatformAdDisplayContainer(params); } + + @override + PlatformContentProgressProvider createPlatformContentProgressProvider( + PlatformContentProgressProviderCreationParams params, + ) { + return onCreatePlatformContentProgressProvider(params); + } } final class TestPlatformAdDisplayContainer extends PlatformAdDisplayContainer { @@ -125,3 +138,17 @@ class TestAdsManager extends PlatformAdsManager { return onDestroy?.call(); } } + +class TestContentProgressProvider extends PlatformContentProgressProvider { + TestContentProgressProvider( + super.params, { + this.onSetProgress, + }) : super.implementation(); + + Future Function(Duration progress)? onSetProgress; + + @override + Future setProgress(Duration progress) async { + return onSetProgress?.call(progress); + } +} From 89e4434ef35f2459b995ac0a9bbb92fb9624a003 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:08:01 -0400 Subject: [PATCH 02/26] partial android implementation --- .../ContentProgressProviderProxyApi.kt | 25 +- .../InteractiveMediaAdsLibrary.g.kt | 707 ++++++-- .../InteractiveMediaAdsPlugin.kt | 5 +- .../ProxyApiRegistrar.kt | 8 +- .../ContentProgressProviderProxyApiTest.kt | 35 + .../android_content_progress_provider.dart | 64 + .../src/android/interactive_media_ads.g.dart | 117 +- .../android/interactive_media_ads_proxy.dart | 4 + .../interactive_media_ads_android.dart | 1436 +++++++++-------- packages/interactive_media_ads/pubspec.yaml | 5 + 10 files changed, 1523 insertions(+), 883 deletions(-) create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt create mode 100644 packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt index 0fa1308d1383..116ee8477490 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt @@ -4,6 +4,9 @@ package dev.flutter.packages.interactive_media_ads +import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + /** * ProxyApi implementation for * [com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider]. @@ -12,4 +15,24 @@ package dev.flutter.packages.interactive_media_ads * instance or handle method calls on the associated native class or an instance of that class. */ class ContentProgressProviderProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : - PigeonApiContentProgressProvider(pigeonRegistrar) + PigeonApiContentProgressProvider(pigeonRegistrar) { + internal class ContentProgressProviderImpl(val api: ContentProgressProviderProxyApi) : + ContentProgressProvider { + var currentProgress = VideoProgressUpdate.VIDEO_TIME_NOT_READY + + override fun getContentProgress(): VideoProgressUpdate { + return currentProgress + } + } + + override fun pigeon_defaultConstructor(): ContentProgressProvider { + return ContentProgressProviderImpl(this) + } + + override fun setContentProgress( + pigeon_instance: ContentProgressProvider, + update: VideoProgressUpdate + ) { + (pigeon_instance as ContentProgressProviderImpl).currentProgress = update + } +} diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index 49d21f7b51eb..6091cdfca4b6 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -1,9 +1,9 @@ // 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 (v19.1.0), do not edit directly. +// Autogenerated from Pigeon (v21.2.0), do not edit directly. // See also: https://pub.dev/packages/pigeon -@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass", "SyntheticAccessor") +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") package dev.flutter.packages.interactive_media_ads @@ -50,20 +50,22 @@ class FlutterError( /** * Maintains instances used to communicate with the corresponding objects in Dart. * - *

Objects stored in this container are represented by an object in Dart that is also stored in - * an InstanceManager with the same identifier. + * Objects stored in this container are represented by an object in Dart that is also stored in an + * InstanceManager with the same identifier. * - *

When an instance is added with an identifier, either can be used to retrieve the other. + * When an instance is added with an identifier, either can be used to retrieve the other. * - *

Added instances are added as a weak reference and a strong reference. When the strong - * reference is removed with [remove] and the weak reference is deallocated, the - * `finalizationListener` is made with the instance's identifier. However, if the strong reference - * is removed and then the identifier is retrieved with the intention to pass the identifier to Dart - * (e.g. calling [getIdentifierForStrongReference]), the strong reference to the instance is - * recreated. The strong reference will then need to be removed manually again. + * Added instances are added as a weak reference and a strong reference. When the strong reference + * is removed with [remove] and the weak reference is deallocated, the + * `finalizationListener.onFinalize` is called with the instance's identifier. However, if the + * strong reference is removed and then the identifier is retrieved with the intention to pass the + * identifier to Dart (e.g. calling [getIdentifierForStrongReference]), the strong reference to the + * instance is recreated. The strong reference will then need to be removed manually again. */ -@Suppress("UNCHECKED_CAST", "MemberVisibilityCanBePrivate", "unused") -class PigeonInstanceManager(private val finalizationListener: PigeonFinalizationListener) { +@Suppress("UNCHECKED_CAST", "MemberVisibilityCanBePrivate") +class InteractiveMediaAdsLibraryPigeonInstanceManager( + private val finalizationListener: PigeonFinalizationListener +) { /** Interface for listening when a weak reference of an instance is removed from the manager. */ interface PigeonFinalizationListener { fun onFinalize(identifier: Long) @@ -102,26 +104,20 @@ class PigeonInstanceManager(private val finalizationListener: PigeonFinalization private const val tag = "PigeonInstanceManager" /** - * Instantiate a new manager. + * Instantiate a new manager with a listener for garbage collected weak references. * * When the manager is no longer needed, [stopFinalizationListener] must be called. - * - * @param finalizationListener the listener for garbage collected weak references. - * @return a new `PigeonInstanceManager`. */ - fun create(finalizationListener: PigeonFinalizationListener): PigeonInstanceManager { - return PigeonInstanceManager(finalizationListener) + fun create( + finalizationListener: PigeonFinalizationListener + ): InteractiveMediaAdsLibraryPigeonInstanceManager { + return InteractiveMediaAdsLibraryPigeonInstanceManager(finalizationListener) } } /** - * Removes `identifier` and its associated strongly referenced instance, if present, from the - * manager. - * - * @param identifier the identifier paired to an instance. - * @param the expected return type. - * @return the removed instance if the manager contains the given identifier, otherwise `null` if - * the manager doesn't contain the value. + * Removes `identifier` and return its associated strongly referenced instance, if present, from + * the manager. */ fun remove(identifier: Long): T? { logWarningIfFinalizationListenerHasStopped() @@ -129,19 +125,15 @@ class PigeonInstanceManager(private val finalizationListener: PigeonFinalization } /** - * Retrieves the identifier paired with an instance. + * Retrieves the identifier paired with an instance, if present, otherwise `null`. * * If the manager contains a strong reference to `instance`, it will return the identifier * associated with `instance`. If the manager contains only a weak reference to `instance`, a new * strong reference to `instance` will be added and will need to be removed again with [remove]. * * If this method returns a nonnull identifier, this method also expects the Dart - * `PigeonInstanceManager` to have, or recreate, a weak reference to the Dart instance the - * identifier is associated with. - * - * @param instance an instance that may be stored in the manager. - * @return the identifier associated with `instance` if the manager contains the value, otherwise - * `null` if the manager doesn't contain the value. + * `InteractiveMediaAdsLibraryPigeonInstanceManager` to have, or recreate, a weak reference to the + * Dart instance the identifier is associated with. */ fun getIdentifierForStrongReference(instance: Any?): Long? { logWarningIfFinalizationListenerHasStopped() @@ -159,9 +151,7 @@ class PigeonInstanceManager(private val finalizationListener: PigeonFinalization * two objects that are equivalent (e.g. the `equals` method returns true and their hashcodes are * equal) to both be added. * - * @param instance the instance to be stored. - * @param identifier the identifier to be paired with instance. This value must be >= 0 and - * unique. + * [identifier] must be >= 0 and unique. */ fun addDartCreatedInstance(instance: Any, identifier: Long) { logWarningIfFinalizationListenerHasStopped() @@ -169,10 +159,9 @@ class PigeonInstanceManager(private val finalizationListener: PigeonFinalization } /** - * Adds a new instance that was instantiated from the host platform. + * Adds a new unique instance that was instantiated from the host platform. * - * @param instance the instance to be stored. This must be unique to all other added instances. - * @return the unique identifier (>= 0) stored with instance. + * [identifier] must be >= 0 and unique. */ fun addHostCreatedInstance(instance: Any): Long { logWarningIfFinalizationListenerHasStopped() @@ -184,33 +173,21 @@ class PigeonInstanceManager(private val finalizationListener: PigeonFinalization return identifier } - /** - * Retrieves the instance associated with identifier. - * - * @param identifier the identifier associated with an instance. - * @param the expected return type. - * @return the instance associated with `identifier` if the manager contains the value, otherwise - * `null` if the manager doesn't contain the value. - */ + /** Retrieves the instance associated with identifier, if present, otherwise `null`. */ fun getInstance(identifier: Long): T? { logWarningIfFinalizationListenerHasStopped() val instance = weakInstances[identifier] as java.lang.ref.WeakReference? return instance?.get() } - /** - * Returns whether this manager contains the given `instance`. - * - * @param instance the instance whose presence in this manager is to be tested. - * @return whether this manager contains the given `instance`. - */ + /** Returns whether this manager contains the given `instance`. */ fun containsInstance(instance: Any?): Boolean { logWarningIfFinalizationListenerHasStopped() return identifiers.containsKey(instance) } /** - * Stop the periodic run of the [PigeonFinalizationListener] for instances that have been garbage + * Stops the periodic run of the [PigeonFinalizationListener] for instances that have been garbage * collected. * * The InstanceManager can continue to be used, but the [PigeonFinalizationListener] will no @@ -282,18 +259,20 @@ class PigeonInstanceManager(private val finalizationListener: PigeonFinalization } /** Generated API for managing the Dart and native `PigeonInstanceManager`s. */ -private class PigeonInstanceManagerApi(val binaryMessenger: BinaryMessenger) { +private class InteractiveMediaAdsLibraryPigeonInstanceManagerApi( + val binaryMessenger: BinaryMessenger +) { companion object { - /** The codec used by PigeonInstanceManagerApi. */ + /** The codec used by InteractiveMediaAdsLibraryPigeonInstanceManagerApi. */ val codec: MessageCodec by lazy { StandardMessageCodec() } /** - * Sets up an instance of `PigeonInstanceManagerApi` to handle messages from the - * `binaryMessenger`. + * Sets up an instance of `InteractiveMediaAdsLibraryPigeonInstanceManagerApi` to handle + * messages from the `binaryMessenger`. */ fun setUpMessageHandlers( binaryMessenger: BinaryMessenger, - instanceManager: PigeonInstanceManager? + instanceManager: InteractiveMediaAdsLibraryPigeonInstanceManager? ) { run { val channel = @@ -308,7 +287,7 @@ private class PigeonInstanceManagerApi(val binaryMessenger: BinaryMessenger) { val wrapped: List = try { instanceManager.remove(identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -329,7 +308,7 @@ private class PigeonInstanceManagerApi(val binaryMessenger: BinaryMessenger) { val wrapped: List = try { instanceManager.clear() - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -363,22 +342,26 @@ private class PigeonInstanceManagerApi(val binaryMessenger: BinaryMessenger) { * Provides implementations for each ProxyApi implementation and provides access to resources needed * by any implementation. */ -abstract class PigeonProxyApiRegistrar(val binaryMessenger: BinaryMessenger) { - val instanceManager: PigeonInstanceManager +abstract class InteractiveMediaAdsLibraryPigeonProxyApiRegistrar( + val binaryMessenger: BinaryMessenger +) { + /** Whether APIs should ignore calling to Dart. */ + public var ignoreCallsToDart = false + val instanceManager: InteractiveMediaAdsLibraryPigeonInstanceManager private var _codec: StandardMessageCodec? = null val codec: StandardMessageCodec get() { if (_codec == null) { - _codec = PigeonProxyApiBaseCodec(this) + _codec = InteractiveMediaAdsLibraryPigeonProxyApiBaseCodec(this) } return _codec!! } init { - val api = PigeonInstanceManagerApi(binaryMessenger) + val api = InteractiveMediaAdsLibraryPigeonInstanceManagerApi(binaryMessenger) instanceManager = - PigeonInstanceManager.create( - object : PigeonInstanceManager.PigeonFinalizationListener { + InteractiveMediaAdsLibraryPigeonInstanceManager.create( + object : InteractiveMediaAdsLibraryPigeonInstanceManager.PigeonFinalizationListener { override fun onFinalize(identifier: Long) { api.removeStrongReference(identifier) { if (it.isFailure) { @@ -390,7 +373,6 @@ abstract class PigeonProxyApiRegistrar(val binaryMessenger: BinaryMessenger) { } }) } - /** * An implementation of [PigeonApiBaseDisplayContainer] used to add a new Dart instance of * `BaseDisplayContainer` to the Dart `InstanceManager`. @@ -441,9 +423,7 @@ abstract class PigeonProxyApiRegistrar(val binaryMessenger: BinaryMessenger) { * An implementation of [PigeonApiContentProgressProvider] used to add a new Dart instance of * `ContentProgressProvider` to the Dart `InstanceManager`. */ - open fun getPigeonApiContentProgressProvider(): PigeonApiContentProgressProvider { - return PigeonApiContentProgressProvider(this) - } + abstract fun getPigeonApiContentProgressProvider(): PigeonApiContentProgressProvider /** * An implementation of [PigeonApiAdsManager] used to add a new Dart instance of `AdsManager` to @@ -558,9 +538,12 @@ abstract class PigeonProxyApiRegistrar(val binaryMessenger: BinaryMessenger) { abstract fun getPigeonApiAdEventListener(): PigeonApiAdEventListener fun setUp() { - PigeonInstanceManagerApi.setUpMessageHandlers(binaryMessenger, instanceManager) + InteractiveMediaAdsLibraryPigeonInstanceManagerApi.setUpMessageHandlers( + binaryMessenger, instanceManager) PigeonApiAdsLoader.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsLoader()) PigeonApiAdsRequest.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsRequest()) + PigeonApiContentProgressProvider.setUpMessageHandlers( + binaryMessenger, getPigeonApiContentProgressProvider()) PigeonApiAdsManager.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsManager()) PigeonApiBaseManager.setUpMessageHandlers(binaryMessenger, getPigeonApiBaseManager()) PigeonApiImaSdkFactory.setUpMessageHandlers(binaryMessenger, getPigeonApiImaSdkFactory()) @@ -580,9 +563,10 @@ abstract class PigeonProxyApiRegistrar(val binaryMessenger: BinaryMessenger) { } fun tearDown() { - PigeonInstanceManagerApi.setUpMessageHandlers(binaryMessenger, null) + InteractiveMediaAdsLibraryPigeonInstanceManagerApi.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsLoader.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsRequest.setUpMessageHandlers(binaryMessenger, null) + PigeonApiContentProgressProvider.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsManager.setUpMessageHandlers(binaryMessenger, null) PigeonApiBaseManager.setUpMessageHandlers(binaryMessenger, null) PigeonApiImaSdkFactory.setUpMessageHandlers(binaryMessenger, null) @@ -599,8 +583,9 @@ abstract class PigeonProxyApiRegistrar(val binaryMessenger: BinaryMessenger) { } } -private class PigeonProxyApiBaseCodec(val registrar: PigeonProxyApiRegistrar) : - StandardMessageCodec() { +private class InteractiveMediaAdsLibraryPigeonProxyApiBaseCodec( + val registrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) : InteractiveMediaAdsLibraryPigeonCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { 128.toByte() -> { @@ -612,6 +597,26 @@ private class PigeonProxyApiBaseCodec(val registrar: PigeonProxyApiRegistrar) : } override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + if (value is Boolean || + value is ByteArray || + value is Double || + value is DoubleArray || + value is FloatArray || + value is Int || + value is IntArray || + value is List<*> || + value is Long || + value is LongArray || + value is Map<*, *> || + value is String || + value is AdErrorCode || + value is AdErrorType || + value is AdEventType || + value == null) { + super.writeValue(stream, value) + return + } + if (value is com.google.ads.interactivemedia.v3.api.AdDisplayContainer) { registrar.getPigeonApiAdDisplayContainer().pigeon_newInstance(value) {} } else if (value is com.google.ads.interactivemedia.v3.api.BaseDisplayContainer) { @@ -672,7 +677,9 @@ private class PigeonProxyApiBaseCodec(val registrar: PigeonProxyApiRegistrar) : stream.write(128) writeValue(stream, registrar.instanceManager.getIdentifierForStrongReference(value)) } - else -> super.writeValue(stream, value) + else -> + throw IllegalArgumentException( + "Unsupported value: '$value' of type '${value.javaClass.name}'") } } } @@ -847,6 +854,42 @@ enum class AdEventType(val raw: Int) { } } } + +private open class InteractiveMediaAdsLibraryPigeonCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 129.toByte() -> { + return (readValue(buffer) as Int?)?.let { AdErrorCode.ofRaw(it) } + } + 130.toByte() -> { + return (readValue(buffer) as Int?)?.let { AdErrorType.ofRaw(it) } + } + 131.toByte() -> { + return (readValue(buffer) as Int?)?.let { AdEventType.ofRaw(it) } + } + else -> super.readValueOfType(type, buffer) + } + } + + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is AdErrorCode -> { + stream.write(129) + writeValue(stream, value.raw) + } + is AdErrorType -> { + stream.write(130) + writeValue(stream, value.raw) + } + is AdEventType -> { + stream.write(131) + writeValue(stream, value.raw) + } + else -> super.writeValue(stream, value) + } + } +} + /** * A base class for more specialized container interfaces. * @@ -854,13 +897,21 @@ enum class AdEventType(val raw: Int) { * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseDisplayContainer.html. */ @Suppress("UNCHECKED_CAST") -open class PigeonApiBaseDisplayContainer(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +open class PigeonApiBaseDisplayContainer( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { @Suppress("LocalVariableName", "FunctionName") /** Creates a Dart instance of BaseDisplayContainer and attaches it to [pigeon_instanceArg]. */ fun pigeon_newInstance( pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.BaseDisplayContainer, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -892,13 +943,21 @@ open class PigeonApiBaseDisplayContainer(open val pigeonRegistrar: PigeonProxyAp * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdDisplayContainer. */ @Suppress("UNCHECKED_CAST") -open class PigeonApiAdDisplayContainer(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +open class PigeonApiAdDisplayContainer( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { @Suppress("LocalVariableName", "FunctionName") /** Creates a Dart instance of AdDisplayContainer and attaches it to [pigeon_instanceArg]. */ fun pigeon_newInstance( pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdDisplayContainer, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -937,7 +996,9 @@ open class PigeonApiAdDisplayContainer(open val pigeonRegistrar: PigeonProxyApiR * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdsLoader(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdsLoader( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** Registers a listener for errors that occur during the ads request. */ abstract fun addAdErrorListener( pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsLoader, @@ -975,7 +1036,7 @@ abstract class PigeonApiAdsLoader(open val pigeonRegistrar: PigeonProxyApiRegist val wrapped: List = try { api.addAdErrorListener(pigeon_instanceArg, listenerArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1000,7 +1061,7 @@ abstract class PigeonApiAdsLoader(open val pigeonRegistrar: PigeonProxyApiRegist val wrapped: List = try { api.addAdsLoadedListener(pigeon_instanceArg, listenerArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1024,7 +1085,7 @@ abstract class PigeonApiAdsLoader(open val pigeonRegistrar: PigeonProxyApiRegist val wrapped: List = try { api.requestAds(pigeon_instanceArg, requestArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1043,6 +1104,12 @@ abstract class PigeonApiAdsLoader(open val pigeonRegistrar: PigeonProxyApiRegist pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsLoader, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1073,7 +1140,9 @@ abstract class PigeonApiAdsLoader(open val pigeonRegistrar: PigeonProxyApiRegist * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManagerLoadedEvent.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdsManagerLoadedEvent(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdsManagerLoadedEvent( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** * The ads manager that will control playback of the loaded ads, or null when using dynamic ad * insertion. @@ -1088,6 +1157,12 @@ abstract class PigeonApiAdsManagerLoadedEvent(open val pigeonRegistrar: PigeonPr pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1120,7 +1195,9 @@ abstract class PigeonApiAdsManagerLoadedEvent(open val pigeonRegistrar: PigeonPr * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdErrorEvent(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdErrorEvent( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** The AdError that caused this event. */ abstract fun error( pigeon_instance: com.google.ads.interactivemedia.v3.api.AdErrorEvent @@ -1132,6 +1209,12 @@ abstract class PigeonApiAdErrorEvent(open val pigeonRegistrar: PigeonProxyApiReg pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdErrorEvent, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1163,7 +1246,9 @@ abstract class PigeonApiAdErrorEvent(open val pigeonRegistrar: PigeonProxyApiReg * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdError(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdError( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** The error's code. */ abstract fun errorCode( pigeon_instance: com.google.ads.interactivemedia.v3.api.AdError @@ -1188,6 +1273,12 @@ abstract class PigeonApiAdError(open val pigeonRegistrar: PigeonProxyApiRegistra pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdError, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1203,12 +1294,7 @@ abstract class PigeonApiAdError(open val pigeonRegistrar: PigeonProxyApiRegistra val channelName = "dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) channel.send( - listOf( - pigeon_identifierArg, - errorCodeArg.raw, - errorCodeNumberArg, - errorTypeArg.raw, - messageArg)) { + listOf(pigeon_identifierArg, errorCodeArg, errorCodeNumberArg, errorTypeArg, messageArg)) { if (it is List<*>) { if (it.size > 1) { callback( @@ -1229,7 +1315,9 @@ abstract class PigeonApiAdError(open val pigeonRegistrar: PigeonProxyApiRegistra * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdsRequest(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdsRequest( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** Sets the URL from which ads will be requested. */ abstract fun setAdTagUrl( pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest, @@ -1263,7 +1351,7 @@ abstract class PigeonApiAdsRequest(open val pigeonRegistrar: PigeonProxyApiRegis val wrapped: List = try { api.setAdTagUrl(pigeon_instanceArg, adTagUrlArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1288,7 +1376,7 @@ abstract class PigeonApiAdsRequest(open val pigeonRegistrar: PigeonProxyApiRegis val wrapped: List = try { api.setContentProgressProvider(pigeon_instanceArg, providerArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1307,6 +1395,12 @@ abstract class PigeonApiAdsRequest(open val pigeonRegistrar: PigeonProxyApiRegis pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsRequest, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1337,13 +1431,96 @@ abstract class PigeonApiAdsRequest(open val pigeonRegistrar: PigeonProxyApiRegis * https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. */ @Suppress("UNCHECKED_CAST") -open class PigeonApiContentProgressProvider(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiContentProgressProvider( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { + abstract fun pigeon_defaultConstructor(): + com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider + + /** + * Sets an update on the progress of the video. + * + * This is a custom method added to the native class because the native method + * `getContentProgress` requires a synchronous return value. + */ + abstract fun setContentProgress( + pigeon_instance: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider, + update: com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + ) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers( + binaryMessenger: BinaryMessenger, + api: PigeonApiContentProgressProvider? + ) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.setContentProgress", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] as com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider + val updateArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + val wrapped: List = + try { + api.setContentProgress(pigeon_instanceArg, updateArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + @Suppress("LocalVariableName", "FunctionName") /** Creates a Dart instance of ContentProgressProvider and attaches it to [pigeon_instanceArg]. */ fun pigeon_newInstance( pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1375,7 +1552,9 @@ open class PigeonApiContentProgressProvider(open val pigeonRegistrar: PigeonProx * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManager. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdsManager(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdsManager( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** Discards current ad break and resumes content. */ abstract fun discardAdBreak(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsManager) @@ -1402,7 +1581,7 @@ abstract class PigeonApiAdsManager(open val pigeonRegistrar: PigeonProxyApiRegis val wrapped: List = try { api.discardAdBreak(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1423,7 +1602,7 @@ abstract class PigeonApiAdsManager(open val pigeonRegistrar: PigeonProxyApiRegis val wrapped: List = try { api.pause(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1444,7 +1623,7 @@ abstract class PigeonApiAdsManager(open val pigeonRegistrar: PigeonProxyApiRegis val wrapped: List = try { api.start(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1463,6 +1642,12 @@ abstract class PigeonApiAdsManager(open val pigeonRegistrar: PigeonProxyApiRegis pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsManager, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1499,7 +1684,9 @@ abstract class PigeonApiAdsManager(open val pigeonRegistrar: PigeonProxyApiRegis * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiBaseManager(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiBaseManager( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** * Registers a listener for errors that occur during the ad or stream initialization and playback. */ @@ -1541,7 +1728,7 @@ abstract class PigeonApiBaseManager(open val pigeonRegistrar: PigeonProxyApiRegi val wrapped: List = try { api.addAdErrorListener(pigeon_instanceArg, errorListenerArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1566,7 +1753,7 @@ abstract class PigeonApiBaseManager(open val pigeonRegistrar: PigeonProxyApiRegi val wrapped: List = try { api.addAdEventListener(pigeon_instanceArg, adEventListenerArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1589,7 +1776,7 @@ abstract class PigeonApiBaseManager(open val pigeonRegistrar: PigeonProxyApiRegi val wrapped: List = try { api.destroy(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1610,7 +1797,7 @@ abstract class PigeonApiBaseManager(open val pigeonRegistrar: PigeonProxyApiRegi val wrapped: List = try { api.init(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1629,6 +1816,12 @@ abstract class PigeonApiBaseManager(open val pigeonRegistrar: PigeonProxyApiRegi pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.BaseManager, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1659,7 +1852,9 @@ abstract class PigeonApiBaseManager(open val pigeonRegistrar: PigeonProxyApiRegi * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdEvent(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdEvent( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** The type of event that occurred. */ abstract fun type(pigeon_instance: com.google.ads.interactivemedia.v3.api.AdEvent): AdEventType @@ -1669,6 +1864,12 @@ abstract class PigeonApiAdEvent(open val pigeonRegistrar: PigeonProxyApiRegistra pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdEvent, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1680,7 +1881,7 @@ abstract class PigeonApiAdEvent(open val pigeonRegistrar: PigeonProxyApiRegistra val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(pigeon_identifierArg, typeArg.raw)) { + channel.send(listOf(pigeon_identifierArg, typeArg)) { if (it is List<*>) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) @@ -1700,7 +1901,9 @@ abstract class PigeonApiAdEvent(open val pigeonRegistrar: PigeonProxyApiRegistra * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiImaSdkFactory( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun instance(): com.google.ads.interactivemedia.v3.api.ImaSdkFactory abstract fun createAdDisplayContainer( @@ -1744,7 +1947,7 @@ abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRe try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.instance(), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1767,7 +1970,7 @@ abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRe val playerArg = args[1] as com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer val wrapped: List = try { - listOf(api.createAdDisplayContainer(containerArg, playerArg)) + listOf(api.createAdDisplayContainer(containerArg, playerArg)) } catch (exception: Throwable) { wrapError(exception) } @@ -1789,7 +1992,7 @@ abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRe val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.ImaSdkFactory val wrapped: List = try { - listOf(api.createImaSdkSettings(pigeon_instanceArg)) + listOf(api.createImaSdkSettings(pigeon_instanceArg)) } catch (exception: Throwable) { wrapError(exception) } @@ -1813,7 +2016,7 @@ abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRe val containerArg = args[2] as com.google.ads.interactivemedia.v3.api.AdDisplayContainer val wrapped: List = try { - listOf(api.createAdsLoader(pigeon_instanceArg, settingsArg, containerArg)) + listOf(api.createAdsLoader(pigeon_instanceArg, settingsArg, containerArg)) } catch (exception: Throwable) { wrapError(exception) } @@ -1835,7 +2038,7 @@ abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRe val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.ImaSdkFactory val wrapped: List = try { - listOf(api.createAdsRequest(pigeon_instanceArg)) + listOf(api.createAdsRequest(pigeon_instanceArg)) } catch (exception: Throwable) { wrapError(exception) } @@ -1854,6 +2057,12 @@ abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRe pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.ImaSdkFactory, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1884,13 +2093,21 @@ abstract class PigeonApiImaSdkFactory(open val pigeonRegistrar: PigeonProxyApiRe * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. */ @Suppress("UNCHECKED_CAST") -open class PigeonApiImaSdkSettings(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +open class PigeonApiImaSdkSettings( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { @Suppress("LocalVariableName", "FunctionName") /** Creates a Dart instance of ImaSdkSettings and attaches it to [pigeon_instanceArg]. */ fun pigeon_newInstance( pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.ImaSdkSettings, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -1921,7 +2138,9 @@ open class PigeonApiImaSdkSettings(open val pigeonRegistrar: PigeonProxyApiRegis * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiVideoProgressUpdate(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiVideoProgressUpdate( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun pigeon_defaultConstructor( currentTimeMs: Long, durationMs: Long @@ -1954,7 +2173,7 @@ abstract class PigeonApiVideoProgressUpdate(open val pigeonRegistrar: PigeonProx api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(currentTimeMsArg, durationMsArg), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1979,7 +2198,7 @@ abstract class PigeonApiVideoProgressUpdate(open val pigeonRegistrar: PigeonProx try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.videoTimeNotReady(), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -1998,6 +2217,12 @@ abstract class PigeonApiVideoProgressUpdate(open val pigeonRegistrar: PigeonProx pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -2029,7 +2254,9 @@ abstract class PigeonApiVideoProgressUpdate(open val pigeonRegistrar: PigeonProx * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdMediaInfo(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdMediaInfo( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun url( pigeon_instance: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo ): String @@ -2040,6 +2267,12 @@ abstract class PigeonApiAdMediaInfo(open val pigeonRegistrar: PigeonProxyApiRegi pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -2071,7 +2304,9 @@ abstract class PigeonApiAdMediaInfo(open val pigeonRegistrar: PigeonProxyApiRegi * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdPodInfo(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdPodInfo( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** * The position of the ad within the pod. * @@ -2113,6 +2348,12 @@ abstract class PigeonApiAdPodInfo(open val pigeonRegistrar: PigeonProxyApiRegist pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdPodInfo, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -2157,7 +2398,9 @@ abstract class PigeonApiAdPodInfo(open val pigeonRegistrar: PigeonProxyApiRegist * See https://developer.android.com/reference/android/widget/FrameLayout. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiFrameLayout(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiFrameLayout( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun pigeon_defaultConstructor(): android.widget.FrameLayout companion object { @@ -2179,7 +2422,7 @@ abstract class PigeonApiFrameLayout(open val pigeonRegistrar: PigeonProxyApiRegi try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2198,6 +2441,12 @@ abstract class PigeonApiFrameLayout(open val pigeonRegistrar: PigeonProxyApiRegi pigeon_instanceArg: android.widget.FrameLayout, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -2233,7 +2482,9 @@ abstract class PigeonApiFrameLayout(open val pigeonRegistrar: PigeonProxyApiRegi * See https://developer.android.com/reference/android/view/ViewGroup. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiViewGroup(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiViewGroup( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun addView(pigeon_instance: android.view.ViewGroup, view: android.view.View) companion object { @@ -2254,7 +2505,7 @@ abstract class PigeonApiViewGroup(open val pigeonRegistrar: PigeonProxyApiRegist val wrapped: List = try { api.addView(pigeon_instanceArg, viewArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2273,6 +2524,12 @@ abstract class PigeonApiViewGroup(open val pigeonRegistrar: PigeonProxyApiRegist pigeon_instanceArg: android.view.ViewGroup, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -2308,7 +2565,9 @@ abstract class PigeonApiViewGroup(open val pigeonRegistrar: PigeonProxyApiRegist * See https://developer.android.com/reference/android/widget/VideoView. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiVideoView( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun pigeon_defaultConstructor(): android.widget.VideoView /** Sets the URI of the video. */ @@ -2340,7 +2599,7 @@ abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegist try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2364,7 +2623,7 @@ abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegist val wrapped: List = try { api.setVideoUri(pigeon_instanceArg, uriArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2386,7 +2645,7 @@ abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegist val pigeon_instanceArg = args[0] as android.widget.VideoView val wrapped: List = try { - listOf(api.getCurrentPosition(pigeon_instanceArg)) + listOf(api.getCurrentPosition(pigeon_instanceArg)) } catch (exception: Throwable) { wrapError(exception) } @@ -2405,6 +2664,12 @@ abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegist pigeon_instanceArg: android.widget.VideoView, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -2419,6 +2684,12 @@ abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegist playerArg: android.media.MediaPlayer, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoView.onPrepared" @@ -2442,6 +2713,12 @@ abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegist playerArg: android.media.MediaPlayer, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoView.onCompletion" @@ -2467,6 +2744,12 @@ abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegist extraArg: Long, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoView.onError" @@ -2496,10 +2779,18 @@ abstract class PigeonApiVideoView(open val pigeonRegistrar: PigeonProxyApiRegist * See https://developer.android.com/reference/android/view/View. */ @Suppress("UNCHECKED_CAST") -open class PigeonApiView(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +open class PigeonApiView( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { @Suppress("LocalVariableName", "FunctionName") /** Creates a Dart instance of View and attaches it to [pigeon_instanceArg]. */ fun pigeon_newInstance(pigeon_instanceArg: android.view.View, callback: (Result) -> Unit) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -2529,7 +2820,9 @@ open class PigeonApiView(open val pigeonRegistrar: PigeonProxyApiRegistrar) { * See https://developer.android.com/reference/android/media/MediaPlayer. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiMediaPlayer( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** Gets the duration of the file. */ abstract fun getDuration(pigeon_instance: android.media.MediaPlayer): Long @@ -2561,7 +2854,7 @@ abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegi val pigeon_instanceArg = args[0] as android.media.MediaPlayer val wrapped: List = try { - listOf(api.getDuration(pigeon_instanceArg)) + listOf(api.getDuration(pigeon_instanceArg)) } catch (exception: Throwable) { wrapError(exception) } @@ -2585,7 +2878,7 @@ abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegi val wrapped: List = try { api.seekTo(pigeon_instanceArg, mSecArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2608,7 +2901,7 @@ abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegi val wrapped: List = try { api.start(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2631,7 +2924,7 @@ abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegi val wrapped: List = try { api.pause(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2652,7 +2945,7 @@ abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegi val wrapped: List = try { api.stop(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2671,6 +2964,12 @@ abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegi pigeon_instanceArg: android.media.MediaPlayer, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -2701,7 +3000,9 @@ abstract class PigeonApiMediaPlayer(open val pigeonRegistrar: PigeonProxyApiRegi * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiVideoAdPlayerCallback( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { /** Fire this callback periodically as ad playback occurs. */ abstract fun onAdProgress( pigeon_instance: @@ -2800,7 +3101,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onAdProgress(pigeon_instanceArg, adMediaInfoArg, videoProgressUpdateArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2828,7 +3129,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onBuffering(pigeon_instanceArg, adMediaInfoArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2854,7 +3155,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onContentComplete(pigeon_instanceArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2882,7 +3183,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onEnded(pigeon_instanceArg, adMediaInfoArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2910,7 +3211,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onError(pigeon_instanceArg, adMediaInfoArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2938,7 +3239,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onLoaded(pigeon_instanceArg, adMediaInfoArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2966,7 +3267,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onPause(pigeon_instanceArg, adMediaInfoArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -2994,7 +3295,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onPlay(pigeon_instanceArg, adMediaInfoArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3022,7 +3323,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onResume(pigeon_instanceArg, adMediaInfoArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3051,7 +3352,7 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr val wrapped: List = try { api.onVolumeChanged(pigeon_instanceArg, adMediaInfoArg, percentageArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3071,6 +3372,12 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -3103,7 +3410,9 @@ abstract class PigeonApiVideoAdPlayerCallback(open val pigeonRegistrar: PigeonPr * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiVideoAdPlayer( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun pigeon_defaultConstructor(): com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer @@ -3138,7 +3447,7 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3163,7 +3472,7 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe val wrapped: List = try { api.setVolume(pigeon_instanceArg, valueArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3189,7 +3498,7 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe val wrapped: List = try { api.setAdProgress(pigeon_instanceArg, progressArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3208,6 +3517,12 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -3223,6 +3538,12 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.addCallback" @@ -3247,6 +3568,12 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe adPodInfoArg: com.google.ads.interactivemedia.v3.api.AdPodInfo, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd" @@ -3270,6 +3597,12 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe adMediaInfoArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pauseAd" @@ -3296,6 +3629,12 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe adMediaInfoArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.playAd" @@ -3318,6 +3657,12 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.release" @@ -3342,6 +3687,12 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.removeCallback" @@ -3365,6 +3716,12 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe adMediaInfoArg: com.google.ads.interactivemedia.v3.api.player.AdMediaInfo, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.stopAd" @@ -3389,7 +3746,9 @@ abstract class PigeonApiVideoAdPlayer(open val pigeonRegistrar: PigeonProxyApiRe * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdsLoadedListener(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdsLoadedListener( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun pigeon_defaultConstructor(): com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener @@ -3412,7 +3771,7 @@ abstract class PigeonApiAdsLoadedListener(open val pigeonRegistrar: PigeonProxyA try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3431,6 +3790,12 @@ abstract class PigeonApiAdsLoadedListener(open val pigeonRegistrar: PigeonProxyA pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -3445,6 +3810,12 @@ abstract class PigeonApiAdsLoadedListener(open val pigeonRegistrar: PigeonProxyA eventArg: com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = @@ -3470,7 +3841,9 @@ abstract class PigeonApiAdsLoadedListener(open val pigeonRegistrar: PigeonProxyA * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdErrorListener(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdErrorListener( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun pigeon_defaultConstructor(): com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener @@ -3493,7 +3866,7 @@ abstract class PigeonApiAdErrorListener(open val pigeonRegistrar: PigeonProxyApi try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3512,6 +3885,12 @@ abstract class PigeonApiAdErrorListener(open val pigeonRegistrar: PigeonProxyApi pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -3526,6 +3905,12 @@ abstract class PigeonApiAdErrorListener(open val pigeonRegistrar: PigeonProxyApi eventArg: com.google.ads.interactivemedia.v3.api.AdErrorEvent, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.AdErrorListener.onAdError" @@ -3550,7 +3935,9 @@ abstract class PigeonApiAdErrorListener(open val pigeonRegistrar: PigeonProxyApi * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. */ @Suppress("UNCHECKED_CAST") -abstract class PigeonApiAdEventListener(open val pigeonRegistrar: PigeonProxyApiRegistrar) { +abstract class PigeonApiAdEventListener( + open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar +) { abstract fun pigeon_defaultConstructor(): com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener @@ -3573,7 +3960,7 @@ abstract class PigeonApiAdEventListener(open val pigeonRegistrar: PigeonProxyApi try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) + listOf(null) } catch (exception: Throwable) { wrapError(exception) } @@ -3592,6 +3979,12 @@ abstract class PigeonApiAdEventListener(open val pigeonRegistrar: PigeonProxyApi pigeon_instanceArg: com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) { Result.success(Unit) return @@ -3606,6 +3999,12 @@ abstract class PigeonApiAdEventListener(open val pigeonRegistrar: PigeonProxyApi eventArg: com.google.ads.interactivemedia.v3.api.AdEvent, callback: (Result) -> Unit ) { + if (pigeonRegistrar.ignoreCallsToDart) { + callback( + Result.failure( + FlutterError("ignore-calls-error", "Calls to Dart are being ignored.", ""))) + return + } val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.AdEventListener.onAdEvent" diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPlugin.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPlugin.kt index 5dd456e0d723..e56f58685dd3 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPlugin.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsPlugin.kt @@ -52,8 +52,9 @@ class InteractiveMediaAdsPlugin : FlutterPlugin, ActivityAware { } } -internal class FlutterViewFactory(private val instanceManager: PigeonInstanceManager) : - PlatformViewFactory(StandardMessageCodec.INSTANCE) { +internal class FlutterViewFactory( + private val instanceManager: InteractiveMediaAdsLibraryPigeonInstanceManager +) : PlatformViewFactory(StandardMessageCodec.INSTANCE) { override fun create(context: Context, viewId: Int, args: Any?): PlatformView { val identifier = diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ProxyApiRegistrar.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ProxyApiRegistrar.kt index ee15a91c2f35..eb86c8837ef2 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ProxyApiRegistrar.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ProxyApiRegistrar.kt @@ -10,11 +10,11 @@ import android.os.Looper import io.flutter.plugin.common.BinaryMessenger /** - * Implementation of [PigeonProxyApiRegistrar] that provides each ProxyApi implementation and any - * additional resources needed by an implementation. + * Implementation of [InteractiveMediaAdsLibraryPigeonProxyApiRegistrar] that provides each ProxyApi + * implementation and any additional resources needed by an implementation. */ -open class ProxyApiRegistrar(binaryMessenger: BinaryMessenger, var context: Context) : - PigeonProxyApiRegistrar(binaryMessenger) { +public open class ProxyApiRegistrar(binaryMessenger: BinaryMessenger, var context: Context) : + InteractiveMediaAdsLibraryPigeonProxyApiRegistrar(binaryMessenger) { // Added to be overriden for tests. The test implementation calls `callback` immediately, instead // of waiting for the main thread to run it. diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt new file mode 100644 index 000000000000..cd58b67aae2f --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt @@ -0,0 +1,35 @@ +// 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. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import org.mockito.kotlin.mock + +class ContentProgressProviderProxyApiTest { + @Test + fun pigeon_defaultConstructor() { + val api = TestProxyApiRegistrar().getPigeonApiContentProgressProvider() + + assertTrue( + api.pigeon_defaultConstructor() + is ContentProgressProviderProxyApi.ContentProgressProviderImpl) + } + + @Test + fun setContentProgress() { + val api = TestProxyApiRegistrar().getPigeonApiContentProgressProvider() + + val instance = + ContentProgressProviderProxyApi.ContentProgressProviderImpl( + api as ContentProgressProviderProxyApi) + val mockProgressUpdate = mock() + api.setContentProgress(instance, mockProgressUpdate) + + assertEquals(mockProgressUpdate, instance.currentProgress) + } +} diff --git a/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart b/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart new file mode 100644 index 000000000000..b084db02c638 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart @@ -0,0 +1,64 @@ +// 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. + +import 'dart:async'; + +import 'package:flutter/foundation.dart'; + +import '../platform_interface/platform_content_progress_provider.dart'; +import 'interactive_media_ads.g.dart' as ima; +import 'interactive_media_ads_proxy.dart'; + +/// Android implementation of [PlatformContentProgressProviderCreationParams]. +final class AndroidContentProgressProviderCreationParams + extends PlatformContentProgressProviderCreationParams { + /// Constructs a [AndroidContentProgressProviderCreationParams]. + const AndroidContentProgressProviderCreationParams({ + @visibleForTesting InteractiveMediaAdsProxy? proxy, + }) : _proxy = proxy ?? const InteractiveMediaAdsProxy(), + super(); + + /// Creates a [AndroidContentProgressProviderCreationParams] from an instance of + /// [PlatformContentProgressProviderCreationParams]. + factory AndroidContentProgressProviderCreationParams.fromPlatformContentProgressProviderCreationParams( + // Placeholder to prevent requiring a breaking change if params are added to + // PlatformContentProgressProviderCreationParams. + // ignore: avoid_unused_constructor_parameters + PlatformContentProgressProviderCreationParams params, { + @visibleForTesting InteractiveMediaAdsProxy? proxy, + }) { + return AndroidContentProgressProviderCreationParams(proxy: proxy); + } + + final InteractiveMediaAdsProxy _proxy; +} + +/// Android implementation of [PlatformContentProgressProvider]. +base class AndroidContentProgressProvider + extends PlatformContentProgressProvider { + /// Constructs an [AndroidContentProgressProvider]. + AndroidContentProgressProvider(super.params) : super.implementation(); + + late final ima.ContentProgressProvider _progressProvider = + _androidParams._proxy.newContentProgressProvider(); + + late final AndroidContentProgressProviderCreationParams _androidParams = + params is AndroidContentProgressProviderCreationParams + ? params as AndroidContentProgressProviderCreationParams + : AndroidContentProgressProviderCreationParams + .fromPlatformContentProgressProviderCreationParams( + params, + ); + + @override + Future setProgress(Duration progress) async { + throw UnimplementedError(); + // return _progressProvider.setContentProgress( + // _androidParams._proxy.newVideoProgressUpdate( + // currentTimeMs: progress.inMilliseconds, + // durationMs: null, + // ), + // ); + } +} diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart index 5ba85481c3bf..7e4c65591017 100644 --- a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart @@ -1,7 +1,7 @@ // 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 (v19.1.0), do not edit directly. +// Autogenerated from Pigeon (v21.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 @@ -423,7 +423,7 @@ class _PigeonInstanceManagerApi { } } -class _PigeonProxyApiBaseCodec extends StandardMessageCodec { +class _PigeonProxyApiBaseCodec extends _PigeonCodec { const _PigeonProxyApiBaseCodec(this.instanceManager); final PigeonInstanceManager instanceManager; @override @@ -637,6 +637,42 @@ enum AdEventType { unknown, } +class _PigeonCodec extends StandardMessageCodec { + const _PigeonCodec(); + @override + void writeValue(WriteBuffer buffer, Object? value) { + 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. @@ -1158,15 +1194,13 @@ class AdError extends PigeonProxyApiBaseClass { final int? arg_pigeon_instanceIdentifier = (args[0] as int?); assert(arg_pigeon_instanceIdentifier != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null int.'); - final AdErrorCode? arg_errorCode = - args[1] == null ? null : AdErrorCode.values[args[1]! as int]; + final AdErrorCode? arg_errorCode = (args[1] as AdErrorCode?); assert(arg_errorCode != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null AdErrorCode.'); final int? arg_errorCodeNumber = (args[2] as int?); assert(arg_errorCodeNumber != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null int.'); - final AdErrorType? arg_errorType = - args[3] == null ? null : AdErrorType.values[args[3]! as int]; + final AdErrorType? arg_errorType = (args[3] as AdErrorType?); assert(arg_errorType != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null, expected non-null AdErrorType.'); final String? arg_message = (args[4] as String?); @@ -1348,6 +1382,40 @@ class AdsRequest extends PigeonProxyApiBaseClass { /// /// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. class ContentProgressProvider extends PigeonProxyApiBaseClass { + ContentProgressProvider({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }) { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecContentProgressProvider; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + /// Constructs [ContentProgressProvider] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1358,6 +1426,9 @@ class ContentProgressProvider extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); + late final _PigeonProxyApiBaseCodec __pigeon_codecContentProgressProvider = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, BinaryMessenger? pigeon_binaryMessenger, @@ -1406,6 +1477,37 @@ class ContentProgressProvider extends PigeonProxyApiBaseClass { } } + /// Sets an update on the progress of the video. + /// + /// This is a custom method added to the native class because the native + /// method `getContentProgress` requires a synchronous return value. + Future setContentProgress(VideoProgressUpdate update) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecContentProgressProvider; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.setContentProgress'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, update]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + @override ContentProgressProvider pigeon_copy() { return ContentProgressProvider.pigeon_detached( @@ -1807,8 +1909,7 @@ class AdEvent extends PigeonProxyApiBaseClass { final int? arg_pigeon_instanceIdentifier = (args[0] as int?); assert(arg_pigeon_instanceIdentifier != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance was null, expected non-null int.'); - final AdEventType? arg_type = - args[1] == null ? null : AdEventType.values[args[1]! as int]; + final AdEventType? arg_type = (args[1] as AdEventType?); assert(arg_type != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance was null, expected non-null AdEventType.'); try { diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads_proxy.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads_proxy.dart index eff593541369..7aa120654e84 100644 --- a/packages/interactive_media_ads/lib/src/android/interactive_media_ads_proxy.dart +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads_proxy.dart @@ -16,6 +16,7 @@ import 'interactive_media_ads.g.dart'; class InteractiveMediaAdsProxy { /// Constructs an [InteractiveMediaAdsProxy]. const InteractiveMediaAdsProxy({ + this.newContentProgressProvider = ContentProgressProvider.new, this.newVideoProgressUpdate = VideoProgressUpdate.new, this.newFrameLayout = FrameLayout.new, this.newVideoView = VideoView.new, @@ -30,6 +31,9 @@ class InteractiveMediaAdsProxy { _videoTimeNotReadyVideoProgressUpdate, }); + /// Constructs [ContentProgressProvider]. + final ContentProgressProvider Function() newContentProgressProvider; + /// Constructs [VideoProgressUpdate]. final VideoProgressUpdate Function({ required int currentTimeMs, diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart index 972a1e6818c4..25d5ac2fef99 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -7,717 +7,725 @@ // Kotlin ProxyApi feature from pigeon. // ignore_for_file: avoid_unused_constructor_parameters // -// import 'package:pigeon/pigeon.dart'; -// -// @ConfigurePigeon( -// PigeonOptions( -// copyrightHeader: 'pigeons/copyright.txt', -// dartOut: 'lib/src/android/interactive_media_ads.g.dart', -// kotlinOut: -// 'android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt', -// kotlinOptions: KotlinOptions( -// package: 'dev.flutter.packages.interactive_media_ads', -// ), -// ), -// ) -// -// /// 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 `` 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, -// } -// -// /// 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. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.BaseDisplayContainer', -// ), -// ) -// abstract class BaseDisplayContainer {} -// -// /// 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. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdDisplayContainer', -// ), -// ) -// abstract class AdDisplayContainer implements BaseDisplayContainer {} -// -// /// 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. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsLoader', -// ), -// ) -// abstract class AdsLoader { -// /// Registers a listener for errors that occur during the ads request. -// void addAdErrorListener(AdErrorListener listener); -// -// /// Registers a listener for the ads manager loaded event. -// void addAdsLoadedListener(AdsLoadedListener listener); -// -// /// Requests ads from a server. -// void requestAds(AdsRequest request); -// } -// -// /// 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. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent', -// ), -// ) -// abstract class AdsManagerLoadedEvent { -// /// The ads manager that will control playback of the loaded ads, or null when -// /// using dynamic ad insertion. -// late final AdsManager manager; -// } -// -// /// An event raised when there is an error loading or playing ads. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdErrorEvent', -// ), -// ) -// abstract class AdErrorEvent { -// /// The AdError that caused this event. -// late final AdError error; -// } -// -// /// An error that occurred in the SDK. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdError', -// ), -// ) -// abstract class AdError { -// /// The error's code. -// late final AdErrorCode errorCode; -// -// /// The error code's number. -// late final int errorCodeNumber; -// -// /// The error's type. -// late final AdErrorType errorType; -// -// /// A human-readable summary of the error. -// late final String message; -// } -// -// /// An object containing the data used to request ads from the server. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsRequest', -// ), -// ) -// abstract class AdsRequest { -// /// Sets the URL from which ads will be requested. -// void setAdTagUrl(String adTagUrl); -// -// /// Attaches a ContentProgressProvider instance to allow scheduling ad breaks -// /// based on content progress (cue points). -// void setContentProgressProvider(ContentProgressProvider provider); -// } -// -// /// Defines an interface to allow SDK to track progress of the content video. -// /// -// /// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider', -// ), -// ) -// abstract class ContentProgressProvider {} -// -// /// An object which handles playing ads after they've been received from the -// /// server. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManager. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsManager', -// ), -// ) -// abstract class AdsManager extends BaseManager { -// /// Discards current ad break and resumes content. -// void discardAdBreak(); -// -// /// Pauses the current ad. -// void pause(); -// -// /// Starts playing the ads. -// void start(); -// } -// -// /// Base interface for managing ads.. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.BaseManager', -// ), -// ) -// abstract class BaseManager { -// /// Registers a listener for errors that occur during the ad or stream -// /// initialization and playback. -// void addAdErrorListener(AdErrorListener errorListener); -// -// /// Registers a listener for ad events that occur during ad or stream -// /// initialization and playback. -// void addAdEventListener(AdEventListener adEventListener); -// -// /// Stops the ad and all tracking, then releases all assets that were loaded -// /// to play the ad. -// void destroy(); -// -// /// Initializes the ad experience using default rendering settings -// void init(); -// } -// -// /// Event to notify publisher that an event occurred with an Ad. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdEvent', -// ), -// ) -// abstract class AdEvent { -// /// The type of event that occurred. -// late final AdEventType type; -// } -// -// /// Factory class for creating SDK objects. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkFactory', -// ), -// ) -// abstract class ImaSdkFactory { -// @static -// @attached -// late final ImaSdkFactory instance; -// -// @static -// AdDisplayContainer createAdDisplayContainer( -// ViewGroup container, -// VideoAdPlayer player, -// ); -// -// /// Creates an `ImaSdkSettings` object for configuring the IMA SDK. -// ImaSdkSettings createImaSdkSettings(); -// -// /// Creates an `AdsLoader` for requesting ads using the specified settings -// /// object. -// AdsLoader createAdsLoader( -// ImaSdkSettings settings, -// AdDisplayContainer container, -// ); -// -// /// Creates an AdsRequest object to contain the data used to request ads. -// AdsRequest createAdsRequest(); -// } -// -// /// Defines general SDK settings that are used when creating an `AdsLoader`. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkSettings', -// ), -// ) -// abstract class ImaSdkSettings {} -// -// /// Defines an update to the video's progress. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate', -// ), -// ) -// abstract class VideoProgressUpdate { -// VideoProgressUpdate(int currentTimeMs, int durationMs); -// -// /// Value to use for cases when progress is not yet defined, such as video -// /// initialization. -// @static -// @attached -// late final VideoProgressUpdate videoTimeNotReady; -// } -// -// /// The minimal information required to play an ad. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.player.AdMediaInfo', -// ), -// ) -// abstract class AdMediaInfo { -// late final String url; -// } -// -// /// An ad may be part of a pod of ads. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdPodInfo', -// ), -// ) -// abstract class AdPodInfo { -// /// The position of the ad within the pod. -// /// -// /// The value returned is one-based, for example, 1 of 2, 2 of 2, etc. If the -// /// ad is not part of a pod, this will return 1. -// late final int adPosition; -// -// /// The maximum duration of the pod in seconds. -// /// -// /// For unknown duration, -1 is returned. -// late final double maxDuration; -// -// /// Client side and DAI VOD: Returns the index of the ad pod. -// late final int podIndex; -// -// /// The content time offset at which the current ad pod was scheduled. -// /// -// /// For preroll pod, 0 is returned. For midrolls, the scheduled time is -// /// returned in seconds. For postroll, -1 is returned. Defaults to 0 if this -// /// ad is not part of a pod, or the pod is not part of an ad playlist. -// late final double timeOffset; -// -// /// The total number of ads contained within this pod, including bumpers. -// late final int totalAds; -// -// /// Returns true if the ad is a bumper ad. -// late final bool isBumper; -// } -// -// /// FrameLayout is designed to block out an area on the screen to display a -// /// single item. -// /// -// /// See https://developer.android.com/reference/android/widget/FrameLayout. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'android.widget.FrameLayout', -// ), -// ) -// abstract class FrameLayout extends ViewGroup { -// FrameLayout(); -// } -// -// /// A special view that can contain other views (called children.) -// /// -// /// See https://developer.android.com/reference/android/view/ViewGroup. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'android.view.ViewGroup', -// ), -// ) -// abstract class ViewGroup extends View { -// void addView(View view); -// } -// -// /// Displays a video file. -// /// -// /// See https://developer.android.com/reference/android/widget/VideoView. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'android.widget.VideoView', -// ), -// ) -// abstract class VideoView extends View { -// VideoView(); -// -// /// Callback to be invoked when the media source is ready for playback. -// late final void Function(MediaPlayer player)? onPrepared; -// -// /// Callback to be invoked when playback of a media source has completed. -// late final void Function(MediaPlayer player)? onCompletion; -// -// /// Callback to be invoked when there has been an error during an asynchronous -// /// operation. -// late final void Function(MediaPlayer player, int what, int extra) onError; -// -// /// Sets the URI of the video. -// void setVideoUri(String uri); -// -// /// The current position of the playing video. -// /// -// /// In milliseconds. -// int getCurrentPosition(); -// } -// -// /// This class represents the basic building block for user interface components. -// /// -// /// See https://developer.android.com/reference/android/view/View. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions(fullClassName: 'android.view.View'), -// ) -// abstract class View {} -// -// /// MediaPlayer class can be used to control playback of audio/video files and -// /// streams. -// /// -// /// See https://developer.android.com/reference/android/media/MediaPlayer. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: 'android.media.MediaPlayer', -// ), -// ) -// abstract class MediaPlayer { -// /// Gets the duration of the file. -// int getDuration(); -// -// /// Seeks to specified time position. -// void seekTo(int mSec); -// -// /// Starts or resumes playback. -// void start(); -// -// /// Pauses playback. -// void pause(); -// -// /// Stops playback after playback has been started or paused. -// void stop(); -// } -// -// /// Callbacks that the player must fire. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback', -// ), -// ) -// abstract class VideoAdPlayerCallback { -// /// Fire this callback periodically as ad playback occurs. -// void onAdProgress( -// AdMediaInfo adMediaInfo, -// VideoProgressUpdate videoProgressUpdate, -// ); -// -// /// Fire this callback when video playback stalls waiting for data. -// void onBuffering(AdMediaInfo adMediaInfo); -// -// /// Fire this callback when all content has finished playing. -// void onContentComplete(); -// -// /// Fire this callback when the video finishes playing. -// void onEnded(AdMediaInfo adMediaInfo); -// -// /// Fire this callback when the video has encountered an error. -// void onError(AdMediaInfo adMediaInfo); -// -// /// Fire this callback when the video is ready to begin playback. -// void onLoaded(AdMediaInfo adMediaInfo); -// -// /// Fire this callback when the video is paused. -// void onPause(AdMediaInfo adMediaInfo); -// -// /// Fire this callback when the player begins playing a video. -// void onPlay(AdMediaInfo adMediaInfo); -// -// /// Fire this callback when the video is unpaused. -// void onResume(AdMediaInfo adMediaInfo); -// -// /// Fire this callback when the playback volume changes. -// void onVolumeChanged(AdMediaInfo adMediaInfo, int percentage); -// } -// -// /// Defines the set of methods that a video player must implement to be used by -// /// the IMA SDK, as well as a set of callbacks that it must fire. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer', -// ), -// ) -// abstract class VideoAdPlayer { -// VideoAdPlayer(); -// -// /// Adds a callback. -// late final void Function(VideoAdPlayerCallback callback) addCallback; -// -// /// Loads a video ad hosted at AdMediaInfo. -// late final void Function(AdMediaInfo adMediaInfo, AdPodInfo adPodInfo) loadAd; -// -// /// Pauses playing the current ad. -// late final void Function(AdMediaInfo adMediaInfo) pauseAd; -// -// /// Starts or resumes playing the video ad referenced by the AdMediaInfo, -// /// provided loadAd has already been called for it. -// late final void Function(AdMediaInfo adMediaInfo) playAd; -// -// /// Cleans up and releases all resources used by the `VideoAdPlayer`. -// late final void Function() release; -// -// /// Removes a callback. -// late final void Function(VideoAdPlayerCallback callback) removeCallback; -// -// /// Stops playing the current ad. -// late final void Function(AdMediaInfo adMediaInfo) stopAd; -// -// /// The volume of the player as a percentage from 0 to 100. -// void setVolume(int value); -// -// /// The `VideoProgressUpdate` describing playback progress of the current -// /// video. -// void setAdProgress(VideoProgressUpdate progress); -// } -// -// /// Listener interface for notification of ad load or stream load completion. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener', -// ), -// ) -// abstract class AdsLoadedListener { -// AdsLoadedListener(); -// -// /// Called once the AdsManager or StreamManager has been loaded. -// late final void Function(AdsManagerLoadedEvent event) onAdsManagerLoaded; -// } -// -// /// Interface for classes that will listen to AdErrorEvents. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener', -// ), -// ) -// abstract class AdErrorListener { -// AdErrorListener(); -// -// /// Called when an error occurs. -// late final void Function(AdErrorEvent event) onAdError; -// } -// -// /// Listener interface for ad events. -// /// -// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. -// @ProxyApi( -// kotlinOptions: KotlinProxyApiOptions( -// fullClassName: -// 'com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener', -// ), -// ) -// abstract class AdEventListener { -// AdEventListener(); -// -// /// Respond to an occurrence of an AdEvent. -// late final void Function(AdEvent event) onAdEvent; -// } +import 'package:pigeon/pigeon.dart'; + +@ConfigurePigeon( + PigeonOptions( + copyrightHeader: 'pigeons/copyright.txt', + dartOut: 'lib/src/android/interactive_media_ads.g.dart', + kotlinOut: + 'android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt', + kotlinOptions: KotlinOptions( + package: 'dev.flutter.packages.interactive_media_ads', + ), + ), +) + +/// 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 `` 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, +} + +/// 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. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.BaseDisplayContainer', + ), +) +abstract class BaseDisplayContainer {} + +/// 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. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.AdDisplayContainer', + ), +) +abstract class AdDisplayContainer implements BaseDisplayContainer {} + +/// 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. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsLoader', + ), +) +abstract class AdsLoader { + /// Registers a listener for errors that occur during the ads request. + void addAdErrorListener(AdErrorListener listener); + + /// Registers a listener for the ads manager loaded event. + void addAdsLoadedListener(AdsLoadedListener listener); + + /// Requests ads from a server. + void requestAds(AdsRequest request); +} + +/// 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. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent', + ), +) +abstract class AdsManagerLoadedEvent { + /// The ads manager that will control playback of the loaded ads, or null when + /// using dynamic ad insertion. + late final AdsManager manager; +} + +/// An event raised when there is an error loading or playing ads. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.AdErrorEvent', + ), +) +abstract class AdErrorEvent { + /// The AdError that caused this event. + late final AdError error; +} + +/// An error that occurred in the SDK. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.AdError', + ), +) +abstract class AdError { + /// The error's code. + late final AdErrorCode errorCode; + + /// The error code's number. + late final int errorCodeNumber; + + /// The error's type. + late final AdErrorType errorType; + + /// A human-readable summary of the error. + late final String message; +} + +/// An object containing the data used to request ads from the server. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsRequest', + ), +) +abstract class AdsRequest { + /// Sets the URL from which ads will be requested. + void setAdTagUrl(String adTagUrl); + + /// Attaches a ContentProgressProvider instance to allow scheduling ad breaks + /// based on content progress (cue points). + void setContentProgressProvider(ContentProgressProvider provider); +} + +/// Defines an interface to allow SDK to track progress of the content video. +/// +/// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider', + ), +) +abstract class ContentProgressProvider { + ContentProgressProvider(); + + /// Sets an update on the progress of the video. + /// + /// This is a custom method added to the native class because the native + /// method `getContentProgress` requires a synchronous return value. + void setContentProgress(VideoProgressUpdate update); +} + +/// An object which handles playing ads after they've been received from the +/// server. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManager. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsManager', + ), +) +abstract class AdsManager extends BaseManager { + /// Discards current ad break and resumes content. + void discardAdBreak(); + + /// Pauses the current ad. + void pause(); + + /// Starts playing the ads. + void start(); +} + +/// Base interface for managing ads.. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.BaseManager', + ), +) +abstract class BaseManager { + /// Registers a listener for errors that occur during the ad or stream + /// initialization and playback. + void addAdErrorListener(AdErrorListener errorListener); + + /// Registers a listener for ad events that occur during ad or stream + /// initialization and playback. + void addAdEventListener(AdEventListener adEventListener); + + /// Stops the ad and all tracking, then releases all assets that were loaded + /// to play the ad. + void destroy(); + + /// Initializes the ad experience using default rendering settings + void init(); +} + +/// Event to notify publisher that an event occurred with an Ad. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.AdEvent', + ), +) +abstract class AdEvent { + /// The type of event that occurred. + late final AdEventType type; +} + +/// Factory class for creating SDK objects. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkFactory', + ), +) +abstract class ImaSdkFactory { + @static + @attached + late final ImaSdkFactory instance; + + @static + AdDisplayContainer createAdDisplayContainer( + ViewGroup container, + VideoAdPlayer player, + ); + + /// Creates an `ImaSdkSettings` object for configuring the IMA SDK. + ImaSdkSettings createImaSdkSettings(); + + /// Creates an `AdsLoader` for requesting ads using the specified settings + /// object. + AdsLoader createAdsLoader( + ImaSdkSettings settings, + AdDisplayContainer container, + ); + + /// Creates an AdsRequest object to contain the data used to request ads. + AdsRequest createAdsRequest(); +} + +/// Defines general SDK settings that are used when creating an `AdsLoader`. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkSettings', + ), +) +abstract class ImaSdkSettings {} + +/// Defines an update to the video's progress. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate', + ), +) +abstract class VideoProgressUpdate { + VideoProgressUpdate(int currentTimeMs, int durationMs); + + /// Value to use for cases when progress is not yet defined, such as video + /// initialization. + @static + @attached + late final VideoProgressUpdate videoTimeNotReady; +} + +/// The minimal information required to play an ad. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.player.AdMediaInfo', + ), +) +abstract class AdMediaInfo { + late final String url; +} + +/// An ad may be part of a pod of ads. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'com.google.ads.interactivemedia.v3.api.AdPodInfo', + ), +) +abstract class AdPodInfo { + /// The position of the ad within the pod. + /// + /// The value returned is one-based, for example, 1 of 2, 2 of 2, etc. If the + /// ad is not part of a pod, this will return 1. + late final int adPosition; + + /// The maximum duration of the pod in seconds. + /// + /// For unknown duration, -1 is returned. + late final double maxDuration; + + /// Client side and DAI VOD: Returns the index of the ad pod. + late final int podIndex; + + /// The content time offset at which the current ad pod was scheduled. + /// + /// For preroll pod, 0 is returned. For midrolls, the scheduled time is + /// returned in seconds. For postroll, -1 is returned. Defaults to 0 if this + /// ad is not part of a pod, or the pod is not part of an ad playlist. + late final double timeOffset; + + /// The total number of ads contained within this pod, including bumpers. + late final int totalAds; + + /// Returns true if the ad is a bumper ad. + late final bool isBumper; +} + +/// FrameLayout is designed to block out an area on the screen to display a +/// single item. +/// +/// See https://developer.android.com/reference/android/widget/FrameLayout. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'android.widget.FrameLayout', + ), +) +abstract class FrameLayout extends ViewGroup { + FrameLayout(); +} + +/// A special view that can contain other views (called children.) +/// +/// See https://developer.android.com/reference/android/view/ViewGroup. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'android.view.ViewGroup', + ), +) +abstract class ViewGroup extends View { + void addView(View view); +} + +/// Displays a video file. +/// +/// See https://developer.android.com/reference/android/widget/VideoView. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'android.widget.VideoView', + ), +) +abstract class VideoView extends View { + VideoView(); + + /// Callback to be invoked when the media source is ready for playback. + late final void Function(MediaPlayer player)? onPrepared; + + /// Callback to be invoked when playback of a media source has completed. + late final void Function(MediaPlayer player)? onCompletion; + + /// Callback to be invoked when there has been an error during an asynchronous + /// operation. + late final void Function(MediaPlayer player, int what, int extra) onError; + + /// Sets the URI of the video. + void setVideoUri(String uri); + + /// The current position of the playing video. + /// + /// In milliseconds. + int getCurrentPosition(); +} + +/// This class represents the basic building block for user interface components. +/// +/// See https://developer.android.com/reference/android/view/View. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions(fullClassName: 'android.view.View'), +) +abstract class View {} + +/// MediaPlayer class can be used to control playback of audio/video files and +/// streams. +/// +/// See https://developer.android.com/reference/android/media/MediaPlayer. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: 'android.media.MediaPlayer', + ), +) +abstract class MediaPlayer { + /// Gets the duration of the file. + int getDuration(); + + /// Seeks to specified time position. + void seekTo(int mSec); + + /// Starts or resumes playback. + void start(); + + /// Pauses playback. + void pause(); + + /// Stops playback after playback has been started or paused. + void stop(); +} + +/// Callbacks that the player must fire. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback', + ), +) +abstract class VideoAdPlayerCallback { + /// Fire this callback periodically as ad playback occurs. + void onAdProgress( + AdMediaInfo adMediaInfo, + VideoProgressUpdate videoProgressUpdate, + ); + + /// Fire this callback when video playback stalls waiting for data. + void onBuffering(AdMediaInfo adMediaInfo); + + /// Fire this callback when all content has finished playing. + void onContentComplete(); + + /// Fire this callback when the video finishes playing. + void onEnded(AdMediaInfo adMediaInfo); + + /// Fire this callback when the video has encountered an error. + void onError(AdMediaInfo adMediaInfo); + + /// Fire this callback when the video is ready to begin playback. + void onLoaded(AdMediaInfo adMediaInfo); + + /// Fire this callback when the video is paused. + void onPause(AdMediaInfo adMediaInfo); + + /// Fire this callback when the player begins playing a video. + void onPlay(AdMediaInfo adMediaInfo); + + /// Fire this callback when the video is unpaused. + void onResume(AdMediaInfo adMediaInfo); + + /// Fire this callback when the playback volume changes. + void onVolumeChanged(AdMediaInfo adMediaInfo, int percentage); +} + +/// Defines the set of methods that a video player must implement to be used by +/// the IMA SDK, as well as a set of callbacks that it must fire. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer', + ), +) +abstract class VideoAdPlayer { + VideoAdPlayer(); + + /// Adds a callback. + late final void Function(VideoAdPlayerCallback callback) addCallback; + + /// Loads a video ad hosted at AdMediaInfo. + late final void Function(AdMediaInfo adMediaInfo, AdPodInfo adPodInfo) loadAd; + + /// Pauses playing the current ad. + late final void Function(AdMediaInfo adMediaInfo) pauseAd; + + /// Starts or resumes playing the video ad referenced by the AdMediaInfo, + /// provided loadAd has already been called for it. + late final void Function(AdMediaInfo adMediaInfo) playAd; + + /// Cleans up and releases all resources used by the `VideoAdPlayer`. + late final void Function() release; + + /// Removes a callback. + late final void Function(VideoAdPlayerCallback callback) removeCallback; + + /// Stops playing the current ad. + late final void Function(AdMediaInfo adMediaInfo) stopAd; + + /// The volume of the player as a percentage from 0 to 100. + void setVolume(int value); + + /// The `VideoProgressUpdate` describing playback progress of the current + /// video. + void setAdProgress(VideoProgressUpdate progress); +} + +/// Listener interface for notification of ad load or stream load completion. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener', + ), +) +abstract class AdsLoadedListener { + AdsLoadedListener(); + + /// Called once the AdsManager or StreamManager has been loaded. + late final void Function(AdsManagerLoadedEvent event) onAdsManagerLoaded; +} + +/// Interface for classes that will listen to AdErrorEvents. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener', + ), +) +abstract class AdErrorListener { + AdErrorListener(); + + /// Called when an error occurs. + late final void Function(AdErrorEvent event) onAdError; +} + +/// Listener interface for ad events. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. +@ProxyApi( + kotlinOptions: KotlinProxyApiOptions( + fullClassName: + 'com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener', + ), +) +abstract class AdEventListener { + AdEventListener(); + + /// Respond to an occurrence of an AdEvent. + late final void Function(AdEvent event) onAdEvent; +} diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml index 1c9dcbb586eb..940b3ea193eb 100644 --- a/packages/interactive_media_ads/pubspec.yaml +++ b/packages/interactive_media_ads/pubspec.yaml @@ -31,6 +31,11 @@ dev_dependencies: flutter_test: sdk: flutter mockito: 5.4.4 + pigeon: + git: + url: git@github.com:bparrishMines/packages.git + ref: pigeon_kotlin_split + path: packages/pigeon topics: - ads From 427ded94e56fd29da502a8c1f5dcc14bc31baa11 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:24:05 -0400 Subject: [PATCH 03/26] pass progress and duration to set progress --- .../android_content_progress_provider.dart | 18 ++++++++------- .../lib/src/content_progress_provider.dart | 7 ++++-- .../platform_content_progress_provider.dart | 5 ++++- .../test/content_progress_provider_test.dart | 22 +++++++++++++++---- .../test/test_stubs.dart | 12 +++++++--- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart b/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart index b084db02c638..53df1f47ddf1 100644 --- a/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart +++ b/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart @@ -52,13 +52,15 @@ base class AndroidContentProgressProvider ); @override - Future setProgress(Duration progress) async { - throw UnimplementedError(); - // return _progressProvider.setContentProgress( - // _androidParams._proxy.newVideoProgressUpdate( - // currentTimeMs: progress.inMilliseconds, - // durationMs: null, - // ), - // ); + Future setProgress({ + required Duration progress, + required Duration duration, + }) async { + return _progressProvider.setContentProgress( + _androidParams._proxy.newVideoProgressUpdate( + currentTimeMs: progress.inMilliseconds, + durationMs: duration.inMilliseconds, + ), + ); } } diff --git a/packages/interactive_media_ads/lib/src/content_progress_provider.dart b/packages/interactive_media_ads/lib/src/content_progress_provider.dart index 490acbc47d8c..46b569709e66 100644 --- a/packages/interactive_media_ads/lib/src/content_progress_provider.dart +++ b/packages/interactive_media_ads/lib/src/content_progress_provider.dart @@ -80,7 +80,10 @@ class ContentProgressProvider { final PlatformContentProgressProvider platform; /// Sends an update on the progress of the content video. - Future setProgress(Duration progress) { - return platform.setProgress(progress); + Future setProgress({ + required Duration progress, + required Duration duration, + }) { + return platform.setProgress(progress: progress, duration: duration); } } diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_content_progress_provider.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_content_progress_provider.dart index 24cad7bc5820..fb5c54a563ea 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/platform_content_progress_provider.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_content_progress_provider.dart @@ -79,5 +79,8 @@ abstract class PlatformContentProgressProvider { final PlatformContentProgressProviderCreationParams params; /// Sends an update on the progress of the content video. - Future setProgress(Duration progress); + Future setProgress({ + required Duration progress, + required Duration duration, + }); } diff --git a/packages/interactive_media_ads/test/content_progress_provider_test.dart b/packages/interactive_media_ads/test/content_progress_provider_test.dart index c218a076c18a..180d9ce0d015 100644 --- a/packages/interactive_media_ads/test/content_progress_provider_test.dart +++ b/packages/interactive_media_ads/test/content_progress_provider_test.dart @@ -10,18 +10,32 @@ import 'test_stubs.dart'; void main() { test('setProgress', () async { + late final Duration callbackProgress; + late final Duration callbackDuration; + final TestContentProgressProvider platformProvider = TestContentProgressProvider( const PlatformContentProgressProviderCreationParams(), - onSetProgress: expectAsync1((Duration progress) async { - expect(progress, equals(const Duration(seconds: 1))); - }), + onSetProgress: ({ + required Duration progress, + required Duration duration, + }) async { + callbackProgress = progress; + callbackDuration = duration; + }, ); final ContentProgressProvider provider = ContentProgressProvider.fromPlatform( platformProvider, ); - await provider.setProgress(const Duration(seconds: 1)); + + await provider.setProgress( + progress: const Duration(seconds: 1), + duration: const Duration(seconds: 10), + ); + + expect(callbackProgress, const Duration(seconds: 1)); + expect(callbackDuration, const Duration(seconds: 10)); }); } diff --git a/packages/interactive_media_ads/test/test_stubs.dart b/packages/interactive_media_ads/test/test_stubs.dart index ca9ea4d25e2c..f4e47fd41eb1 100644 --- a/packages/interactive_media_ads/test/test_stubs.dart +++ b/packages/interactive_media_ads/test/test_stubs.dart @@ -145,10 +145,16 @@ class TestContentProgressProvider extends PlatformContentProgressProvider { this.onSetProgress, }) : super.implementation(); - Future Function(Duration progress)? onSetProgress; + Future Function({ + required Duration progress, + required Duration duration, + })? onSetProgress; @override - Future setProgress(Duration progress) async { - return onSetProgress?.call(progress); + Future setProgress({ + required Duration progress, + required Duration duration, + }) async { + return onSetProgress?.call(progress: progress, duration: duration); } } From e8fd08d2fa88812f831df7d00019dff32775349e Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:08:22 -0400 Subject: [PATCH 04/26] android implementation mostly --- .../AdsRequestProxyApi.kt | 4 ++ .../InteractiveMediaAdsLibrary.g.kt | 30 ++++++++++++++ .../AdsRequestProxyApiTest.kt | 10 +++++ .../ContentProgressProviderProxyApiTest.kt | 1 + .../lib/src/android/android_ads_loader.dart | 4 ++ .../src/android/interactive_media_ads.g.dart | 28 +++++++++++++ .../interactive_media_ads_android.dart | 3 ++ .../test/android/ads_loader_test.dart | 8 +++- .../test/android/ads_loader_test.mocks.dart | 10 +++++ .../test/ios/ads_loader_test.mocks.dart | 40 +++++++++++++++++++ .../test/ios/ads_manager_delegate_tests.dart | 2 - .../test/ios/ads_manager_tests.mocks.dart | 40 +++++++++++++++++++ 12 files changed, 177 insertions(+), 3 deletions(-) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt index 3f828b5d587f..b39fe6de6e90 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt @@ -38,4 +38,8 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : ) { pigeon_instance.contentProgressProvider = provider } + + override fun setContentDuration(pigeon_instance: AdsRequest, duration: Double) { + pigeon_instance.setContentDuration(duration.toFloat()) + } } diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index 6091cdfca4b6..73f13fc3962e 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -1333,6 +1333,12 @@ abstract class PigeonApiAdsRequest( provider: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider ) + /** Specifies the duration of the content in seconds to be shown. */ + abstract fun setContentDuration( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest, + duration: Double + ) + companion object { @Suppress("LocalVariableName") fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdsRequest?) { @@ -1386,6 +1392,30 @@ abstract class PigeonApiAdsRequest( channel.setMessageHandler(null) } } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentDuration", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest + val durationArg = args[1] as Double + val wrapped: List = + try { + api.setContentDuration(pigeon_instanceArg, durationArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } } } diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt index 42f0cc88b84e..ee4061771de5 100644 --- a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt @@ -32,4 +32,14 @@ class AdsRequestProxyApiTest { verify(instance).contentProgressProvider = mockProvider } + + @Test + fun setContentDuration() { + val api = TestProxyApiRegistrar().getPigeonApiAdsRequest() + + val instance = mock() + api.setContentDuration(instance, 2.0) + + verify(instance).setContentDuration(2.0f) + } } diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt index cd58b67aae2f..55c8accb055e 100644 --- a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt @@ -31,5 +31,6 @@ class ContentProgressProviderProxyApiTest { api.setContentProgress(instance, mockProgressUpdate) assertEquals(mockProgressUpdate, instance.currentProgress) + assertEquals(mockProgressUpdate, instance.contentProgress) } } diff --git a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart index 58fe19c0bdc8..9a82f58311d9 100644 --- a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart +++ b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart @@ -86,6 +86,10 @@ base class AndroidAdsLoader extends PlatformAdsLoader { await Future.wait(>[ androidRequest.setAdTagUrl(request.adTagUrl), + if (request.contentDuration != null) + androidRequest.setContentDuration( + request.contentDuration!.inSeconds.toDouble(), + ), adsLoader.requestAds(androidRequest), ]); } diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart index 7e4c65591017..bd9a478b3c9a 100644 --- a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart @@ -1369,6 +1369,34 @@ class AdsRequest extends PigeonProxyApiBaseClass { } } + /// Specifies the duration of the content in seconds to be shown. + Future setContentDuration(double duration) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecAdsRequest; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentDuration'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, duration]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + @override AdsRequest pigeon_copy() { return AdsRequest.pigeon_detached( diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart index 25d5ac2fef99..2af03f14a40d 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -316,6 +316,9 @@ abstract class AdsRequest { /// Attaches a ContentProgressProvider instance to allow scheduling ad breaks /// based on content progress (cue points). void setContentProgressProvider(ContentProgressProvider provider); + + /// Specifies the duration of the content in seconds to be shown. + void setContentDuration(double duration); } /// Defines an interface to allow SDK to track progress of the content video. diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.dart b/packages/interactive_media_ads/test/android/ads_loader_test.dart index 3446c4e899ad..2b79559f7116 100644 --- a/packages/interactive_media_ads/test/android/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/android/ads_loader_test.dart @@ -105,10 +105,16 @@ void main() { ), ); - await adsLoader.requestAds(AdsRequest(adTagUrl: 'url')); + await adsLoader.requestAds( + AdsRequest( + adTagUrl: 'url', + contentDuration: const Duration(seconds: 1), + ), + ); verifyInOrder(>[ mockAdsRequest.setAdTagUrl('url'), + mockAdsRequest.setContentDuration(1.0), mockAdsLoader.requestAds(mockAdsRequest), ]); }); diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart b/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart index bdcfc1f4d54c..c72e048d9d13 100644 --- a/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart +++ b/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart @@ -799,6 +799,16 @@ class MockAdsRequest extends _i1.Mock implements _i2.AdsRequest { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); + @override + _i6.Future setContentDuration(double? duration) => (super.noSuchMethod( + Invocation.method( + #setContentDuration, + [duration], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override _i2.AdsRequest pigeon_copy() => (super.noSuchMethod( Invocation.method( diff --git a/packages/interactive_media_ads/test/ios/ads_loader_test.mocks.dart b/packages/interactive_media_ads/test/ios/ads_loader_test.mocks.dart index 64c4de9ed314..2be4284c1ce1 100644 --- a/packages/interactive_media_ads/test/ios/ads_loader_test.mocks.dart +++ b/packages/interactive_media_ads/test/ios/ads_loader_test.mocks.dart @@ -356,6 +356,46 @@ class MockIMAAdsManager extends _i1.Mock implements _i2.IMAAdsManager { returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); + @override + _i3.Future pause() => (super.noSuchMethod( + Invocation.method( + #pause, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + _i3.Future resume() => (super.noSuchMethod( + Invocation.method( + #resume, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + _i3.Future skip() => (super.noSuchMethod( + Invocation.method( + #skip, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + _i3.Future discardAdBreak() => (super.noSuchMethod( + Invocation.method( + #discardAdBreak, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + @override _i3.Future destroy() => (super.noSuchMethod( Invocation.method( diff --git a/packages/interactive_media_ads/test/ios/ads_manager_delegate_tests.dart b/packages/interactive_media_ads/test/ios/ads_manager_delegate_tests.dart index 398d8600e058..4399a2b17102 100644 --- a/packages/interactive_media_ads/test/ios/ads_manager_delegate_tests.dart +++ b/packages/interactive_media_ads/test/ios/ads_manager_delegate_tests.dart @@ -8,9 +8,7 @@ import 'package:interactive_media_ads/src/ios/interactive_media_ads.g.dart' import 'package:interactive_media_ads/src/ios/interactive_media_ads_proxy.dart'; import 'package:interactive_media_ads/src/ios/ios_ads_manager_delegate.dart'; import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart'; -import 'package:mockito/annotations.dart'; -@GenerateNiceMocks(>[MockSpec()]) void main() { group('IOSAdsManagerDelegate', () { test('didReceiveAdEvent calls onAdEvent', () { diff --git a/packages/interactive_media_ads/test/ios/ads_manager_tests.mocks.dart b/packages/interactive_media_ads/test/ios/ads_manager_tests.mocks.dart index 54b13f521920..07a1b5252426 100644 --- a/packages/interactive_media_ads/test/ios/ads_manager_tests.mocks.dart +++ b/packages/interactive_media_ads/test/ios/ads_manager_tests.mocks.dart @@ -93,6 +93,46 @@ class MockIMAAdsManager extends _i1.Mock implements _i2.IMAAdsManager { returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); + @override + _i3.Future pause() => (super.noSuchMethod( + Invocation.method( + #pause, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + _i3.Future resume() => (super.noSuchMethod( + Invocation.method( + #resume, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + _i3.Future skip() => (super.noSuchMethod( + Invocation.method( + #skip, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + _i3.Future discardAdBreak() => (super.noSuchMethod( + Invocation.method( + #discardAdBreak, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + @override _i3.Future destroy() => (super.noSuchMethod( Invocation.method( From 55e080b78617bdb427004773fa30b4d64e6a9a24 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:30:47 -0400 Subject: [PATCH 05/26] separate adsrequest into its own app-facing class --- .../lib/interactive_media_ads.dart | 4 +- .../lib/src/ads_loader.dart | 3 +- .../lib/src/ads_request.dart | 42 +++++++++++++++++++ .../lib/src/android/android_ads_loader.dart | 2 +- .../lib/src/ios/ios_ads_loader.dart | 2 +- .../platform_ads_loader.dart | 4 +- ...request.dart => platform_ads_request.dart} | 6 +-- .../platform_interface.dart | 2 +- .../test/ads_loader_test.dart | 8 ++-- .../test/ads_manager_test.dart | 2 +- .../test/android/ads_loader_test.dart | 2 +- .../test/ios/ads_loader_test.dart | 2 +- .../test/test_stubs.dart | 4 +- 13 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 packages/interactive_media_ads/lib/src/ads_request.dart rename packages/interactive_media_ads/lib/src/platform_interface/{ads_request.dart => platform_ads_request.dart} (89%) diff --git a/packages/interactive_media_ads/lib/interactive_media_ads.dart b/packages/interactive_media_ads/lib/interactive_media_ads.dart index 954a27c9049a..ba3d8e1d52d2 100644 --- a/packages/interactive_media_ads/lib/interactive_media_ads.dart +++ b/packages/interactive_media_ads/lib/interactive_media_ads.dart @@ -5,6 +5,7 @@ export 'src/ad_display_container.dart'; export 'src/ads_loader.dart'; export 'src/ads_manager_delegate.dart'; +export 'src/ads_request.dart'; export 'src/android/android_interactive_media_ads.dart' show AndroidInteractiveMediaAds; export 'src/ios/ios_interactive_media_ads.dart' show IOSInteractiveMediaAds; @@ -16,5 +17,4 @@ export 'src/platform_interface/platform_interface.dart' AdErrorType, AdEvent, AdEventType, - AdsLoadErrorData, - AdsRequest; + AdsLoadErrorData; diff --git a/packages/interactive_media_ads/lib/src/ads_loader.dart b/packages/interactive_media_ads/lib/src/ads_loader.dart index 4ab3a97c1477..9647b11411dd 100644 --- a/packages/interactive_media_ads/lib/src/ads_loader.dart +++ b/packages/interactive_media_ads/lib/src/ads_loader.dart @@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart'; import 'ad_display_container.dart'; import 'ads_manager_delegate.dart'; +import 'ads_request.dart'; import 'platform_interface/platform_interface.dart'; /// Allows publishers to request ads from ad servers or a dynamic ad insertion @@ -97,7 +98,7 @@ class AdsLoader { /// Ads cannot be requested until the `AdDisplayContainer` has been added to /// the native View hierarchy. See [AdDisplayContainer.onContainerAdded]. Future requestAds(AdsRequest request) { - return platform.requestAds(request); + return platform.requestAds(request.platform); } } diff --git a/packages/interactive_media_ads/lib/src/ads_request.dart b/packages/interactive_media_ads/lib/src/ads_request.dart new file mode 100644 index 000000000000..3f37699c2bf7 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/ads_request.dart @@ -0,0 +1,42 @@ +// 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. + +import 'content_progress_provider.dart'; +import 'platform_interface/platform_ads_request.dart'; + +/// An object containing the data used to request ads from the server. +class AdsRequest { + /// Creates an [AdsRequest]. + AdsRequest({ + required String adTagUrl, + Duration? contentDuration, + ContentProgressProvider? contentProgressProvider, + }) : this.fromPlatform( + PlatformAdsRequest( + adTagUrl: adTagUrl, + contentDuration: contentDuration, + contentProgressProvider: contentProgressProvider?.platform, + ), + ); + + /// Constructs an [AdsRequest] from a specific platform implementation. + AdsRequest.fromPlatform(this.platform); + + /// Implementation of [PlatformAdsRequest] for the current platform. + final PlatformAdsRequest platform; + + /// The URL from which ads will be requested. + String get adTagUrl => platform.adTagUrl; + + /// The duration of the content video to be shown. + Duration? get contentDuration => platform.contentDuration; + + /// A [ContentProgressProvider] instance to allow scheduling of ad breaks + /// based on content progress (cue points). + ContentProgressProvider? get contentProgressProvider => platform + .contentProgressProvider != + null + ? ContentProgressProvider.fromPlatform(platform.contentProgressProvider!) + : null; +} diff --git a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart index 9a82f58311d9..94533eb29628 100644 --- a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart +++ b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart @@ -79,7 +79,7 @@ base class AndroidAdsLoader extends PlatformAdsLoader { } @override - Future requestAds(AdsRequest request) async { + Future requestAds(PlatformAdsRequest request) async { final ima.AdsLoader adsLoader = await _adsLoaderFuture; final ima.AdsRequest androidRequest = await _sdkFactory.createAdsRequest(); diff --git a/packages/interactive_media_ads/lib/src/ios/ios_ads_loader.dart b/packages/interactive_media_ads/lib/src/ios/ios_ads_loader.dart index d0f68646570d..b25ef27dae48 100644 --- a/packages/interactive_media_ads/lib/src/ios/ios_ads_loader.dart +++ b/packages/interactive_media_ads/lib/src/ios/ios_ads_loader.dart @@ -72,7 +72,7 @@ base class IOSAdsLoader extends PlatformAdsLoader { } @override - Future requestAds(AdsRequest request) async { + Future requestAds(PlatformAdsRequest request) async { return _adsLoader.requestAds(_iosParams._proxy.newIMAAdsRequest( adTagUrl: request.adTagUrl, adDisplayContainer: diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart index 7dc6a57a1d22..51ed2a64e686 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_loader.dart @@ -5,10 +5,10 @@ import 'package:flutter/foundation.dart'; import 'ad_error.dart'; -import 'ads_request.dart'; import 'interactive_media_ads_platform.dart'; import 'platform_ad_display_container.dart'; import 'platform_ads_manager.dart'; +import 'platform_ads_request.dart'; /// Object specifying creation parameters for creating a [PlatformAdsLoader]. /// @@ -94,7 +94,7 @@ abstract base class PlatformAdsLoader { Future contentComplete(); /// Requests ads from a server. - Future requestAds(AdsRequest request); + Future requestAds(PlatformAdsRequest request); } /// Data when ads are successfully loaded from the ad server through an diff --git a/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_request.dart similarity index 89% rename from packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart rename to packages/interactive_media_ads/lib/src/platform_interface/platform_ads_request.dart index 38bf7cc5177b..8f7035346d70 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/ads_request.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_request.dart @@ -5,9 +5,9 @@ import 'platform_content_progress_provider.dart'; /// An object containing the data used to request ads from the server. -class AdsRequest { - /// Creates an [AdsRequest]. - AdsRequest({ +class PlatformAdsRequest { + /// Creates an [PlatformAdsRequest]. + PlatformAdsRequest({ required this.adTagUrl, this.contentDuration, this.contentProgressProvider, diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart index ad8896480443..cc727464b60c 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart @@ -4,9 +4,9 @@ export 'ad_error.dart'; export 'ad_event.dart'; -export 'ads_request.dart'; export 'interactive_media_ads_platform.dart'; export 'platform_ad_display_container.dart'; export 'platform_ads_loader.dart'; export 'platform_ads_manager.dart'; export 'platform_ads_manager_delegate.dart'; +export 'platform_ads_request.dart'; diff --git a/packages/interactive_media_ads/test/ads_loader_test.dart b/packages/interactive_media_ads/test/ads_loader_test.dart index 424c86ccc1d5..bea867e371fa 100644 --- a/packages/interactive_media_ads/test/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/ads_loader_test.dart @@ -18,7 +18,7 @@ void main() { onAdsLoadError: (AdsLoadErrorData data) {}, ), onContentComplete: expectAsync0(() async {}), - onRequestAds: (AdsRequest request) async {}, + onRequestAds: (PlatformAdsRequest request) async {}, ); final AdsLoader loader = AdsLoader.fromPlatform(adsLoader); @@ -32,12 +32,14 @@ void main() { onAdsLoaded: (PlatformOnAdsLoadedData data) {}, onAdsLoadError: (AdsLoadErrorData data) {}, ), - onRequestAds: expectAsync1((AdsRequest request) async {}), + onRequestAds: expectAsync1((PlatformAdsRequest request) async {}), onContentComplete: () async {}, ); final AdsLoader loader = AdsLoader.fromPlatform(adsLoader); - await loader.requestAds(AdsRequest(adTagUrl: '')); + await loader.requestAds( + AdsRequest.fromPlatform(PlatformAdsRequest(adTagUrl: '')), + ); }); } diff --git a/packages/interactive_media_ads/test/ads_manager_test.dart b/packages/interactive_media_ads/test/ads_manager_test.dart index 204b0173b5ec..489371984c6c 100644 --- a/packages/interactive_media_ads/test/ads_manager_test.dart +++ b/packages/interactive_media_ads/test/ads_manager_test.dart @@ -56,7 +56,7 @@ AdsManager createAdsManager(PlatformAdsManager platformManager) { onCreatePlatformAdsLoader: (PlatformAdsLoaderCreationParams params) { return TestPlatformAdsLoader(params, onContentComplete: () async {}, - onRequestAds: (AdsRequest request) async {}); + onRequestAds: (PlatformAdsRequest request) async {}); }, onCreatePlatformAdsManagerDelegate: (PlatformAdsManagerDelegateCreationParams params) { diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.dart b/packages/interactive_media_ads/test/android/ads_loader_test.dart index 2b79559f7116..80c18797c9e0 100644 --- a/packages/interactive_media_ads/test/android/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/android/ads_loader_test.dart @@ -106,7 +106,7 @@ void main() { ); await adsLoader.requestAds( - AdsRequest( + PlatformAdsRequest( adTagUrl: 'url', contentDuration: const Duration(seconds: 1), ), diff --git a/packages/interactive_media_ads/test/ios/ads_loader_test.dart b/packages/interactive_media_ads/test/ios/ads_loader_test.dart index 04ea706d2128..7354e214eba6 100644 --- a/packages/interactive_media_ads/test/ios/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/ios/ads_loader_test.dart @@ -92,7 +92,7 @@ void main() { ), ); - await loader.requestAds(AdsRequest(adTagUrl: adTag)); + await loader.requestAds(PlatformAdsRequest(adTagUrl: adTag)); verify(mockLoader.requestAds(any)); }); diff --git a/packages/interactive_media_ads/test/test_stubs.dart b/packages/interactive_media_ads/test/test_stubs.dart index f4e47fd41eb1..8d4e4c4406af 100644 --- a/packages/interactive_media_ads/test/test_stubs.dart +++ b/packages/interactive_media_ads/test/test_stubs.dart @@ -82,7 +82,7 @@ final class TestPlatformAdsLoader extends PlatformAdsLoader { Future Function() onContentComplete; - Future Function(AdsRequest request) onRequestAds; + Future Function(PlatformAdsRequest request) onRequestAds; @override Future contentComplete() async { @@ -90,7 +90,7 @@ final class TestPlatformAdsLoader extends PlatformAdsLoader { } @override - Future requestAds(AdsRequest request) async { + Future requestAds(PlatformAdsRequest request) async { return onRequestAds(request); } } From 76efd5a8e3b7d1f15ed335f5d154dd9724b0e779 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:46:46 -0400 Subject: [PATCH 06/26] finish android impl and add to example app --- .../example/lib/main.dart | 27 ++++++++++++++++++- .../lib/interactive_media_ads.dart | 1 + .../lib/src/android/android_ads_loader.dart | 6 +++++ .../android_content_progress_provider.dart | 10 ++++--- .../android_interactive_media_ads.dart | 4 +-- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index 8cac5c867b88..b872f72cb73c 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -61,6 +61,11 @@ class _AdExampleWidgetState extends State { }, ); + Timer? _contentProgressTimer; + + final ContentProgressProvider _contentProgressProvider = + ContentProgressProvider(); + @override void initState() { super.initState(); @@ -121,13 +126,30 @@ class _AdExampleWidgetState extends State { }, ); - return _adsLoader.requestAds(AdsRequest(adTagUrl: _adTagUrl)); + return _adsLoader.requestAds(AdsRequest( + adTagUrl: _adTagUrl, + contentProgressProvider: _contentProgressProvider, + )); } Future _resumeContent() { setState(() { _shouldShowContentVideo = true; }); + _contentProgressTimer = Timer.periodic( + const Duration(milliseconds: 500), + (Timer timer) async { + if (_contentVideoController.value.isInitialized) { + final Duration? progress = await _contentVideoController.position; + if (progress != null) { + await _contentProgressProvider.setProgress( + progress: progress, + duration: _contentVideoController.value.duration, + ); + } + } + }, + ); return _contentVideoController.play(); } @@ -135,6 +157,8 @@ class _AdExampleWidgetState extends State { setState(() { _shouldShowContentVideo = false; }); + _contentProgressTimer?.cancel(); + _contentProgressTimer = null; return _contentVideoController.pause(); } // #enddocregion request_ads @@ -143,6 +167,7 @@ class _AdExampleWidgetState extends State { @override void dispose() { super.dispose(); + _contentProgressTimer?.cancel(); _contentVideoController.dispose(); _adsManager?.destroy(); } diff --git a/packages/interactive_media_ads/lib/interactive_media_ads.dart b/packages/interactive_media_ads/lib/interactive_media_ads.dart index ba3d8e1d52d2..06c180248410 100644 --- a/packages/interactive_media_ads/lib/interactive_media_ads.dart +++ b/packages/interactive_media_ads/lib/interactive_media_ads.dart @@ -8,6 +8,7 @@ export 'src/ads_manager_delegate.dart'; export 'src/ads_request.dart'; export 'src/android/android_interactive_media_ads.dart' show AndroidInteractiveMediaAds; +export 'src/content_progress_provider.dart'; export 'src/ios/ios_interactive_media_ads.dart' show IOSInteractiveMediaAds; export 'src/platform_interface/platform_interface.dart' show diff --git a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart index 94533eb29628..3da8d2fb4274 100644 --- a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart +++ b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart @@ -9,6 +9,7 @@ import 'package:flutter/widgets.dart'; import '../platform_interface/platform_interface.dart'; import 'android_ad_display_container.dart'; import 'android_ads_manager.dart'; +import 'android_content_progress_provider.dart'; import 'enum_converter_utils.dart'; import 'interactive_media_ads.g.dart' as ima; import 'interactive_media_ads_proxy.dart'; @@ -90,6 +91,11 @@ base class AndroidAdsLoader extends PlatformAdsLoader { androidRequest.setContentDuration( request.contentDuration!.inSeconds.toDouble(), ), + if (request.contentProgressProvider != null) + androidRequest.setContentProgressProvider( + (request.contentProgressProvider! as AndroidContentProgressProvider) + .progressProvider, + ), adsLoader.requestAds(androidRequest), ]); } diff --git a/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart b/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart index 53df1f47ddf1..e3f4d57c2955 100644 --- a/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart +++ b/packages/interactive_media_ads/lib/src/android/android_content_progress_provider.dart @@ -4,7 +4,7 @@ import 'dart:async'; -import 'package:flutter/foundation.dart'; +import 'package:meta/meta.dart'; import '../platform_interface/platform_content_progress_provider.dart'; import 'interactive_media_ads.g.dart' as ima; @@ -40,7 +40,11 @@ base class AndroidContentProgressProvider /// Constructs an [AndroidContentProgressProvider]. AndroidContentProgressProvider(super.params) : super.implementation(); - late final ima.ContentProgressProvider _progressProvider = + /// The native Android ContentProgressProvider. + /// + /// This allows the SDK to track progress of the content video. + @internal + late final ima.ContentProgressProvider progressProvider = _androidParams._proxy.newContentProgressProvider(); late final AndroidContentProgressProviderCreationParams _androidParams = @@ -56,7 +60,7 @@ base class AndroidContentProgressProvider required Duration progress, required Duration duration, }) async { - return _progressProvider.setContentProgress( + return progressProvider.setContentProgress( _androidParams._proxy.newVideoProgressUpdate( currentTimeMs: progress.inMilliseconds, durationMs: duration.inMilliseconds, diff --git a/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart b/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart index d1ad7370f412..0f05362a6919 100644 --- a/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart +++ b/packages/interactive_media_ads/lib/src/android/android_interactive_media_ads.dart @@ -10,6 +10,7 @@ import '../platform_interface/platform_content_progress_provider.dart'; import 'android_ad_display_container.dart'; import 'android_ads_loader.dart'; import 'android_ads_manager_delegate.dart'; +import 'android_content_progress_provider.dart'; /// Android implementation of [InteractiveMediaAdsPlatform]. final class AndroidInteractiveMediaAds extends InteractiveMediaAdsPlatform { @@ -43,7 +44,6 @@ final class AndroidInteractiveMediaAds extends InteractiveMediaAdsPlatform { PlatformContentProgressProvider createPlatformContentProgressProvider( PlatformContentProgressProviderCreationParams params, ) { - // TODO: implement createPlatformContentProgressProvider - throw UnimplementedError(); + return AndroidContentProgressProvider(params); } } From 83ac065322c2bcd3ae90b7598018106256856e19 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 7 Aug 2024 14:36:43 -0400 Subject: [PATCH 07/26] working mid rolls --- .../example/lib/main.dart | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index b872f72cb73c..469421479a16 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -33,10 +33,10 @@ class AdExampleWidget extends StatefulWidget { } class _AdExampleWidgetState extends State { - // IMA sample tag for a single skippable inline video ad. See more IMA sample + // IMA sample tag for a single Pre-, Mid-, and Post-roll video ad. See more IMA sample // tags at https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags static const String _adTagUrl = - 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator='; + 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpost&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator='; // The AdsLoader instance exposes the request ads method. late final AdsLoader _adsLoader; @@ -132,25 +132,31 @@ class _AdExampleWidgetState extends State { )); } - Future _resumeContent() { + Future _resumeContent() async { setState(() { _shouldShowContentVideo = true; }); - _contentProgressTimer = Timer.periodic( - const Duration(milliseconds: 500), - (Timer timer) async { - if (_contentVideoController.value.isInitialized) { - final Duration? progress = await _contentVideoController.position; - if (progress != null) { - await _contentProgressProvider.setProgress( - progress: progress, - duration: _contentVideoController.value.duration, - ); + + if (_adsManager != null) { + _contentProgressTimer = Timer.periodic( + const Duration(milliseconds: 500), + (Timer timer) async { + if (_contentVideoController.value.isInitialized) { + final Duration? progress = await _contentVideoController.position; + if (progress != null) { + await _contentProgressProvider.setProgress( + progress: progress, + duration: _contentVideoController.value.duration, + ); + } } - } - }, - ); - return _contentVideoController.play(); + }, + ); + } + + if (!_contentVideoController.value.isCompleted) { + await _contentVideoController.play(); + } } Future _pauseContent() { From 837e345fce35c3374df5e983f0b43b4832b9d61a Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 7 Aug 2024 14:41:59 -0400 Subject: [PATCH 08/26] fix test names --- .../{ads_manager_tests.dart => ads_manager_test.dart} | 2 +- ...ager_tests.mocks.dart => ads_manager_test.mocks.dart} | 2 +- .../test/android/content_progress_provider_test.dart | 9 +++++++++ .../{ads_manager_tests.dart => ads_manager_test.dart} | 2 +- ...ager_tests.mocks.dart => ads_manager_test.mocks.dart} | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) rename packages/interactive_media_ads/test/android/{ads_manager_tests.dart => ads_manager_test.dart} (99%) rename packages/interactive_media_ads/test/android/{ads_manager_tests.mocks.dart => ads_manager_test.mocks.dart} (99%) create mode 100644 packages/interactive_media_ads/test/android/content_progress_provider_test.dart rename packages/interactive_media_ads/test/ios/{ads_manager_tests.dart => ads_manager_test.dart} (98%) rename packages/interactive_media_ads/test/ios/{ads_manager_tests.mocks.dart => ads_manager_test.mocks.dart} (98%) diff --git a/packages/interactive_media_ads/test/android/ads_manager_tests.dart b/packages/interactive_media_ads/test/android/ads_manager_test.dart similarity index 99% rename from packages/interactive_media_ads/test/android/ads_manager_tests.dart rename to packages/interactive_media_ads/test/android/ads_manager_test.dart index b05811102cad..565166d51a37 100644 --- a/packages/interactive_media_ads/test/android/ads_manager_tests.dart +++ b/packages/interactive_media_ads/test/android/ads_manager_test.dart @@ -12,7 +12,7 @@ import 'package:interactive_media_ads/src/platform_interface/platform_interface. import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'ads_manager_tests.mocks.dart'; +import 'ads_manager_test.mocks.dart'; @GenerateNiceMocks(>[ MockSpec(), diff --git a/packages/interactive_media_ads/test/android/ads_manager_tests.mocks.dart b/packages/interactive_media_ads/test/android/ads_manager_test.mocks.dart similarity index 99% rename from packages/interactive_media_ads/test/android/ads_manager_tests.mocks.dart rename to packages/interactive_media_ads/test/android/ads_manager_test.mocks.dart index f86c6778845b..57069cf78e18 100644 --- a/packages/interactive_media_ads/test/android/ads_manager_tests.mocks.dart +++ b/packages/interactive_media_ads/test/android/ads_manager_test.mocks.dart @@ -1,5 +1,5 @@ // Mocks generated by Mockito 5.4.4 from annotations -// in interactive_media_ads/test/android/ads_manager_tests.dart. +// in interactive_media_ads/test/android/ads_manager_test.dart. // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/interactive_media_ads/test/android/content_progress_provider_test.dart b/packages/interactive_media_ads/test/android/content_progress_provider_test.dart new file mode 100644 index 000000000000..657546ca5fcc --- /dev/null +++ b/packages/interactive_media_ads/test/android/content_progress_provider_test.dart @@ -0,0 +1,9 @@ +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('AndroidContentProgressProvider', () { + test('', () { + + }); + }); +} diff --git a/packages/interactive_media_ads/test/ios/ads_manager_tests.dart b/packages/interactive_media_ads/test/ios/ads_manager_test.dart similarity index 98% rename from packages/interactive_media_ads/test/ios/ads_manager_tests.dart rename to packages/interactive_media_ads/test/ios/ads_manager_test.dart index a46fa1b91d94..8c9c6d3a35d1 100644 --- a/packages/interactive_media_ads/test/ios/ads_manager_tests.dart +++ b/packages/interactive_media_ads/test/ios/ads_manager_test.dart @@ -12,7 +12,7 @@ import 'package:interactive_media_ads/src/platform_interface/platform_interface. import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'ads_manager_tests.mocks.dart'; +import 'ads_manager_test.mocks.dart'; @GenerateNiceMocks(>[MockSpec()]) void main() { diff --git a/packages/interactive_media_ads/test/ios/ads_manager_tests.mocks.dart b/packages/interactive_media_ads/test/ios/ads_manager_test.mocks.dart similarity index 98% rename from packages/interactive_media_ads/test/ios/ads_manager_tests.mocks.dart rename to packages/interactive_media_ads/test/ios/ads_manager_test.mocks.dart index 07a1b5252426..9e891eb299f2 100644 --- a/packages/interactive_media_ads/test/ios/ads_manager_tests.mocks.dart +++ b/packages/interactive_media_ads/test/ios/ads_manager_test.mocks.dart @@ -1,5 +1,5 @@ // Mocks generated by Mockito 5.4.4 from annotations -// in interactive_media_ads/test/ios/ads_manager_tests.dart. +// in interactive_media_ads/test/ios/ads_manager_test.dart. // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes From fb2baee75df902cbb9ed7a6a3a5bfcf472e53c2c Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:18:41 -0400 Subject: [PATCH 09/26] android tests --- .../test/android/ads_loader_test.dart | 11 +++ .../content_progress_provider_test.dart | 42 +++++++- .../content_progress_provider_test.mocks.dart | 97 +++++++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 packages/interactive_media_ads/test/android/content_progress_provider_test.mocks.dart diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.dart b/packages/interactive_media_ads/test/android/ads_loader_test.dart index 80c18797c9e0..5b772c054e22 100644 --- a/packages/interactive_media_ads/test/android/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/android/ads_loader_test.dart @@ -9,6 +9,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:interactive_media_ads/src/android/android_ad_display_container.dart'; import 'package:interactive_media_ads/src/android/android_ads_loader.dart'; +import 'package:interactive_media_ads/src/android/android_content_progress_provider.dart'; import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' as ima; import 'package:interactive_media_ads/src/android/interactive_media_ads_proxy.dart'; @@ -94,6 +95,8 @@ void main() { final InteractiveMediaAdsProxy proxy = InteractiveMediaAdsProxy( instanceImaSdkFactory: () => mockSdkFactory, + newContentProgressProvider: () => + ima.ContentProgressProvider.pigeon_detached(), ); final AndroidAdsLoader adsLoader = AndroidAdsLoader( @@ -105,16 +108,24 @@ void main() { ), ); + final AndroidContentProgressProvider progressProvider = + AndroidContentProgressProvider( + AndroidContentProgressProviderCreationParams(proxy: proxy), + ); await adsLoader.requestAds( PlatformAdsRequest( adTagUrl: 'url', contentDuration: const Duration(seconds: 1), + contentProgressProvider: progressProvider, ), ); verifyInOrder(>[ mockAdsRequest.setAdTagUrl('url'), mockAdsRequest.setContentDuration(1.0), + mockAdsRequest.setContentProgressProvider( + progressProvider.progressProvider, + ), mockAdsLoader.requestAds(mockAdsRequest), ]); }); diff --git a/packages/interactive_media_ads/test/android/content_progress_provider_test.dart b/packages/interactive_media_ads/test/android/content_progress_provider_test.dart index 657546ca5fcc..bf7885bb77c6 100644 --- a/packages/interactive_media_ads/test/android/content_progress_provider_test.dart +++ b/packages/interactive_media_ads/test/android/content_progress_provider_test.dart @@ -1,9 +1,49 @@ +// 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. + import 'package:flutter_test/flutter_test.dart'; +import 'package:interactive_media_ads/src/android/android_content_progress_provider.dart'; +import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' + as ima; +import 'package:interactive_media_ads/src/android/interactive_media_ads_proxy.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; + +import 'content_progress_provider_test.mocks.dart'; +@GenerateNiceMocks(>[ + MockSpec(), +]) void main() { group('AndroidContentProgressProvider', () { - test('', () { + test('setProgress', () async { + final MockContentProgressProvider mockContentProgressProvider = + MockContentProgressProvider(); + + final AndroidContentProgressProvider provider = + AndroidContentProgressProvider( + AndroidContentProgressProviderCreationParams( + proxy: InteractiveMediaAdsProxy( + newContentProgressProvider: () => mockContentProgressProvider, + newVideoProgressUpdate: ({ + required int currentTimeMs, + required int durationMs, + }) { + expect(currentTimeMs, 1000); + expect(durationMs, 10000); + return ima.VideoProgressUpdate.pigeon_detached(); + }, + ), + ), + ); + + await provider.setProgress( + progress: const Duration(seconds: 1), + duration: const Duration(seconds: 10), + ); + verify(mockContentProgressProvider.setContentProgress(any)); }); }); } diff --git a/packages/interactive_media_ads/test/android/content_progress_provider_test.mocks.dart b/packages/interactive_media_ads/test/android/content_progress_provider_test.mocks.dart new file mode 100644 index 000000000000..6d65d6475030 --- /dev/null +++ b/packages/interactive_media_ads/test/android/content_progress_provider_test.mocks.dart @@ -0,0 +1,97 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in interactive_media_ads/test/android/content_progress_provider_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i3; + +import 'package:interactive_media_ads/src/android/interactive_media_ads.g.dart' + as _i2; +import 'package:mockito/mockito.dart' as _i1; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakePigeonInstanceManager_0 extends _i1.SmartFake + implements _i2.PigeonInstanceManager { + _FakePigeonInstanceManager_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeContentProgressProvider_1 extends _i1.SmartFake + implements _i2.ContentProgressProvider { + _FakeContentProgressProvider_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [ContentProgressProvider]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockContentProgressProvider extends _i1.Mock + implements _i2.ContentProgressProvider { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i3.Future setContentProgress(_i2.VideoProgressUpdate? update) => + (super.noSuchMethod( + Invocation.method( + #setContentProgress, + [update], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + _i2.ContentProgressProvider pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeContentProgressProvider_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeContentProgressProvider_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.ContentProgressProvider); +} From cef317cb3ed778a12a265e3169deb0ee7466439c Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:51:42 -0400 Subject: [PATCH 10/26] change to swift gen --- .../interactive_media_ads_android.dart | 1450 ++++++++--------- .../pigeons/interactive_media_ads_ios.dart | 2 - packages/interactive_media_ads/pubspec.yaml | 2 +- 3 files changed, 726 insertions(+), 728 deletions(-) diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart index 2af03f14a40d..db2941ae58d4 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -7,728 +7,728 @@ // Kotlin ProxyApi feature from pigeon. // ignore_for_file: avoid_unused_constructor_parameters // -import 'package:pigeon/pigeon.dart'; - -@ConfigurePigeon( - PigeonOptions( - copyrightHeader: 'pigeons/copyright.txt', - dartOut: 'lib/src/android/interactive_media_ads.g.dart', - kotlinOut: - 'android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt', - kotlinOptions: KotlinOptions( - package: 'dev.flutter.packages.interactive_media_ads', - ), - ), -) - -/// 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 `` 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, -} - -/// 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. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.BaseDisplayContainer', - ), -) -abstract class BaseDisplayContainer {} - -/// 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. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.AdDisplayContainer', - ), -) -abstract class AdDisplayContainer implements BaseDisplayContainer {} - -/// 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. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsLoader', - ), -) -abstract class AdsLoader { - /// Registers a listener for errors that occur during the ads request. - void addAdErrorListener(AdErrorListener listener); - - /// Registers a listener for the ads manager loaded event. - void addAdsLoadedListener(AdsLoadedListener listener); - - /// Requests ads from a server. - void requestAds(AdsRequest request); -} - -/// 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. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent', - ), -) -abstract class AdsManagerLoadedEvent { - /// The ads manager that will control playback of the loaded ads, or null when - /// using dynamic ad insertion. - late final AdsManager manager; -} - -/// An event raised when there is an error loading or playing ads. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.AdErrorEvent', - ), -) -abstract class AdErrorEvent { - /// The AdError that caused this event. - late final AdError error; -} - -/// An error that occurred in the SDK. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.AdError', - ), -) -abstract class AdError { - /// The error's code. - late final AdErrorCode errorCode; - - /// The error code's number. - late final int errorCodeNumber; - - /// The error's type. - late final AdErrorType errorType; - - /// A human-readable summary of the error. - late final String message; -} - -/// An object containing the data used to request ads from the server. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsRequest', - ), -) -abstract class AdsRequest { - /// Sets the URL from which ads will be requested. - void setAdTagUrl(String adTagUrl); - - /// Attaches a ContentProgressProvider instance to allow scheduling ad breaks - /// based on content progress (cue points). - void setContentProgressProvider(ContentProgressProvider provider); - - /// Specifies the duration of the content in seconds to be shown. - void setContentDuration(double duration); -} - -/// Defines an interface to allow SDK to track progress of the content video. -/// -/// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider', - ), -) -abstract class ContentProgressProvider { - ContentProgressProvider(); - - /// Sets an update on the progress of the video. - /// - /// This is a custom method added to the native class because the native - /// method `getContentProgress` requires a synchronous return value. - void setContentProgress(VideoProgressUpdate update); -} - -/// An object which handles playing ads after they've been received from the -/// server. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManager. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsManager', - ), -) -abstract class AdsManager extends BaseManager { - /// Discards current ad break and resumes content. - void discardAdBreak(); - - /// Pauses the current ad. - void pause(); - - /// Starts playing the ads. - void start(); -} - -/// Base interface for managing ads.. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.BaseManager', - ), -) -abstract class BaseManager { - /// Registers a listener for errors that occur during the ad or stream - /// initialization and playback. - void addAdErrorListener(AdErrorListener errorListener); - - /// Registers a listener for ad events that occur during ad or stream - /// initialization and playback. - void addAdEventListener(AdEventListener adEventListener); - - /// Stops the ad and all tracking, then releases all assets that were loaded - /// to play the ad. - void destroy(); - - /// Initializes the ad experience using default rendering settings - void init(); -} - -/// Event to notify publisher that an event occurred with an Ad. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.AdEvent', - ), -) -abstract class AdEvent { - /// The type of event that occurred. - late final AdEventType type; -} - -/// Factory class for creating SDK objects. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkFactory', - ), -) -abstract class ImaSdkFactory { - @static - @attached - late final ImaSdkFactory instance; - - @static - AdDisplayContainer createAdDisplayContainer( - ViewGroup container, - VideoAdPlayer player, - ); - - /// Creates an `ImaSdkSettings` object for configuring the IMA SDK. - ImaSdkSettings createImaSdkSettings(); - - /// Creates an `AdsLoader` for requesting ads using the specified settings - /// object. - AdsLoader createAdsLoader( - ImaSdkSettings settings, - AdDisplayContainer container, - ); - - /// Creates an AdsRequest object to contain the data used to request ads. - AdsRequest createAdsRequest(); -} - -/// Defines general SDK settings that are used when creating an `AdsLoader`. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkSettings', - ), -) -abstract class ImaSdkSettings {} - -/// Defines an update to the video's progress. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate', - ), -) -abstract class VideoProgressUpdate { - VideoProgressUpdate(int currentTimeMs, int durationMs); - - /// Value to use for cases when progress is not yet defined, such as video - /// initialization. - @static - @attached - late final VideoProgressUpdate videoTimeNotReady; -} - -/// The minimal information required to play an ad. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.player.AdMediaInfo', - ), -) -abstract class AdMediaInfo { - late final String url; -} - -/// An ad may be part of a pod of ads. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'com.google.ads.interactivemedia.v3.api.AdPodInfo', - ), -) -abstract class AdPodInfo { - /// The position of the ad within the pod. - /// - /// The value returned is one-based, for example, 1 of 2, 2 of 2, etc. If the - /// ad is not part of a pod, this will return 1. - late final int adPosition; - - /// The maximum duration of the pod in seconds. - /// - /// For unknown duration, -1 is returned. - late final double maxDuration; - - /// Client side and DAI VOD: Returns the index of the ad pod. - late final int podIndex; - - /// The content time offset at which the current ad pod was scheduled. - /// - /// For preroll pod, 0 is returned. For midrolls, the scheduled time is - /// returned in seconds. For postroll, -1 is returned. Defaults to 0 if this - /// ad is not part of a pod, or the pod is not part of an ad playlist. - late final double timeOffset; - - /// The total number of ads contained within this pod, including bumpers. - late final int totalAds; - - /// Returns true if the ad is a bumper ad. - late final bool isBumper; -} - -/// FrameLayout is designed to block out an area on the screen to display a -/// single item. -/// -/// See https://developer.android.com/reference/android/widget/FrameLayout. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'android.widget.FrameLayout', - ), -) -abstract class FrameLayout extends ViewGroup { - FrameLayout(); -} - -/// A special view that can contain other views (called children.) -/// -/// See https://developer.android.com/reference/android/view/ViewGroup. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'android.view.ViewGroup', - ), -) -abstract class ViewGroup extends View { - void addView(View view); -} - -/// Displays a video file. -/// -/// See https://developer.android.com/reference/android/widget/VideoView. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'android.widget.VideoView', - ), -) -abstract class VideoView extends View { - VideoView(); - - /// Callback to be invoked when the media source is ready for playback. - late final void Function(MediaPlayer player)? onPrepared; - - /// Callback to be invoked when playback of a media source has completed. - late final void Function(MediaPlayer player)? onCompletion; - - /// Callback to be invoked when there has been an error during an asynchronous - /// operation. - late final void Function(MediaPlayer player, int what, int extra) onError; - - /// Sets the URI of the video. - void setVideoUri(String uri); - - /// The current position of the playing video. - /// - /// In milliseconds. - int getCurrentPosition(); -} - -/// This class represents the basic building block for user interface components. -/// -/// See https://developer.android.com/reference/android/view/View. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions(fullClassName: 'android.view.View'), -) -abstract class View {} - -/// MediaPlayer class can be used to control playback of audio/video files and -/// streams. -/// -/// See https://developer.android.com/reference/android/media/MediaPlayer. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: 'android.media.MediaPlayer', - ), -) -abstract class MediaPlayer { - /// Gets the duration of the file. - int getDuration(); - - /// Seeks to specified time position. - void seekTo(int mSec); - - /// Starts or resumes playback. - void start(); - - /// Pauses playback. - void pause(); - - /// Stops playback after playback has been started or paused. - void stop(); -} - -/// Callbacks that the player must fire. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback', - ), -) -abstract class VideoAdPlayerCallback { - /// Fire this callback periodically as ad playback occurs. - void onAdProgress( - AdMediaInfo adMediaInfo, - VideoProgressUpdate videoProgressUpdate, - ); - - /// Fire this callback when video playback stalls waiting for data. - void onBuffering(AdMediaInfo adMediaInfo); - - /// Fire this callback when all content has finished playing. - void onContentComplete(); - - /// Fire this callback when the video finishes playing. - void onEnded(AdMediaInfo adMediaInfo); - - /// Fire this callback when the video has encountered an error. - void onError(AdMediaInfo adMediaInfo); - - /// Fire this callback when the video is ready to begin playback. - void onLoaded(AdMediaInfo adMediaInfo); - - /// Fire this callback when the video is paused. - void onPause(AdMediaInfo adMediaInfo); - - /// Fire this callback when the player begins playing a video. - void onPlay(AdMediaInfo adMediaInfo); - - /// Fire this callback when the video is unpaused. - void onResume(AdMediaInfo adMediaInfo); - - /// Fire this callback when the playback volume changes. - void onVolumeChanged(AdMediaInfo adMediaInfo, int percentage); -} - -/// Defines the set of methods that a video player must implement to be used by -/// the IMA SDK, as well as a set of callbacks that it must fire. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer', - ), -) -abstract class VideoAdPlayer { - VideoAdPlayer(); - - /// Adds a callback. - late final void Function(VideoAdPlayerCallback callback) addCallback; - - /// Loads a video ad hosted at AdMediaInfo. - late final void Function(AdMediaInfo adMediaInfo, AdPodInfo adPodInfo) loadAd; - - /// Pauses playing the current ad. - late final void Function(AdMediaInfo adMediaInfo) pauseAd; - - /// Starts or resumes playing the video ad referenced by the AdMediaInfo, - /// provided loadAd has already been called for it. - late final void Function(AdMediaInfo adMediaInfo) playAd; - - /// Cleans up and releases all resources used by the `VideoAdPlayer`. - late final void Function() release; - - /// Removes a callback. - late final void Function(VideoAdPlayerCallback callback) removeCallback; - - /// Stops playing the current ad. - late final void Function(AdMediaInfo adMediaInfo) stopAd; - - /// The volume of the player as a percentage from 0 to 100. - void setVolume(int value); - - /// The `VideoProgressUpdate` describing playback progress of the current - /// video. - void setAdProgress(VideoProgressUpdate progress); -} - -/// Listener interface for notification of ad load or stream load completion. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener', - ), -) -abstract class AdsLoadedListener { - AdsLoadedListener(); - - /// Called once the AdsManager or StreamManager has been loaded. - late final void Function(AdsManagerLoadedEvent event) onAdsManagerLoaded; -} - -/// Interface for classes that will listen to AdErrorEvents. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener', - ), -) -abstract class AdErrorListener { - AdErrorListener(); - - /// Called when an error occurs. - late final void Function(AdErrorEvent event) onAdError; -} - -/// Listener interface for ad events. -/// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. -@ProxyApi( - kotlinOptions: KotlinProxyApiOptions( - fullClassName: - 'com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener', - ), -) -abstract class AdEventListener { - AdEventListener(); - - /// Respond to an occurrence of an AdEvent. - late final void Function(AdEvent event) onAdEvent; -} +// import 'package:pigeon/pigeon.dart'; +// +// @ConfigurePigeon( +// PigeonOptions( +// copyrightHeader: 'pigeons/copyright.txt', +// dartOut: 'lib/src/android/interactive_media_ads.g.dart', +// kotlinOut: +// 'android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt', +// kotlinOptions: KotlinOptions( +// package: 'dev.flutter.packages.interactive_media_ads', +// ), +// ), +// ) +// +// /// 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 `` 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, +// } +// +// /// 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. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.BaseDisplayContainer', +// ), +// ) +// abstract class BaseDisplayContainer {} +// +// /// 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. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdDisplayContainer', +// ), +// ) +// abstract class AdDisplayContainer implements BaseDisplayContainer {} +// +// /// 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. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsLoader', +// ), +// ) +// abstract class AdsLoader { +// /// Registers a listener for errors that occur during the ads request. +// void addAdErrorListener(AdErrorListener listener); +// +// /// Registers a listener for the ads manager loaded event. +// void addAdsLoadedListener(AdsLoadedListener listener); +// +// /// Requests ads from a server. +// void requestAds(AdsRequest request); +// } +// +// /// 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. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent', +// ), +// ) +// abstract class AdsManagerLoadedEvent { +// /// The ads manager that will control playback of the loaded ads, or null when +// /// using dynamic ad insertion. +// late final AdsManager manager; +// } +// +// /// An event raised when there is an error loading or playing ads. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdErrorEvent', +// ), +// ) +// abstract class AdErrorEvent { +// /// The AdError that caused this event. +// late final AdError error; +// } +// +// /// An error that occurred in the SDK. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdError', +// ), +// ) +// abstract class AdError { +// /// The error's code. +// late final AdErrorCode errorCode; +// +// /// The error code's number. +// late final int errorCodeNumber; +// +// /// The error's type. +// late final AdErrorType errorType; +// +// /// A human-readable summary of the error. +// late final String message; +// } +// +// /// An object containing the data used to request ads from the server. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsRequest', +// ), +// ) +// abstract class AdsRequest { +// /// Sets the URL from which ads will be requested. +// void setAdTagUrl(String adTagUrl); +// +// /// Attaches a ContentProgressProvider instance to allow scheduling ad breaks +// /// based on content progress (cue points). +// void setContentProgressProvider(ContentProgressProvider provider); +// +// /// Specifies the duration of the content in seconds to be shown. +// void setContentDuration(double duration); +// } +// +// /// Defines an interface to allow SDK to track progress of the content video. +// /// +// /// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider', +// ), +// ) +// abstract class ContentProgressProvider { +// ContentProgressProvider(); +// +// /// Sets an update on the progress of the video. +// /// +// /// This is a custom method added to the native class because the native +// /// method `getContentProgress` requires a synchronous return value. +// void setContentProgress(VideoProgressUpdate update); +// } +// +// /// An object which handles playing ads after they've been received from the +// /// server. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsManager. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdsManager', +// ), +// ) +// abstract class AdsManager extends BaseManager { +// /// Discards current ad break and resumes content. +// void discardAdBreak(); +// +// /// Pauses the current ad. +// void pause(); +// +// /// Starts playing the ads. +// void start(); +// } +// +// /// Base interface for managing ads.. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.BaseManager', +// ), +// ) +// abstract class BaseManager { +// /// Registers a listener for errors that occur during the ad or stream +// /// initialization and playback. +// void addAdErrorListener(AdErrorListener errorListener); +// +// /// Registers a listener for ad events that occur during ad or stream +// /// initialization and playback. +// void addAdEventListener(AdEventListener adEventListener); +// +// /// Stops the ad and all tracking, then releases all assets that were loaded +// /// to play the ad. +// void destroy(); +// +// /// Initializes the ad experience using default rendering settings +// void init(); +// } +// +// /// Event to notify publisher that an event occurred with an Ad. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdEvent', +// ), +// ) +// abstract class AdEvent { +// /// The type of event that occurred. +// late final AdEventType type; +// } +// +// /// Factory class for creating SDK objects. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkFactory', +// ), +// ) +// abstract class ImaSdkFactory { +// @static +// @attached +// late final ImaSdkFactory instance; +// +// @static +// AdDisplayContainer createAdDisplayContainer( +// ViewGroup container, +// VideoAdPlayer player, +// ); +// +// /// Creates an `ImaSdkSettings` object for configuring the IMA SDK. +// ImaSdkSettings createImaSdkSettings(); +// +// /// Creates an `AdsLoader` for requesting ads using the specified settings +// /// object. +// AdsLoader createAdsLoader( +// ImaSdkSettings settings, +// AdDisplayContainer container, +// ); +// +// /// Creates an AdsRequest object to contain the data used to request ads. +// AdsRequest createAdsRequest(); +// } +// +// /// Defines general SDK settings that are used when creating an `AdsLoader`. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.ImaSdkSettings', +// ), +// ) +// abstract class ImaSdkSettings {} +// +// /// Defines an update to the video's progress. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate', +// ), +// ) +// abstract class VideoProgressUpdate { +// VideoProgressUpdate(int currentTimeMs, int durationMs); +// +// /// Value to use for cases when progress is not yet defined, such as video +// /// initialization. +// @static +// @attached +// late final VideoProgressUpdate videoTimeNotReady; +// } +// +// /// The minimal information required to play an ad. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.player.AdMediaInfo', +// ), +// ) +// abstract class AdMediaInfo { +// late final String url; +// } +// +// /// An ad may be part of a pod of ads. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'com.google.ads.interactivemedia.v3.api.AdPodInfo', +// ), +// ) +// abstract class AdPodInfo { +// /// The position of the ad within the pod. +// /// +// /// The value returned is one-based, for example, 1 of 2, 2 of 2, etc. If the +// /// ad is not part of a pod, this will return 1. +// late final int adPosition; +// +// /// The maximum duration of the pod in seconds. +// /// +// /// For unknown duration, -1 is returned. +// late final double maxDuration; +// +// /// Client side and DAI VOD: Returns the index of the ad pod. +// late final int podIndex; +// +// /// The content time offset at which the current ad pod was scheduled. +// /// +// /// For preroll pod, 0 is returned. For midrolls, the scheduled time is +// /// returned in seconds. For postroll, -1 is returned. Defaults to 0 if this +// /// ad is not part of a pod, or the pod is not part of an ad playlist. +// late final double timeOffset; +// +// /// The total number of ads contained within this pod, including bumpers. +// late final int totalAds; +// +// /// Returns true if the ad is a bumper ad. +// late final bool isBumper; +// } +// +// /// FrameLayout is designed to block out an area on the screen to display a +// /// single item. +// /// +// /// See https://developer.android.com/reference/android/widget/FrameLayout. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'android.widget.FrameLayout', +// ), +// ) +// abstract class FrameLayout extends ViewGroup { +// FrameLayout(); +// } +// +// /// A special view that can contain other views (called children.) +// /// +// /// See https://developer.android.com/reference/android/view/ViewGroup. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'android.view.ViewGroup', +// ), +// ) +// abstract class ViewGroup extends View { +// void addView(View view); +// } +// +// /// Displays a video file. +// /// +// /// See https://developer.android.com/reference/android/widget/VideoView. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'android.widget.VideoView', +// ), +// ) +// abstract class VideoView extends View { +// VideoView(); +// +// /// Callback to be invoked when the media source is ready for playback. +// late final void Function(MediaPlayer player)? onPrepared; +// +// /// Callback to be invoked when playback of a media source has completed. +// late final void Function(MediaPlayer player)? onCompletion; +// +// /// Callback to be invoked when there has been an error during an asynchronous +// /// operation. +// late final void Function(MediaPlayer player, int what, int extra) onError; +// +// /// Sets the URI of the video. +// void setVideoUri(String uri); +// +// /// The current position of the playing video. +// /// +// /// In milliseconds. +// int getCurrentPosition(); +// } +// +// /// This class represents the basic building block for user interface components. +// /// +// /// See https://developer.android.com/reference/android/view/View. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions(fullClassName: 'android.view.View'), +// ) +// abstract class View {} +// +// /// MediaPlayer class can be used to control playback of audio/video files and +// /// streams. +// /// +// /// See https://developer.android.com/reference/android/media/MediaPlayer. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: 'android.media.MediaPlayer', +// ), +// ) +// abstract class MediaPlayer { +// /// Gets the duration of the file. +// int getDuration(); +// +// /// Seeks to specified time position. +// void seekTo(int mSec); +// +// /// Starts or resumes playback. +// void start(); +// +// /// Pauses playback. +// void pause(); +// +// /// Stops playback after playback has been started or paused. +// void stop(); +// } +// +// /// Callbacks that the player must fire. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback', +// ), +// ) +// abstract class VideoAdPlayerCallback { +// /// Fire this callback periodically as ad playback occurs. +// void onAdProgress( +// AdMediaInfo adMediaInfo, +// VideoProgressUpdate videoProgressUpdate, +// ); +// +// /// Fire this callback when video playback stalls waiting for data. +// void onBuffering(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when all content has finished playing. +// void onContentComplete(); +// +// /// Fire this callback when the video finishes playing. +// void onEnded(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the video has encountered an error. +// void onError(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the video is ready to begin playback. +// void onLoaded(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the video is paused. +// void onPause(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the player begins playing a video. +// void onPlay(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the video is unpaused. +// void onResume(AdMediaInfo adMediaInfo); +// +// /// Fire this callback when the playback volume changes. +// void onVolumeChanged(AdMediaInfo adMediaInfo, int percentage); +// } +// +// /// Defines the set of methods that a video player must implement to be used by +// /// the IMA SDK, as well as a set of callbacks that it must fire. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer', +// ), +// ) +// abstract class VideoAdPlayer { +// VideoAdPlayer(); +// +// /// Adds a callback. +// late final void Function(VideoAdPlayerCallback callback) addCallback; +// +// /// Loads a video ad hosted at AdMediaInfo. +// late final void Function(AdMediaInfo adMediaInfo, AdPodInfo adPodInfo) loadAd; +// +// /// Pauses playing the current ad. +// late final void Function(AdMediaInfo adMediaInfo) pauseAd; +// +// /// Starts or resumes playing the video ad referenced by the AdMediaInfo, +// /// provided loadAd has already been called for it. +// late final void Function(AdMediaInfo adMediaInfo) playAd; +// +// /// Cleans up and releases all resources used by the `VideoAdPlayer`. +// late final void Function() release; +// +// /// Removes a callback. +// late final void Function(VideoAdPlayerCallback callback) removeCallback; +// +// /// Stops playing the current ad. +// late final void Function(AdMediaInfo adMediaInfo) stopAd; +// +// /// The volume of the player as a percentage from 0 to 100. +// void setVolume(int value); +// +// /// The `VideoProgressUpdate` describing playback progress of the current +// /// video. +// void setAdProgress(VideoProgressUpdate progress); +// } +// +// /// Listener interface for notification of ad load or stream load completion. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.AdsLoader.AdsLoadedListener', +// ), +// ) +// abstract class AdsLoadedListener { +// AdsLoadedListener(); +// +// /// Called once the AdsManager or StreamManager has been loaded. +// late final void Function(AdsManagerLoadedEvent event) onAdsManagerLoaded; +// } +// +// /// Interface for classes that will listen to AdErrorEvents. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener', +// ), +// ) +// abstract class AdErrorListener { +// AdErrorListener(); +// +// /// Called when an error occurs. +// late final void Function(AdErrorEvent event) onAdError; +// } +// +// /// Listener interface for ad events. +// /// +// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. +// @ProxyApi( +// kotlinOptions: KotlinProxyApiOptions( +// fullClassName: +// 'com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener', +// ), +// ) +// abstract class AdEventListener { +// AdEventListener(); +// +// /// Respond to an occurrence of an AdEvent. +// late final void Function(AdEvent event) onAdEvent; +// } diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart index 934518843645..ac11c94637dc 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart @@ -7,7 +7,6 @@ // Swift ProxyApi feature from pigeon. // ignore_for_file: avoid_unused_constructor_parameters -/* import 'package:pigeon/pigeon.dart'; @ConfigurePigeon( @@ -505,4 +504,3 @@ abstract class IMAAdsRenderingSettings extends NSObject { /// See https://developer.apple.com/documentation/objectivec/nsobject. @ProxyApi() abstract class NSObject {} -*/ diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml index 940b3ea193eb..3d1a725303c2 100644 --- a/packages/interactive_media_ads/pubspec.yaml +++ b/packages/interactive_media_ads/pubspec.yaml @@ -34,7 +34,7 @@ dev_dependencies: pigeon: git: url: git@github.com:bparrishMines/packages.git - ref: pigeon_kotlin_split + ref: pigeon_wrapper_swift path: packages/pigeon topics: From 213f2da7123fdc950346ade6278fe2867195fff0 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:10:20 -0400 Subject: [PATCH 11/26] ios impl --- .../example/lib/main.dart | 1 + .../src/ios/interactive_media_ads_proxy.dart | 4 + .../lib/src/ios/ios_ads_loader.dart | 5 + .../ios/ios_content_progress_provider.dart | 64 +++++++++++++ .../src/ios/ios_interactive_media_ads.dart | 6 +- .../test/ios/ads_loader_test.dart | 15 ++- .../ios/content_progress_provider_test.dart | 39 ++++++++ .../content_progress_provider_test.mocks.dart | 96 +++++++++++++++++++ 8 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 packages/interactive_media_ads/lib/src/ios/ios_content_progress_provider.dart create mode 100644 packages/interactive_media_ads/test/ios/content_progress_provider_test.dart create mode 100644 packages/interactive_media_ads/test/ios/content_progress_provider_test.mocks.dart diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index 469421479a16..14be5407c84d 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -129,6 +129,7 @@ class _AdExampleWidgetState extends State { return _adsLoader.requestAds(AdsRequest( adTagUrl: _adTagUrl, contentProgressProvider: _contentProgressProvider, + contentDuration: _contentVideoController.value.duration, )); } diff --git a/packages/interactive_media_ads/lib/src/ios/interactive_media_ads_proxy.dart b/packages/interactive_media_ads/lib/src/ios/interactive_media_ads_proxy.dart index 29600d0b617c..97d1c5166d78 100644 --- a/packages/interactive_media_ads/lib/src/ios/interactive_media_ads_proxy.dart +++ b/packages/interactive_media_ads/lib/src/ios/interactive_media_ads_proxy.dart @@ -15,6 +15,7 @@ class InteractiveMediaAdsProxy { const InteractiveMediaAdsProxy({ this.newIMAAdDisplayContainer = IMAAdDisplayContainer.new, this.newUIViewController = UIViewController.new, + this.newIMAContentPlayhead = IMAContentPlayhead.new, this.newIMAAdsLoader = IMAAdsLoader.new, this.newIMAAdsRequest = IMAAdsRequest.new, this.newIMAAdsLoaderDelegate = IMAAdsLoaderDelegate.new, @@ -33,6 +34,9 @@ class InteractiveMediaAdsProxy { void Function(UIViewController, bool)? viewDidAppear, }) newUIViewController; + /// Constructs [IMAContentPlayhead]. + final IMAContentPlayhead Function() newIMAContentPlayhead; + /// Constructs [IMAAdsLoader]. final IMAAdsLoader Function({IMASettings? settings}) newIMAAdsLoader; diff --git a/packages/interactive_media_ads/lib/src/ios/ios_ads_loader.dart b/packages/interactive_media_ads/lib/src/ios/ios_ads_loader.dart index b25ef27dae48..606cfb6c835e 100644 --- a/packages/interactive_media_ads/lib/src/ios/ios_ads_loader.dart +++ b/packages/interactive_media_ads/lib/src/ios/ios_ads_loader.dart @@ -12,6 +12,7 @@ import 'interactive_media_ads.g.dart'; import 'interactive_media_ads_proxy.dart'; import 'ios_ad_display_container.dart'; import 'ios_ads_manager.dart'; +import 'ios_content_progress_provider.dart'; /// Implementation of [PlatformAdsLoaderCreationParams] for iOS. final class IOSAdsLoaderCreationParams extends PlatformAdsLoaderCreationParams { @@ -77,6 +78,10 @@ base class IOSAdsLoader extends PlatformAdsLoader { adTagUrl: request.adTagUrl, adDisplayContainer: (_iosParams.container as IOSAdDisplayContainer).adDisplayContainer!, + contentPlayhead: request.contentProgressProvider != null + ? (request.contentProgressProvider! as IOSContentProgressProvider) + .contentPlayhead + : null, )); } diff --git a/packages/interactive_media_ads/lib/src/ios/ios_content_progress_provider.dart b/packages/interactive_media_ads/lib/src/ios/ios_content_progress_provider.dart new file mode 100644 index 000000000000..9b75466ae548 --- /dev/null +++ b/packages/interactive_media_ads/lib/src/ios/ios_content_progress_provider.dart @@ -0,0 +1,64 @@ +// 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. + +import 'dart:async'; + +import 'package:meta/meta.dart'; + +import '../platform_interface/platform_content_progress_provider.dart'; +import 'interactive_media_ads.g.dart' as ima; +import 'interactive_media_ads_proxy.dart'; + +/// Implementation of [PlatformContentProgressProviderCreationParams] for iOS. +final class IOSContentProgressProviderCreationParams + extends PlatformContentProgressProviderCreationParams { + /// Constructs an [IOSContentProgressProviderCreationParams]. + const IOSContentProgressProviderCreationParams({ + @visibleForTesting InteractiveMediaAdsProxy? proxy, + }) : _proxy = proxy ?? const InteractiveMediaAdsProxy(), + super(); + + /// Creates a [IOSContentProgressProviderCreationParams] from an instance of + /// [PlatformContentProgressProviderCreationParams]. + factory IOSContentProgressProviderCreationParams.fromPlatformContentProgressProviderCreationParams( + // Placeholder to prevent requiring a breaking change if params are added to + // PlatformContentProgressProviderCreationParams. + // ignore: avoid_unused_constructor_parameters + PlatformContentProgressProviderCreationParams params, { + @visibleForTesting InteractiveMediaAdsProxy? proxy, + }) { + return IOSContentProgressProviderCreationParams(proxy: proxy); + } + + final InteractiveMediaAdsProxy _proxy; +} + +/// Implementation of [PlatformContentProgressProvider] for iOS. +base class IOSContentProgressProvider extends PlatformContentProgressProvider { + /// Constructs an [IOSContentProgressProvider]. + IOSContentProgressProvider(super.params) : super.implementation(); + + /// The native iOS IMAContentPlayhead. + /// + /// This allows the SDK to track progress of the content video. + @internal + late final ima.IMAContentPlayhead contentPlayhead = + _iosParams._proxy.newIMAContentPlayhead(); + + late final IOSContentProgressProviderCreationParams _iosParams = + params is IOSContentProgressProviderCreationParams + ? params as IOSContentProgressProviderCreationParams + : IOSContentProgressProviderCreationParams + .fromPlatformContentProgressProviderCreationParams( + params, + ); + + @override + Future setProgress({ + required Duration progress, + required Duration duration, + }) async { + return contentPlayhead.setCurrentTime(progress.inSeconds.toDouble()); + } +} diff --git a/packages/interactive_media_ads/lib/src/ios/ios_interactive_media_ads.dart b/packages/interactive_media_ads/lib/src/ios/ios_interactive_media_ads.dart index 574df54b3e7f..ee55ecce0c98 100644 --- a/packages/interactive_media_ads/lib/src/ios/ios_interactive_media_ads.dart +++ b/packages/interactive_media_ads/lib/src/ios/ios_interactive_media_ads.dart @@ -10,6 +10,7 @@ import '../platform_interface/platform_content_progress_provider.dart'; import 'ios_ad_display_container.dart'; import 'ios_ads_loader.dart'; import 'ios_ads_manager_delegate.dart'; +import 'ios_content_progress_provider.dart'; /// Implementation of [InteractiveMediaAdsPlatform] for iOS. final class IOSInteractiveMediaAds extends InteractiveMediaAdsPlatform { @@ -38,10 +39,9 @@ final class IOSInteractiveMediaAds extends InteractiveMediaAdsPlatform { } @override - PlatformContentProgressProvider createPlatformContentProgressProvider( + IOSContentProgressProvider createPlatformContentProgressProvider( PlatformContentProgressProviderCreationParams params, ) { - // TODO: implement createPlatformContentProgressProvider - throw UnimplementedError(); + return IOSContentProgressProvider(params); } } diff --git a/packages/interactive_media_ads/test/ios/ads_loader_test.dart b/packages/interactive_media_ads/test/ios/ads_loader_test.dart index 7354e214eba6..eb4e32687958 100644 --- a/packages/interactive_media_ads/test/ios/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/ios/ads_loader_test.dart @@ -9,6 +9,7 @@ import 'package:interactive_media_ads/src/ios/interactive_media_ads.g.dart' import 'package:interactive_media_ads/src/ios/interactive_media_ads_proxy.dart'; import 'package:interactive_media_ads/src/ios/ios_ad_display_container.dart'; import 'package:interactive_media_ads/src/ios/ios_ads_loader.dart'; +import 'package:interactive_media_ads/src/ios/ios_content_progress_provider.dart'; import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; @@ -70,6 +71,8 @@ void main() { const String adTag = 'myAdTag'; final MockIMAAdsLoader mockLoader = MockIMAAdsLoader(); + final ima.IMAContentPlayhead contentPlayheadInstance = + ima.IMAContentPlayhead(); final InteractiveMediaAdsProxy imaProxy = InteractiveMediaAdsProxy( newIMAAdsLoader: ({ima.IMASettings? settings}) => mockLoader, newIMAAdsRequest: ({ @@ -79,8 +82,10 @@ void main() { }) { expect(adTagUrl, adTag); expect(adDisplayContainer, container.adDisplayContainer); + expect(contentPlayhead, contentPlayheadInstance); return MockIMAAdsRequest(); }, + newIMAContentPlayhead: () => contentPlayheadInstance, ); final IOSAdsLoader loader = IOSAdsLoader( @@ -92,7 +97,15 @@ void main() { ), ); - await loader.requestAds(PlatformAdsRequest(adTagUrl: adTag)); + final IOSContentProgressProvider provider = IOSContentProgressProvider( + IOSContentProgressProviderCreationParams(proxy: imaProxy), + ); + + await loader.requestAds(PlatformAdsRequest( + adTagUrl: adTag, + contentDuration: const Duration(seconds: 10), + contentProgressProvider: provider, + )); verify(mockLoader.requestAds(any)); }); diff --git a/packages/interactive_media_ads/test/ios/content_progress_provider_test.dart b/packages/interactive_media_ads/test/ios/content_progress_provider_test.dart new file mode 100644 index 000000000000..80975174d3aa --- /dev/null +++ b/packages/interactive_media_ads/test/ios/content_progress_provider_test.dart @@ -0,0 +1,39 @@ +// 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. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:interactive_media_ads/src/ios/interactive_media_ads.g.dart'; +import 'package:interactive_media_ads/src/ios/interactive_media_ads_proxy.dart'; +import 'package:interactive_media_ads/src/ios/ios_content_progress_provider.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; + +import 'content_progress_provider_test.mocks.dart'; + +@GenerateNiceMocks(>[ + MockSpec(), +]) +void main() { + group('IOSContentProgressProvider', () { + test('setProgress', () async { + final MockIMAContentPlayhead mockContentPlayhead = + MockIMAContentPlayhead(); + + final IOSContentProgressProvider provider = IOSContentProgressProvider( + IOSContentProgressProviderCreationParams( + proxy: InteractiveMediaAdsProxy( + newIMAContentPlayhead: () => mockContentPlayhead, + ), + ), + ); + + await provider.setProgress( + progress: const Duration(seconds: 1), + duration: const Duration(seconds: 10), + ); + + verify(mockContentPlayhead.setCurrentTime(1.0)); + }); + }); +} diff --git a/packages/interactive_media_ads/test/ios/content_progress_provider_test.mocks.dart b/packages/interactive_media_ads/test/ios/content_progress_provider_test.mocks.dart new file mode 100644 index 000000000000..a82fb3fbade8 --- /dev/null +++ b/packages/interactive_media_ads/test/ios/content_progress_provider_test.mocks.dart @@ -0,0 +1,96 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in interactive_media_ads/test/ios/content_progress_provider_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i3; + +import 'package:interactive_media_ads/src/ios/interactive_media_ads.g.dart' + as _i2; +import 'package:mockito/mockito.dart' as _i1; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakePigeonInstanceManager_0 extends _i1.SmartFake + implements _i2.PigeonInstanceManager { + _FakePigeonInstanceManager_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeIMAContentPlayhead_1 extends _i1.SmartFake + implements _i2.IMAContentPlayhead { + _FakeIMAContentPlayhead_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [IMAContentPlayhead]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockIMAContentPlayhead extends _i1.Mock + implements _i2.IMAContentPlayhead { + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) as _i2.PigeonInstanceManager); + + @override + _i3.Future setCurrentTime(double? timeInterval) => (super.noSuchMethod( + Invocation.method( + #setCurrentTime, + [timeInterval], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + _i2.IMAContentPlayhead pigeon_copy() => (super.noSuchMethod( + Invocation.method( + #pigeon_copy, + [], + ), + returnValue: _FakeIMAContentPlayhead_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + returnValueForMissingStub: _FakeIMAContentPlayhead_1( + this, + Invocation.method( + #pigeon_copy, + [], + ), + ), + ) as _i2.IMAContentPlayhead); +} From 209c544ea4ed255263ef8f04cc34c6d508ec4acf Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 20 Aug 2024 22:56:08 -0400 Subject: [PATCH 12/26] android class --- .../InteractiveMediaAdsLibrary.g.kt | 94 +- .../ContentProgressProviderProxyApiTest.kt | 37 + .../src/android/interactive_media_ads.g.dart | 2015 +++++++++-------- .../interactive_media_ads_android.dart | 13 +- 4 files changed, 1195 insertions(+), 964 deletions(-) create mode 100644 packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index b88f1ba596cf..dc1c0d1f8187 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -1,7 +1,7 @@ // 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 (v21.2.0), do not edit directly. +// Autogenerated from Pigeon (v21.3.0), do not edit directly. // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass", "SyntheticAccessor") @@ -258,7 +258,7 @@ class InteractiveMediaAdsLibraryPigeonInstanceManager( } } -/** Generated API for managing the Dart and native `PigeonInstanceManager`s. */ +/** Generated API for managing the Dart and native `InstanceManager`s. */ private class InteractiveMediaAdsLibraryPigeonInstanceManagerApi( val binaryMessenger: BinaryMessenger ) { @@ -278,7 +278,7 @@ private class InteractiveMediaAdsLibraryPigeonInstanceManagerApi( val channel = BasicMessageChannel( binaryMessenger, - "dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference", + "dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference", codec) if (instanceManager != null) { channel.setMessageHandler { message, reply -> @@ -301,7 +301,7 @@ private class InteractiveMediaAdsLibraryPigeonInstanceManagerApi( val channel = BasicMessageChannel( binaryMessenger, - "dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.clear", + "dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.clear", codec) if (instanceManager != null) { channel.setMessageHandler { _, reply -> @@ -323,7 +323,7 @@ private class InteractiveMediaAdsLibraryPigeonInstanceManagerApi( fun removeStrongReference(identifierArg: Long, callback: (Result) -> Unit) { val channelName = - "dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference" + "dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) channel.send(listOf(identifierArg)) { if (it is List<*>) { @@ -423,9 +423,7 @@ abstract class InteractiveMediaAdsLibraryPigeonProxyApiRegistrar( * An implementation of [PigeonApiContentProgressProvider] used to add a new Dart instance of * `ContentProgressProvider` to the Dart `InstanceManager`. */ - open fun getPigeonApiContentProgressProvider(): PigeonApiContentProgressProvider { - return PigeonApiContentProgressProvider(this) - } + abstract fun getPigeonApiContentProgressProvider(): PigeonApiContentProgressProvider /** * An implementation of [PigeonApiAdsManager] used to add a new Dart instance of `AdsManager` to @@ -544,6 +542,8 @@ abstract class InteractiveMediaAdsLibraryPigeonProxyApiRegistrar( binaryMessenger, instanceManager) PigeonApiAdsLoader.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsLoader()) PigeonApiAdsRequest.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsRequest()) + PigeonApiContentProgressProvider.setUpMessageHandlers( + binaryMessenger, getPigeonApiContentProgressProvider()) PigeonApiAdsManager.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsManager()) PigeonApiBaseManager.setUpMessageHandlers(binaryMessenger, getPigeonApiBaseManager()) PigeonApiImaSdkFactory.setUpMessageHandlers(binaryMessenger, getPigeonApiImaSdkFactory()) @@ -566,6 +566,7 @@ abstract class InteractiveMediaAdsLibraryPigeonProxyApiRegistrar( InteractiveMediaAdsLibraryPigeonInstanceManagerApi.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsLoader.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsRequest.setUpMessageHandlers(binaryMessenger, null) + PigeonApiContentProgressProvider.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsManager.setUpMessageHandlers(binaryMessenger, null) PigeonApiBaseManager.setUpMessageHandlers(binaryMessenger, null) PigeonApiImaSdkFactory.setUpMessageHandlers(binaryMessenger, null) @@ -1430,9 +1431,84 @@ abstract class PigeonApiAdsRequest( * https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. */ @Suppress("UNCHECKED_CAST") -open class PigeonApiContentProgressProvider( +abstract class PigeonApiContentProgressProvider( open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar ) { + abstract fun pigeon_defaultConstructor(): + com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider + + /** + * Sets an update on the progress of the video. + * + * This is a custom method added to the native class because the native method + * `getContentProgress` requires a synchronous return value. + */ + abstract fun setContentProgress( + pigeon_instance: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider, + update: com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + ) + + companion object { + @Suppress("LocalVariableName") + fun setUpMessageHandlers( + binaryMessenger: BinaryMessenger, + api: PigeonApiContentProgressProvider? + ) { + val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_defaultConstructor", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_identifierArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val wrapped: List = + try { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + api.pigeon_defaultConstructor(), pigeon_identifierArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.setContentProgress", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = + args[0] as com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider + val updateArg = + args[1] as com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + val wrapped: List = + try { + api.setContentProgress(pigeon_instanceArg, updateArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + } + } + @Suppress("LocalVariableName", "FunctionName") /** Creates a Dart instance of ContentProgressProvider and attaches it to [pigeon_instanceArg]. */ fun pigeon_newInstance( diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt new file mode 100644 index 000000000000..c1011d9ffa84 --- /dev/null +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt @@ -0,0 +1,37 @@ +// 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. + +package dev.flutter.packages.interactive_media_ads + +import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + +/** + * ProxyApi implementation for [ContentProgressProvider]. + * + *

This class may handle instantiating native object instances that are attached to a Dart + * instance or handle method calls on the associated native class or an instance of that class. + */ +class ContentProgressProviderProxyApiTest(override val pigeonRegistrar: ProxyApiRegistrar) : + PigeonApiContentProgressProvider(pigeonRegistrar) { + internal class ContentProgressProviderImpl(val api: ContentProgressProviderProxyApi) : + ContentProgressProvider { + var currentProgress = VideoProgressUpdate.VIDEO_TIME_NOT_READY + + override fun getContentProgress(): VideoProgressUpdate { + return currentProgress + } + } + + override fun pigeon_defaultConstructor(): ContentProgressProvider { + return ContentProgressProviderImpl(this) + } + + override fun setContentProgress( + pigeon_instance: ContentProgressProvider, + update: VideoProgressUpdate + ) { + (pigeon_instance as ContentProgressProviderImpl).currentProgress = update + } +} diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart index 1fca04f82608..1179882455a8 100644 --- a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart @@ -1,7 +1,7 @@ // 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 (v21.2.0), do not edit directly. +// Autogenerated from Pigeon (v21.3.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 @@ -37,9 +37,9 @@ List wrapResponse( /// All implementers are expected to be [immutable] as defined by the annotation /// and override [pigeon_copy] returning an instance of itself. @immutable -abstract class PigeonProxyApiBaseClass { - /// Construct a [PigeonProxyApiBaseClass]. - PigeonProxyApiBaseClass({ +abstract class PigeonInternalProxyApiBaseClass { + /// Construct a [PigeonInternalProxyApiBaseClass]. + PigeonInternalProxyApiBaseClass({ this.pigeon_binaryMessenger, PigeonInstanceManager? pigeon_instanceManager, }) : pigeon_instanceManager = @@ -64,7 +64,7 @@ abstract class PigeonProxyApiBaseClass { /// Subclasses should always override their parent's implementation of this /// method. @protected - PigeonProxyApiBaseClass pigeon_copy(); + PigeonInternalProxyApiBaseClass pigeon_copy(); } /// Maintains instances used to communicate with the native objects they @@ -114,10 +114,10 @@ class PigeonInstanceManager { // by calling instanceManager.getIdentifier() inside of `==` while this was a // HashMap). final Expando _identifiers = Expando(); - final Map> _weakInstances = - >{}; - final Map _strongInstances = - {}; + final Map> + _weakInstances = >{}; + final Map _strongInstances = + {}; late final Finalizer _finalizer; int _nextIdentifier = 0; @@ -127,7 +127,8 @@ class PigeonInstanceManager { static PigeonInstanceManager _initInstance() { WidgetsFlutterBinding.ensureInitialized(); - final _PigeonInstanceManagerApi api = _PigeonInstanceManagerApi(); + final _PigeonInternalInstanceManagerApi api = + _PigeonInternalInstanceManagerApi(); // Clears the native `PigeonInstanceManager` on the initial use of the Dart one. api.clear(); final PigeonInstanceManager instanceManager = PigeonInstanceManager( @@ -135,7 +136,7 @@ class PigeonInstanceManager { api.removeStrongReference(identifier); }, ); - _PigeonInstanceManagerApi.setUpMessageHandlers( + _PigeonInternalInstanceManagerApi.setUpMessageHandlers( instanceManager: instanceManager); BaseDisplayContainer.pigeon_setUpMessageHandlers( pigeon_instanceManager: instanceManager); @@ -199,7 +200,7 @@ class PigeonInstanceManager { /// Throws assertion error if the instance has already been added. /// /// Returns the randomly generated id of the [instance] added. - int addDartCreatedInstance(PigeonProxyApiBaseClass instance) { + int addDartCreatedInstance(PigeonInternalProxyApiBaseClass instance) { final int identifier = _nextUniqueIdentifier(); _addInstanceWithIdentifier(instance, identifier); return identifier; @@ -213,7 +214,7 @@ class PigeonInstanceManager { /// /// This does not remove the strong referenced instance associated with /// [instance]. This can be done with [remove]. - int? removeWeakReference(PigeonProxyApiBaseClass instance) { + int? removeWeakReference(PigeonInternalProxyApiBaseClass instance) { final int? identifier = getIdentifier(instance); if (identifier == null) { return null; @@ -235,7 +236,7 @@ class PigeonInstanceManager { /// /// This does not remove the weak referenced instance associated with /// [identifier]. This can be done with [removeWeakReference]. - T? remove(int identifier) { + T? remove(int identifier) { return _strongInstances.remove(identifier) as T?; } @@ -251,19 +252,20 @@ class PigeonInstanceManager { /// /// This method also expects the host `InstanceManager` to have a strong /// reference to the instance the identifier is associated with. - T? getInstanceWithWeakReference( + T? getInstanceWithWeakReference( int identifier) { - final PigeonProxyApiBaseClass? weakInstance = + final PigeonInternalProxyApiBaseClass? weakInstance = _weakInstances[identifier]?.target; if (weakInstance == null) { - final PigeonProxyApiBaseClass? strongInstance = + final PigeonInternalProxyApiBaseClass? strongInstance = _strongInstances[identifier]; if (strongInstance != null) { - final PigeonProxyApiBaseClass copy = strongInstance.pigeon_copy(); + final PigeonInternalProxyApiBaseClass copy = + strongInstance.pigeon_copy(); _identifiers[copy] = identifier; _weakInstances[identifier] = - WeakReference(copy); + WeakReference(copy); _finalizer.attach(copy, identifier, detach: copy); return copy as T; } @@ -274,7 +276,7 @@ class PigeonInstanceManager { } /// Retrieves the identifier associated with instance. - int? getIdentifier(PigeonProxyApiBaseClass instance) { + int? getIdentifier(PigeonInternalProxyApiBaseClass instance) { return _identifiers[instance]; } @@ -288,22 +290,22 @@ class PigeonInstanceManager { /// /// Returns unique identifier of the [instance] added. void addHostCreatedInstance( - PigeonProxyApiBaseClass instance, int identifier) { + PigeonInternalProxyApiBaseClass instance, int identifier) { _addInstanceWithIdentifier(instance, identifier); } void _addInstanceWithIdentifier( - PigeonProxyApiBaseClass instance, int identifier) { + PigeonInternalProxyApiBaseClass instance, int identifier) { assert(!containsIdentifier(identifier)); assert(getIdentifier(instance) == null); assert(identifier >= 0); _identifiers[instance] = identifier; _weakInstances[identifier] = - WeakReference(instance); + WeakReference(instance); _finalizer.attach(instance, identifier, detach: instance); - final PigeonProxyApiBaseClass copy = instance.pigeon_copy(); + final PigeonInternalProxyApiBaseClass copy = instance.pigeon_copy(); _identifiers[copy] = identifier; _strongInstances[identifier] = copy; } @@ -325,12 +327,12 @@ class PigeonInstanceManager { } /// Generated API for managing the Dart and native `PigeonInstanceManager`s. -class _PigeonInstanceManagerApi { - /// Constructor for [_PigeonInstanceManagerApi]. - _PigeonInstanceManagerApi({BinaryMessenger? binaryMessenger}) - : __pigeon_binaryMessenger = binaryMessenger; +class _PigeonInternalInstanceManagerApi { + /// Constructor for [_PigeonInternalInstanceManagerApi]. + _PigeonInternalInstanceManagerApi({BinaryMessenger? binaryMessenger}) + : pigeonVar_binaryMessenger = binaryMessenger; - final BinaryMessenger? __pigeon_binaryMessenger; + final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = StandardMessageCodec(); @@ -341,21 +343,22 @@ class _PigeonInstanceManagerApi { PigeonInstanceManager? instanceManager, }) { { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference', + 'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference was null.'); + 'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, - 'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference was null, expected non-null int.'); + 'Argument for dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference was null, expected non-null int.'); try { (instanceManager ?? PigeonInstanceManager.instance) .remove(arg_identifier!); @@ -372,23 +375,23 @@ class _PigeonInstanceManagerApi { } Future removeStrongReference(int identifier) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.removeStrongReference'; - final BasicMessageChannel __pigeon_channel = + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.removeStrongReference'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([identifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([identifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -399,23 +402,23 @@ class _PigeonInstanceManagerApi { /// /// This is typically called after a hot restart. Future clear() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.interactive_media_ads.PigeonInstanceManagerApi.clear'; - final BasicMessageChannel __pigeon_channel = + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.PigeonInternalInstanceManager.clear'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -423,12 +426,12 @@ class _PigeonInstanceManagerApi { } } -class _PigeonProxyApiBaseCodec extends _PigeonCodec { - const _PigeonProxyApiBaseCodec(this.instanceManager); +class _PigeonInternalProxyApiBaseCodec extends _PigeonCodec { + const _PigeonInternalProxyApiBaseCodec(this.instanceManager); final PigeonInstanceManager instanceManager; @override void writeValue(WriteBuffer buffer, Object? value) { - if (value is PigeonProxyApiBaseClass) { + if (value is PigeonInternalProxyApiBaseClass) { buffer.putUint8(128); writeValue(buffer, instanceManager.getIdentifier(value)); } else { @@ -676,7 +679,7 @@ class _PigeonCodec extends StandardMessageCodec { /// 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 PigeonProxyApiBaseClass { +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 @@ -693,20 +696,21 @@ class BaseDisplayContainer extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, BaseDisplayContainer Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.BaseDisplayContainer.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -747,7 +751,7 @@ class BaseDisplayContainer extends PigeonProxyApiBaseClass { /// 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 PigeonProxyApiBaseClass +class AdDisplayContainer extends PigeonInternalProxyApiBaseClass implements BaseDisplayContainer { /// Constructs [AdDisplayContainer] without creating the associated native object. /// @@ -765,20 +769,21 @@ class AdDisplayContainer extends PigeonProxyApiBaseClass PigeonInstanceManager? pigeon_instanceManager, AdDisplayContainer Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdDisplayContainer.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -820,7 +825,7 @@ class AdDisplayContainer extends PigeonProxyApiBaseClass /// 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 PigeonProxyApiBaseClass { +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 @@ -831,8 +836,8 @@ class AdsLoader extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecAdsLoader = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecAdsLoader = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -840,20 +845,21 @@ class AdsLoader extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, AdsLoader Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoader.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -884,25 +890,26 @@ class AdsLoader extends PigeonProxyApiBaseClass { /// Registers a listener for errors that occur during the ads request. Future addAdErrorListener(AdErrorListener listener) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecAdsLoader; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + 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 __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, listener]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -911,25 +918,26 @@ class AdsLoader extends PigeonProxyApiBaseClass { /// Registers a listener for the ads manager loaded event. Future addAdsLoadedListener(AdsLoadedListener listener) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecAdsLoader; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + 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 __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, listener]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -938,25 +946,26 @@ class AdsLoader extends PigeonProxyApiBaseClass { /// Requests ads from a server. Future requestAds(AdsRequest request) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecAdsLoader; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + 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 __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this, request]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([this, request]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -975,7 +984,7 @@ class AdsLoader extends PigeonProxyApiBaseClass { /// 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 PigeonProxyApiBaseClass { +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 @@ -997,20 +1006,21 @@ class AdsManagerLoadedEvent extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, AdsManagerLoadedEvent Function(AdsManager manager)? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdsManagerLoadedEvent.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsManagerLoadedEvent.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1056,7 +1066,7 @@ class AdsManagerLoadedEvent extends PigeonProxyApiBaseClass { /// An event raised when there is an error loading or playing ads. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.html. -class AdErrorEvent extends PigeonProxyApiBaseClass { +class AdErrorEvent extends PigeonInternalProxyApiBaseClass { /// Constructs [AdErrorEvent] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1077,20 +1087,21 @@ class AdErrorEvent extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, AdErrorEvent Function(AdError error)? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdErrorEvent.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdErrorEvent.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1136,7 +1147,7 @@ class AdErrorEvent extends PigeonProxyApiBaseClass { /// An error that occurred in the SDK. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdError.html. -class AdError extends PigeonProxyApiBaseClass { +class AdError extends PigeonInternalProxyApiBaseClass { /// Constructs [AdError] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1174,20 +1185,21 @@ class AdError extends PigeonProxyApiBaseClass { String message, )? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdError.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1249,7 +1261,7 @@ class AdError extends PigeonProxyApiBaseClass { /// An object containing the data used to request ads from the server. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest. -class AdsRequest extends PigeonProxyApiBaseClass { +class AdsRequest extends PigeonInternalProxyApiBaseClass { /// Constructs [AdsRequest] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1260,8 +1272,8 @@ class AdsRequest extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecAdsRequest = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecAdsRequest = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -1269,20 +1281,21 @@ class AdsRequest extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, AdsRequest Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdsRequest.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsRequest.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1313,26 +1326,26 @@ class AdsRequest extends PigeonProxyApiBaseClass { /// Sets the URL from which ads will be requested. Future setAdTagUrl(String adTagUrl) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdsRequest; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecAdsRequest; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdTagUrl'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adTagUrl]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1343,26 +1356,26 @@ class AdsRequest extends PigeonProxyApiBaseClass { /// based on content progress (cue points). Future setContentProgressProvider( ContentProgressProvider provider) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdsRequest; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecAdsRequest; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentProgressProvider'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, provider]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1381,7 +1394,41 @@ class AdsRequest extends PigeonProxyApiBaseClass { /// Defines an interface to allow SDK to track progress of the content video. /// /// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. -class ContentProgressProvider extends PigeonProxyApiBaseClass { +class ContentProgressProvider extends PigeonInternalProxyApiBaseClass { + ContentProgressProvider({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }) { + final int pigeonVar_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecContentProgressProvider; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + () async { + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_defaultConstructor'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + 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; + } + }(); + } + /// Constructs [ContentProgressProvider] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1392,26 +1439,31 @@ class ContentProgressProvider extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); + late final _PigeonInternalProxyApiBaseCodec + _pigeonVar_codecContentProgressProvider = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); + static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, BinaryMessenger? pigeon_binaryMessenger, PigeonInstanceManager? pigeon_instanceManager, ContentProgressProvider Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1440,6 +1492,37 @@ class ContentProgressProvider extends PigeonProxyApiBaseClass { } } + /// Sets an update on the progress of the video. + /// + /// This is a custom method added to the native class because the native + /// method `getContentProgress` requires a synchronous return value. + Future setContentProgress(VideoProgressUpdate update) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecContentProgressProvider; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.setContentProgress'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this, update]) as List?; + 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 ContentProgressProvider pigeon_copy() { return ContentProgressProvider.pigeon_detached( @@ -1464,8 +1547,8 @@ class AdsManager extends BaseManager { super.pigeon_instanceManager, }) : super.pigeon_detached(); - late final _PigeonProxyApiBaseCodec __pigeon_codecAdsManager = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecAdsManager = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -1473,20 +1556,21 @@ class AdsManager extends BaseManager { PigeonInstanceManager? pigeon_instanceManager, AdsManager Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdsManager.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsManager.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1517,26 +1601,26 @@ class AdsManager extends BaseManager { /// Discards current ad break and resumes content. Future discardAdBreak() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdsManager; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecAdsManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.AdsManager.discardAdBreak'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1545,26 +1629,26 @@ class AdsManager extends BaseManager { /// Pauses the current ad. Future pause() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdsManager; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecAdsManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.AdsManager.pause'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1573,26 +1657,26 @@ class AdsManager extends BaseManager { /// Starts playing the ads. Future start() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdsManager; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecAdsManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.AdsManager.start'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1611,7 +1695,7 @@ class AdsManager extends BaseManager { /// Base interface for managing ads.. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html. -class BaseManager extends PigeonProxyApiBaseClass { +class BaseManager extends PigeonInternalProxyApiBaseClass { /// Constructs [BaseManager] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1622,8 +1706,8 @@ class BaseManager extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecBaseManager = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecBaseManager = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -1631,20 +1715,21 @@ class BaseManager extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, BaseManager Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.BaseManager.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.BaseManager.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1676,26 +1761,26 @@ class BaseManager extends PigeonProxyApiBaseClass { /// Registers a listener for errors that occur during the ad or stream /// initialization and playback. Future addAdErrorListener(AdErrorListener errorListener) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecBaseManager; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.BaseManager.addAdErrorListener'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, errorListener]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1705,26 +1790,26 @@ class BaseManager extends PigeonProxyApiBaseClass { /// Registers a listener for ad events that occur during ad or stream /// initialization and playback. Future addAdEventListener(AdEventListener adEventListener) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecBaseManager; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.BaseManager.addAdEventListener'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adEventListener]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1734,26 +1819,26 @@ class BaseManager extends PigeonProxyApiBaseClass { /// Stops the ad and all tracking, then releases all assets that were loaded /// to play the ad. Future destroy() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecBaseManager; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.BaseManager.destroy'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1762,26 +1847,26 @@ class BaseManager extends PigeonProxyApiBaseClass { /// Initializes the ad experience using default rendering settings Future init() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecBaseManager; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecBaseManager; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.BaseManager.init'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -1800,7 +1885,7 @@ class BaseManager extends PigeonProxyApiBaseClass { /// Event to notify publisher that an event occurred with an Ad. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. -class AdEvent extends PigeonProxyApiBaseClass { +class AdEvent extends PigeonInternalProxyApiBaseClass { /// Constructs [AdEvent] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1828,20 +1913,21 @@ class AdEvent extends PigeonProxyApiBaseClass { Map? adData, )? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1891,7 +1977,7 @@ class AdEvent extends PigeonProxyApiBaseClass { /// Factory class for creating SDK objects. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory. -class ImaSdkFactory extends PigeonProxyApiBaseClass { +class ImaSdkFactory extends PigeonInternalProxyApiBaseClass { /// Constructs [ImaSdkFactory] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1902,10 +1988,10 @@ class ImaSdkFactory extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecImaSdkFactory = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecImaSdkFactory = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); - static final ImaSdkFactory instance = __pigeon_instance(); + static final ImaSdkFactory instance = pigeonVar_instance(); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -1913,20 +1999,21 @@ class ImaSdkFactory extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, ImaSdkFactory Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -1955,38 +2042,38 @@ class ImaSdkFactory extends PigeonProxyApiBaseClass { } } - static ImaSdkFactory __pigeon_instance() { - final ImaSdkFactory __pigeon_instance = ImaSdkFactory.pigeon_detached(); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec(PigeonInstanceManager.instance); - final BinaryMessenger __pigeon_binaryMessenger = + static ImaSdkFactory pigeonVar_instance() { + final ImaSdkFactory pigeonVar_instance = ImaSdkFactory.pigeon_detached(); + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec(PigeonInstanceManager.instance); + final BinaryMessenger pigeonVar_binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger; - final int __pigeon_instanceIdentifier = PigeonInstanceManager.instance - .addDartCreatedInstance(__pigeon_instance); + final int pigeonVar_instanceIdentifier = PigeonInstanceManager.instance + .addDartCreatedInstance(pigeonVar_instance); () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.instance'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; } }(); - return __pigeon_instance; + return pigeonVar_instance; } static Future createAdDisplayContainer( @@ -1995,68 +2082,68 @@ class ImaSdkFactory extends PigeonProxyApiBaseClass { BinaryMessenger? pigeon_binaryMessenger, PigeonInstanceManager? pigeon_instanceManager, }) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdDisplayContainer'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([container, player]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as AdDisplayContainer?)!; + return (pigeonVar_replyList[0] as AdDisplayContainer?)!; } } /// Creates an `ImaSdkSettings` object for configuring the IMA SDK. Future createImaSdkSettings() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecImaSdkFactory; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecImaSdkFactory; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createImaSdkSettings'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as ImaSdkSettings?)!; + return (pigeonVar_replyList[0] as ImaSdkSettings?)!; } } @@ -2066,67 +2153,67 @@ class ImaSdkFactory extends PigeonProxyApiBaseClass { ImaSdkSettings settings, AdDisplayContainer container, ) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecImaSdkFactory; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecImaSdkFactory; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdsLoader'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, settings, container]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as AdsLoader?)!; + return (pigeonVar_replyList[0] as AdsLoader?)!; } } /// Creates an AdsRequest object to contain the data used to request ads. Future createAdsRequest() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecImaSdkFactory; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecImaSdkFactory; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.ImaSdkFactory.createAdsRequest'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as AdsRequest?)!; + return (pigeonVar_replyList[0] as AdsRequest?)!; } } @@ -2142,7 +2229,7 @@ class ImaSdkFactory extends PigeonProxyApiBaseClass { /// Defines general SDK settings that are used when creating an `AdsLoader`. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings.html. -class ImaSdkSettings extends PigeonProxyApiBaseClass { +class ImaSdkSettings extends PigeonInternalProxyApiBaseClass { /// Constructs [ImaSdkSettings] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -2159,20 +2246,21 @@ class ImaSdkSettings extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, ImaSdkSettings Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.ImaSdkSettings.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.ImaSdkSettings.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -2213,37 +2301,40 @@ class ImaSdkSettings extends PigeonProxyApiBaseClass { /// Defines an update to the video's progress. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoProgressUpdate.html. -class VideoProgressUpdate extends PigeonProxyApiBaseClass { +class VideoProgressUpdate extends PigeonInternalProxyApiBaseClass { VideoProgressUpdate({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, required int currentTimeMs, required int durationMs, }) { - final int __pigeon_instanceIdentifier = + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoProgressUpdate; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoProgressUpdate; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_defaultConstructor'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel.send( - [__pigeon_instanceIdentifier, currentTimeMs, durationMs]) - as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([ + pigeonVar_instanceIdentifier, + currentTimeMs, + durationMs + ]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -2261,13 +2352,14 @@ class VideoProgressUpdate extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecVideoProgressUpdate = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec + _pigeonVar_codecVideoProgressUpdate = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); /// Value to use for cases when progress is not yet defined, such as video /// initialization. static final VideoProgressUpdate videoTimeNotReady = - __pigeon_videoTimeNotReady(); + pigeonVar_videoTimeNotReady(); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -2275,20 +2367,21 @@ class VideoProgressUpdate extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, VideoProgressUpdate Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -2317,39 +2410,39 @@ class VideoProgressUpdate extends PigeonProxyApiBaseClass { } } - static VideoProgressUpdate __pigeon_videoTimeNotReady() { - final VideoProgressUpdate __pigeon_instance = + static VideoProgressUpdate pigeonVar_videoTimeNotReady() { + final VideoProgressUpdate pigeonVar_instance = VideoProgressUpdate.pigeon_detached(); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec(PigeonInstanceManager.instance); - final BinaryMessenger __pigeon_binaryMessenger = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec(PigeonInstanceManager.instance); + final BinaryMessenger pigeonVar_binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger; - final int __pigeon_instanceIdentifier = PigeonInstanceManager.instance - .addDartCreatedInstance(__pigeon_instance); + final int pigeonVar_instanceIdentifier = PigeonInstanceManager.instance + .addDartCreatedInstance(pigeonVar_instance); () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoProgressUpdate.videoTimeNotReady'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; } }(); - return __pigeon_instance; + return pigeonVar_instance; } @override @@ -2364,7 +2457,7 @@ class VideoProgressUpdate extends PigeonProxyApiBaseClass { /// The minimal information required to play an ad. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/AdMediaInfo.html. -class AdMediaInfo extends PigeonProxyApiBaseClass { +class AdMediaInfo extends PigeonInternalProxyApiBaseClass { /// Constructs [AdMediaInfo] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -2384,20 +2477,21 @@ class AdMediaInfo extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, AdMediaInfo Function(String url)? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdMediaInfo.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdMediaInfo.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -2443,7 +2537,7 @@ class AdMediaInfo extends PigeonProxyApiBaseClass { /// An ad may be part of a pod of ads. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdPodInfo.html. -class AdPodInfo extends PigeonProxyApiBaseClass { +class AdPodInfo extends PigeonInternalProxyApiBaseClass { /// Constructs [AdPodInfo] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -2500,20 +2594,21 @@ class AdPodInfo extends PigeonProxyApiBaseClass { bool isBumper, )? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdPodInfo.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -2596,29 +2691,29 @@ class FrameLayout extends ViewGroup { super.pigeon_binaryMessenger, super.pigeon_instanceManager, }) : super.pigeon_detached() { - final int __pigeon_instanceIdentifier = + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecFrameLayout; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecFrameLayout; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_defaultConstructor'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -2636,8 +2731,8 @@ class FrameLayout extends ViewGroup { super.pigeon_instanceManager, }) : super.pigeon_detached(); - late final _PigeonProxyApiBaseCodec __pigeon_codecFrameLayout = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecFrameLayout = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -2645,20 +2740,21 @@ class FrameLayout extends ViewGroup { PigeonInstanceManager? pigeon_instanceManager, FrameLayout Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.FrameLayout.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -2710,8 +2806,8 @@ class ViewGroup extends View { super.pigeon_instanceManager, }) : super.pigeon_detached(); - late final _PigeonProxyApiBaseCodec __pigeon_codecViewGroup = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecViewGroup = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -2719,20 +2815,21 @@ class ViewGroup extends View { PigeonInstanceManager? pigeon_instanceManager, ViewGroup Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.ViewGroup.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.ViewGroup.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -2762,25 +2859,26 @@ class ViewGroup extends View { } Future addView(View view) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecViewGroup; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecViewGroup; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.ViewGroup.addView'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this, view]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this, view]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -2807,28 +2905,29 @@ class VideoView extends View { this.onCompletion, required this.onError, }) : super.pigeon_detached() { - final int __pigeon_instanceIdentifier = + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecVideoView; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoView; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoView.pigeon_defaultConstructor'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -2849,8 +2948,8 @@ class VideoView extends View { required this.onError, }) : super.pigeon_detached(); - late final _PigeonProxyApiBaseCodec __pigeon_codecVideoView = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecVideoView = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); /// Callback to be invoked when the media source is ready for playback. /// @@ -2946,20 +3045,20 @@ class VideoView extends View { int extra, )? onError, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( 'dev.flutter.pigeon.interactive_media_ads.VideoView.onPrepared', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onPrepared was null.'); final List args = (message as List?)!; @@ -2984,15 +3083,15 @@ class VideoView extends View { } { - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( 'dev.flutter.pigeon.interactive_media_ads.VideoView.onCompletion', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onCompletion was null.'); final List args = (message as List?)!; @@ -3017,15 +3116,15 @@ class VideoView extends View { } { - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( 'dev.flutter.pigeon.interactive_media_ads.VideoView.onError', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoView.onError was null.'); final List args = (message as List?)!; @@ -3058,25 +3157,26 @@ class VideoView extends View { /// Sets the URI of the video. Future setVideoUri(String uri) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecVideoView; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoView; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoView.setVideoUri'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this, uri]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this, uri]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3087,33 +3187,34 @@ class VideoView extends View { /// /// In milliseconds. Future getCurrentPosition() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = __pigeon_codecVideoView; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoView; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoView.getCurrentPosition'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as int?)!; + return (pigeonVar_replyList[0] as int?)!; } } @@ -3132,7 +3233,7 @@ class VideoView extends View { /// This class represents the basic building block for user interface components. /// /// See https://developer.android.com/reference/android/view/View. -class View extends PigeonProxyApiBaseClass { +class View extends PigeonInternalProxyApiBaseClass { /// Constructs [View] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -3149,20 +3250,21 @@ class View extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, View Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.View.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.View.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -3204,7 +3306,7 @@ class View extends PigeonProxyApiBaseClass { /// streams. /// /// See https://developer.android.com/reference/android/media/MediaPlayer. -class MediaPlayer extends PigeonProxyApiBaseClass { +class MediaPlayer extends PigeonInternalProxyApiBaseClass { /// Constructs [MediaPlayer] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -3215,8 +3317,8 @@ class MediaPlayer extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecMediaPlayer = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecMediaPlayer = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -3224,20 +3326,21 @@ class MediaPlayer extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, MediaPlayer Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -3268,59 +3371,59 @@ class MediaPlayer extends PigeonProxyApiBaseClass { /// Gets the duration of the file. Future getDuration() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecMediaPlayer; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecMediaPlayer; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.getDuration'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as int?)!; + return (pigeonVar_replyList[0] as int?)!; } } /// Seeks to specified time position. Future seekTo(int mSec) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecMediaPlayer; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecMediaPlayer; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.seekTo'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this, mSec]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this, mSec]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3329,26 +3432,26 @@ class MediaPlayer extends PigeonProxyApiBaseClass { /// Starts or resumes playback. Future start() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecMediaPlayer; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecMediaPlayer; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.start'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3357,26 +3460,26 @@ class MediaPlayer extends PigeonProxyApiBaseClass { /// Pauses playback. Future pause() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecMediaPlayer; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecMediaPlayer; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.pause'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3385,26 +3488,26 @@ class MediaPlayer extends PigeonProxyApiBaseClass { /// Stops playback after playback has been started or paused. Future stop() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecMediaPlayer; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecMediaPlayer; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.MediaPlayer.stop'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3423,7 +3526,7 @@ class MediaPlayer extends PigeonProxyApiBaseClass { /// Callbacks that the player must fire. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.VideoAdPlayerCallback.html -class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { +class VideoAdPlayerCallback extends PigeonInternalProxyApiBaseClass { /// Constructs [VideoAdPlayerCallback] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -3434,8 +3537,9 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { super.pigeon_instanceManager, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecVideoAdPlayerCallback = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec + _pigeonVar_codecVideoAdPlayerCallback = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, @@ -3443,20 +3547,21 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { PigeonInstanceManager? pigeon_instanceManager, VideoAdPlayerCallback Function()? pigeon_newInstance, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.pigeon_newInstance', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.pigeon_newInstance was null.'); final List args = (message as List?)!; @@ -3490,27 +3595,27 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { AdMediaInfo adMediaInfo, VideoProgressUpdate videoProgressUpdate, ) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onAdProgress'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo, videoProgressUpdate]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3519,26 +3624,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// Fire this callback when video playback stalls waiting for data. Future onBuffering(AdMediaInfo adMediaInfo) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onBuffering'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3547,26 +3652,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// Fire this callback when all content has finished playing. Future onContentComplete() async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onContentComplete'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3575,26 +3680,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// Fire this callback when the video finishes playing. Future onEnded(AdMediaInfo adMediaInfo) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onEnded'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3603,26 +3708,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// Fire this callback when the video has encountered an error. Future onError(AdMediaInfo adMediaInfo) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onError'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3631,26 +3736,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// Fire this callback when the video is ready to begin playback. Future onLoaded(AdMediaInfo adMediaInfo) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onLoaded'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3659,26 +3764,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// Fire this callback when the video is paused. Future onPause(AdMediaInfo adMediaInfo) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onPause'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3687,26 +3792,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// Fire this callback when the player begins playing a video. Future onPlay(AdMediaInfo adMediaInfo) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onPlay'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3715,26 +3820,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// Fire this callback when the video is unpaused. Future onResume(AdMediaInfo adMediaInfo) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onResume'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3746,26 +3851,26 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { AdMediaInfo adMediaInfo, int percentage, ) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayerCallback; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayerCallback; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayerCallback.onVolumeChanged'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, adMediaInfo, percentage]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3785,7 +3890,7 @@ class VideoAdPlayerCallback extends PigeonProxyApiBaseClass { /// the IMA SDK, as well as a set of callbacks that it must fire. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/player/VideoAdPlayer.html. -class VideoAdPlayer extends PigeonProxyApiBaseClass { +class VideoAdPlayer extends PigeonInternalProxyApiBaseClass { VideoAdPlayer({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, @@ -3797,29 +3902,29 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { required this.removeCallback, required this.stopAd, }) { - final int __pigeon_instanceIdentifier = + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayer; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayer; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pigeon_defaultConstructor'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -3844,8 +3949,8 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { required this.stopAd, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecVideoAdPlayer = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecVideoAdPlayer = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); /// Adds a callback. /// @@ -4045,20 +4150,21 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { AdMediaInfo adMediaInfo, )? stopAd, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.addCallback', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.addCallback was null.'); final List args = (message as List?)!; @@ -4085,15 +4191,15 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { } { - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.loadAd was null.'); final List args = (message as List?)!; @@ -4122,15 +4228,15 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { } { - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pauseAd', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.pauseAd was null.'); final List args = (message as List?)!; @@ -4156,15 +4262,15 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { } { - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.playAd', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.playAd was null.'); final List args = (message as List?)!; @@ -4190,15 +4296,15 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { } { - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.release', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.release was null.'); final List args = (message as List?)!; @@ -4221,15 +4327,16 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.removeCallback', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.removeCallback was null.'); final List args = (message as List?)!; @@ -4256,15 +4363,15 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { } { - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.stopAd', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.stopAd was null.'); final List args = (message as List?)!; @@ -4292,26 +4399,26 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { /// The volume of the player as a percentage from 0 to 100. Future setVolume(int value) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayer; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayer; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.setVolume'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this, value]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this, value]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -4321,26 +4428,26 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { /// The `VideoProgressUpdate` describing playback progress of the current /// video. Future setAdProgress(VideoProgressUpdate progress) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecVideoAdPlayer; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecVideoAdPlayer; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.VideoAdPlayer.setAdProgress'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([this, progress]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -4366,35 +4473,35 @@ class VideoAdPlayer extends PigeonProxyApiBaseClass { /// Listener interface for notification of ad load or stream load completion. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader.AdsLoadedListener.html. -class AdsLoadedListener extends PigeonProxyApiBaseClass { +class AdsLoadedListener extends PigeonInternalProxyApiBaseClass { AdsLoadedListener({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, required this.onAdsManagerLoaded, }) { - final int __pigeon_instanceIdentifier = + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdsLoadedListener; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecAdsLoadedListener; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.pigeon_defaultConstructor'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -4413,8 +4520,9 @@ class AdsLoadedListener extends PigeonProxyApiBaseClass { required this.onAdsManagerLoaded, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecAdsLoadedListener = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec + _pigeonVar_codecAdsLoadedListener = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); /// Called once the AdsManager or StreamManager has been loaded. /// @@ -4449,20 +4557,21 @@ class AdsLoadedListener extends PigeonProxyApiBaseClass { AdsManagerLoadedEvent event, )? onAdsManagerLoaded, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.onAdsManagerLoaded', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdsLoadedListener.onAdsManagerLoaded was null.'); final List args = (message as List?)!; @@ -4502,35 +4611,35 @@ class AdsLoadedListener extends PigeonProxyApiBaseClass { /// Interface for classes that will listen to AdErrorEvents. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdErrorEvent.AdErrorListener.html. -class AdErrorListener extends PigeonProxyApiBaseClass { +class AdErrorListener extends PigeonInternalProxyApiBaseClass { AdErrorListener({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, required this.onAdError, }) { - final int __pigeon_instanceIdentifier = + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdErrorListener; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecAdErrorListener; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.AdErrorListener.pigeon_defaultConstructor'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -4549,8 +4658,8 @@ class AdErrorListener extends PigeonProxyApiBaseClass { required this.onAdError, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecAdErrorListener = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecAdErrorListener = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); /// Called when an error occurs. /// @@ -4585,20 +4694,21 @@ class AdErrorListener extends PigeonProxyApiBaseClass { AdErrorEvent event, )? onAdError, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdErrorListener.onAdError', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdErrorListener.onAdError was null.'); final List args = (message as List?)!; @@ -4637,35 +4747,35 @@ class AdErrorListener extends PigeonProxyApiBaseClass { /// Listener interface for ad events. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventListener.html. -class AdEventListener extends PigeonProxyApiBaseClass { +class AdEventListener extends PigeonInternalProxyApiBaseClass { AdEventListener({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, required this.onAdEvent, }) { - final int __pigeon_instanceIdentifier = + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdEventListener; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecAdEventListener; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; () async { - const String __pigeon_channelName = + const String pigeonVar_channelName = 'dev.flutter.pigeon.interactive_media_ads.AdEventListener.pigeon_defaultConstructor'; - final BasicMessageChannel __pigeon_channel = + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = await pigeonVar_channel + .send([pigeonVar_instanceIdentifier]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -4684,8 +4794,8 @@ class AdEventListener extends PigeonProxyApiBaseClass { required this.onAdEvent, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecAdEventListener = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecAdEventListener = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); /// Respond to an occurrence of an AdEvent. /// @@ -4720,20 +4830,21 @@ class AdEventListener extends PigeonProxyApiBaseClass { AdEvent event, )? onAdEvent, }) { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - _PigeonProxyApiBaseCodec( + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( pigeon_instanceManager ?? PigeonInstanceManager.instance); final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( 'dev.flutter.pigeon.interactive_media_ads.AdEventListener.onAdEvent', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (pigeon_clearHandlers) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEventListener.onAdEvent was null.'); final List args = (message as List?)!; diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart index 0dc2201399f2..4fe0440b255a 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -6,7 +6,7 @@ // https://github.com/flutter/packages/pull/6371 lands. This file uses the // Kotlin ProxyApi feature from pigeon. // ignore_for_file: avoid_unused_constructor_parameters -/* + import 'package:pigeon/pigeon.dart'; @ConfigurePigeon( @@ -327,7 +327,15 @@ abstract class AdsRequest { 'com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider', ), ) -abstract class ContentProgressProvider {} +abstract class ContentProgressProvider { + ContentProgressProvider(); + + /// Sets an update on the progress of the video. + /// + /// This is a custom method added to the native class because the native + /// method `getContentProgress` requires a synchronous return value. + void setContentProgress(VideoProgressUpdate update); +} /// An object which handles playing ads after they've been received from the /// server. @@ -724,4 +732,3 @@ abstract class AdEventListener { /// Respond to an occurrence of an AdEvent. late final void Function(AdEvent event) onAdEvent; } -*/ From ce5a8becf12b2c6c6791521781936c59af5a94da Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:11:31 -0400 Subject: [PATCH 13/26] version bump --- packages/interactive_media_ads/CHANGELOG.md | 4 ++ .../AdsRequestProxyApi.kt | 2 +- .../ContentProgressProviderProxyApi.kt | 28 ++++++++++-- .../ContentProgressProviderProxyApiTest.kt | 45 +++++++++---------- .../AdsRequestProxyAPIDelegate.swift | 2 +- packages/interactive_media_ads/pubspec.yaml | 2 +- 6 files changed, 54 insertions(+), 29 deletions(-) diff --git a/packages/interactive_media_ads/CHANGELOG.md b/packages/interactive_media_ads/CHANGELOG.md index 27a8262a9200..1c27b1241e41 100644 --- a/packages/interactive_media_ads/CHANGELOG.md +++ b/packages/interactive_media_ads/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.2+2 + +* Adds internal wrapper for Android native `ContentProgressProvider`. + ## 0.1.2+1 * Updates README to clarify supported features and link to issues tracker. diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt index c4ef80ccbc3e..f9d27e3f071b 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : * * This must match the version in pubspec.yaml. */ - const val pluginVersion = "0.1.2+1" + const val pluginVersion = "0.1.2+2" } override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) { diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt index 0fa1308d1383..de942c05aa3c 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApi.kt @@ -4,12 +4,34 @@ package dev.flutter.packages.interactive_media_ads +import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider +import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate + /** - * ProxyApi implementation for - * [com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider]. + * ProxyApi implementation for [ContentProgressProvider]. * *

This class may handle instantiating native object instances that are attached to a Dart * instance or handle method calls on the associated native class or an instance of that class. */ class ContentProgressProviderProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : - PigeonApiContentProgressProvider(pigeonRegistrar) + PigeonApiContentProgressProvider(pigeonRegistrar) { + internal class ContentProgressProviderImpl(val api: ContentProgressProviderProxyApi) : + ContentProgressProvider { + var currentProgress = VideoProgressUpdate.VIDEO_TIME_NOT_READY + + override fun getContentProgress(): VideoProgressUpdate { + return currentProgress + } + } + + override fun pigeon_defaultConstructor(): ContentProgressProvider { + return ContentProgressProviderImpl(this) + } + + override fun setContentProgress( + pigeon_instance: ContentProgressProvider, + update: VideoProgressUpdate + ) { + (pigeon_instance as ContentProgressProviderImpl).currentProgress = update + } +} diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt index c1011d9ffa84..55c8accb055e 100644 --- a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/ContentProgressProviderProxyApiTest.kt @@ -4,34 +4,33 @@ package dev.flutter.packages.interactive_media_ads -import com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import org.mockito.kotlin.mock -/** - * ProxyApi implementation for [ContentProgressProvider]. - * - *

This class may handle instantiating native object instances that are attached to a Dart - * instance or handle method calls on the associated native class or an instance of that class. - */ -class ContentProgressProviderProxyApiTest(override val pigeonRegistrar: ProxyApiRegistrar) : - PigeonApiContentProgressProvider(pigeonRegistrar) { - internal class ContentProgressProviderImpl(val api: ContentProgressProviderProxyApi) : - ContentProgressProvider { - var currentProgress = VideoProgressUpdate.VIDEO_TIME_NOT_READY +class ContentProgressProviderProxyApiTest { + @Test + fun pigeon_defaultConstructor() { + val api = TestProxyApiRegistrar().getPigeonApiContentProgressProvider() - override fun getContentProgress(): VideoProgressUpdate { - return currentProgress - } + assertTrue( + api.pigeon_defaultConstructor() + is ContentProgressProviderProxyApi.ContentProgressProviderImpl) } - override fun pigeon_defaultConstructor(): ContentProgressProvider { - return ContentProgressProviderImpl(this) - } + @Test + fun setContentProgress() { + val api = TestProxyApiRegistrar().getPigeonApiContentProgressProvider() + + val instance = + ContentProgressProviderProxyApi.ContentProgressProviderImpl( + api as ContentProgressProviderProxyApi) + val mockProgressUpdate = mock() + api.setContentProgress(instance, mockProgressUpdate) - override fun setContentProgress( - pigeon_instance: ContentProgressProvider, - update: VideoProgressUpdate - ) { - (pigeon_instance as ContentProgressProviderImpl).currentProgress = update + assertEquals(mockProgressUpdate, instance.currentProgress) + assertEquals(mockProgressUpdate, instance.contentProgress) } } diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift index 5d76d718c81a..132d5055c3fe 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift @@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest { /// The current version of the `interactive_media_ads` plugin. /// /// This must match the version in pubspec.yaml. - static let pluginVersion = "0.1.2+1" + static let pluginVersion = "0.1.2+2" func pigeonDefaultConstructor( pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer, diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml index 35c2e1f8f992..2bf47bbc8b84 100644 --- a/packages/interactive_media_ads/pubspec.yaml +++ b/packages/interactive_media_ads/pubspec.yaml @@ -2,7 +2,7 @@ name: interactive_media_ads description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS. repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22 -version: 0.1.2+1 # This must match the version in +version: 0.1.2+2 # This must match the version in # `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` and # `ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift` From 8d6100864a37de55a2aa5822dde63c6fff02b77f Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:16:31 -0400 Subject: [PATCH 14/26] comment pigeon android again --- .../pigeons/interactive_media_ads_android.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart index 4fe0440b255a..d04d48381e7d 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -6,7 +6,7 @@ // https://github.com/flutter/packages/pull/6371 lands. This file uses the // Kotlin ProxyApi feature from pigeon. // ignore_for_file: avoid_unused_constructor_parameters - +/* import 'package:pigeon/pigeon.dart'; @ConfigurePigeon( @@ -732,3 +732,4 @@ abstract class AdEventListener { /// Respond to an occurrence of an AdEvent. late final void Function(AdEvent event) onAdEvent; } +*/ From bc9c04749fb54573d4561004faa5cc6ac1c31bc9 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 10 Sep 2024 12:54:43 -0400 Subject: [PATCH 15/26] add the suppress --- .../interactive_media_ads/InteractiveMediaAdsLibrary.g.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index 1bf8431d1eb0..4056a3d980b6 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -3,7 +3,7 @@ // found in the LICENSE file. // Autogenerated from Pigeon (v22.3.0), do not edit directly. // See also: https://pub.dev/packages/pigeon -@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass", "SyntheticAccessor") package dev.flutter.packages.interactive_media_ads From 3c568598902dc2e9e75e0f598e8edb6ec2d2f10d Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:08:33 -0400 Subject: [PATCH 16/26] comment out content duration --- packages/interactive_media_ads/example/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index 14be5407c84d..7d0ddfd3db08 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -129,7 +129,7 @@ class _AdExampleWidgetState extends State { return _adsLoader.requestAds(AdsRequest( adTagUrl: _adTagUrl, contentProgressProvider: _contentProgressProvider, - contentDuration: _contentVideoController.value.duration, + //contentDuration: _contentVideoController.value.duration, )); } From 90181e641099b7fc4ad360c25cda7df87cbdedde Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:14:59 -0400 Subject: [PATCH 17/26] regen and format --- .../InteractiveMediaAdsLibrary.g.kt | 157 +----------------- .../src/android/interactive_media_ads.g.dart | 115 +------------ .../pigeons/interactive_media_ads_ios.dart | 3 +- 3 files changed, 7 insertions(+), 268 deletions(-) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index 2c7573e639e0..d9fb2fe9e24a 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -1,11 +1,7 @@ // 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. -<<<<<<< HEAD -// Autogenerated from Pigeon (v21.2.0), do not edit directly. -======= -// Autogenerated from Pigeon (v22.2.0), do not edit directly. ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 +// Autogenerated from Pigeon (v22.3.0), do not edit directly. // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") @@ -262,21 +258,13 @@ class InteractiveMediaAdsLibraryPigeonInstanceManager( } } -<<<<<<< HEAD -/** Generated API for managing the Dart and native `PigeonInstanceManager`s. */ -======= /** Generated API for managing the Dart and native `InstanceManager`s. */ ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 private class InteractiveMediaAdsLibraryPigeonInstanceManagerApi( val binaryMessenger: BinaryMessenger ) { companion object { /** The codec used by InteractiveMediaAdsLibraryPigeonInstanceManagerApi. */ -<<<<<<< HEAD - val codec: MessageCodec by lazy { StandardMessageCodec() } -======= val codec: MessageCodec by lazy { InteractiveMediaAdsLibraryPigeonCodec() } ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 /** * Sets up an instance of `InteractiveMediaAdsLibraryPigeonInstanceManagerApi` to handle @@ -360,13 +348,8 @@ abstract class InteractiveMediaAdsLibraryPigeonProxyApiRegistrar( /** Whether APIs should ignore calling to Dart. */ public var ignoreCallsToDart = false val instanceManager: InteractiveMediaAdsLibraryPigeonInstanceManager -<<<<<<< HEAD - private var _codec: StandardMessageCodec? = null - val codec: StandardMessageCodec -======= private var _codec: MessageCodec? = null val codec: MessageCodec ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 get() { if (_codec == null) { _codec = InteractiveMediaAdsLibraryPigeonProxyApiBaseCodec(this) @@ -440,7 +423,9 @@ abstract class InteractiveMediaAdsLibraryPigeonProxyApiRegistrar( * An implementation of [PigeonApiContentProgressProvider] used to add a new Dart instance of * `ContentProgressProvider` to the Dart `InstanceManager`. */ - abstract fun getPigeonApiContentProgressProvider(): PigeonApiContentProgressProvider + open fun getPigeonApiContentProgressProvider(): PigeonApiContentProgressProvider { + return PigeonApiContentProgressProvider(this) + } /** * An implementation of [PigeonApiAdsManager] used to add a new Dart instance of `AdsManager` to @@ -559,8 +544,6 @@ abstract class InteractiveMediaAdsLibraryPigeonProxyApiRegistrar( binaryMessenger, instanceManager) PigeonApiAdsLoader.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsLoader()) PigeonApiAdsRequest.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsRequest()) - PigeonApiContentProgressProvider.setUpMessageHandlers( - binaryMessenger, getPigeonApiContentProgressProvider()) PigeonApiAdsManager.setUpMessageHandlers(binaryMessenger, getPigeonApiAdsManager()) PigeonApiBaseManager.setUpMessageHandlers(binaryMessenger, getPigeonApiBaseManager()) PigeonApiImaSdkFactory.setUpMessageHandlers(binaryMessenger, getPigeonApiImaSdkFactory()) @@ -583,7 +566,6 @@ abstract class InteractiveMediaAdsLibraryPigeonProxyApiRegistrar( InteractiveMediaAdsLibraryPigeonInstanceManagerApi.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsLoader.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsRequest.setUpMessageHandlers(binaryMessenger, null) - PigeonApiContentProgressProvider.setUpMessageHandlers(binaryMessenger, null) PigeonApiAdsManager.setUpMessageHandlers(binaryMessenger, null) PigeonApiBaseManager.setUpMessageHandlers(binaryMessenger, null) PigeonApiImaSdkFactory.setUpMessageHandlers(binaryMessenger, null) @@ -875,15 +857,6 @@ private open class InteractiveMediaAdsLibraryPigeonCodec : StandardMessageCodec( override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { 129.toByte() -> { -<<<<<<< HEAD - return (readValue(buffer) as Int?)?.let { AdErrorCode.ofRaw(it) } - } - 130.toByte() -> { - return (readValue(buffer) as Int?)?.let { AdErrorType.ofRaw(it) } - } - 131.toByte() -> { - return (readValue(buffer) as Int?)?.let { AdEventType.ofRaw(it) } -======= return (readValue(buffer) as Long?)?.let { AdErrorCode.ofRaw(it.toInt()) } } 130.toByte() -> { @@ -891,7 +864,6 @@ private open class InteractiveMediaAdsLibraryPigeonCodec : StandardMessageCodec( } 131.toByte() -> { return (readValue(buffer) as Long?)?.let { AdEventType.ofRaw(it.toInt()) } ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 } else -> super.readValueOfType(type, buffer) } @@ -1359,12 +1331,6 @@ abstract class PigeonApiAdsRequest( provider: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider ) - /** Specifies the duration of the content in seconds to be shown. */ - abstract fun setContentDuration( - pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest, - duration: Double - ) - companion object { @Suppress("LocalVariableName") fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdsRequest?) { @@ -1409,33 +1375,6 @@ abstract class PigeonApiAdsRequest( try { api.setContentProgressProvider(pigeon_instanceArg, providerArg) listOf(null) -<<<<<<< HEAD - } catch (exception: Throwable) { - wrapError(exception) - } - reply.reply(wrapped) - } - } else { - channel.setMessageHandler(null) - } - } - run { - val channel = - BasicMessageChannel( - binaryMessenger, - "dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentDuration", - codec) - if (api != null) { - channel.setMessageHandler { message, reply -> - val args = message as List - val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest - val durationArg = args[1] as Double - val wrapped: List = - try { - api.setContentDuration(pigeon_instanceArg, durationArg) - listOf(null) -======= ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 } catch (exception: Throwable) { wrapError(exception) } @@ -1490,90 +1429,9 @@ abstract class PigeonApiAdsRequest( * https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. */ @Suppress("UNCHECKED_CAST") -<<<<<<< HEAD -abstract class PigeonApiContentProgressProvider( - open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar -) { - abstract fun pigeon_defaultConstructor(): - com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider - - /** - * Sets an update on the progress of the video. - * - * This is a custom method added to the native class because the native method - * `getContentProgress` requires a synchronous return value. - */ - abstract fun setContentProgress( - pigeon_instance: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider, - update: com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate - ) - - companion object { - @Suppress("LocalVariableName") - fun setUpMessageHandlers( - binaryMessenger: BinaryMessenger, - api: PigeonApiContentProgressProvider? - ) { - val codec = api?.pigeonRegistrar?.codec ?: StandardMessageCodec() - run { - val channel = - BasicMessageChannel( - binaryMessenger, - "dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_defaultConstructor", - codec) - if (api != null) { - channel.setMessageHandler { message, reply -> - val args = message as List - val pigeon_identifierArg = - args[0].let { num -> if (num is Int) num.toLong() else num as Long } - val wrapped: List = - try { - api.pigeonRegistrar.instanceManager.addDartCreatedInstance( - api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) - } catch (exception: Throwable) { - wrapError(exception) - } - reply.reply(wrapped) - } - } else { - channel.setMessageHandler(null) - } - } - run { - val channel = - BasicMessageChannel( - binaryMessenger, - "dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.setContentProgress", - codec) - if (api != null) { - channel.setMessageHandler { message, reply -> - val args = message as List - val pigeon_instanceArg = - args[0] as com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider - val updateArg = - args[1] as com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate - val wrapped: List = - try { - api.setContentProgress(pigeon_instanceArg, updateArg) - listOf(null) - } catch (exception: Throwable) { - wrapError(exception) - } - reply.reply(wrapped) - } - } else { - channel.setMessageHandler(null) - } - } - } - } - -======= open class PigeonApiContentProgressProvider( open val pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar ) { ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 @Suppress("LocalVariableName", "FunctionName") /** Creates a Dart instance of ContentProgressProvider and attaches it to [pigeon_instanceArg]. */ fun pigeon_newInstance( @@ -1708,8 +1566,6 @@ abstract class PigeonApiAdsManager( try { api.start(pigeon_instanceArg) listOf(null) -<<<<<<< HEAD -======= } catch (exception: Throwable) { wrapError(exception) } @@ -1776,7 +1632,6 @@ abstract class PigeonApiAdsManager( try { api.skip(pigeon_instanceArg) listOf(null) ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 } catch (exception: Throwable) { wrapError(exception) } @@ -2040,11 +1895,7 @@ abstract class PigeonApiAdEvent( val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) -<<<<<<< HEAD - channel.send(listOf(pigeon_identifierArg, typeArg)) { -======= channel.send(listOf(pigeon_identifierArg, typeArg, adDataArg)) { ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 if (it is List<*>) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart index 4b2ac44ed00e..000b04cecf3a 100644 --- a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart @@ -1,11 +1,7 @@ // 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. -<<<<<<< HEAD -// Autogenerated from Pigeon (v21.2.0), do not edit directly. -======= -// Autogenerated from Pigeon (v22.2.0), do not edit directly. ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 +// Autogenerated from Pigeon (v22.3.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 @@ -429,13 +425,8 @@ class _PigeonInternalInstanceManagerApi { } } -<<<<<<< HEAD -class _PigeonProxyApiBaseCodec extends _PigeonCodec { - const _PigeonProxyApiBaseCodec(this.instanceManager); -======= class _PigeonInternalProxyApiBaseCodec extends _PigeonCodec { const _PigeonInternalProxyApiBaseCodec(this.instanceManager); ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 final PigeonInstanceManager instanceManager; @override void writeValue(WriteBuffer buffer, Object? value) { @@ -652,14 +643,10 @@ class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override void writeValue(WriteBuffer buffer, Object? value) { -<<<<<<< HEAD - if (value is AdErrorCode) { -======= if (value is int) { buffer.putUint8(4); buffer.putInt64(value); } else if (value is AdErrorCode) { ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 buffer.putUint8(129); writeValue(buffer, value.index); } else if (value is AdErrorType) { @@ -1397,34 +1384,6 @@ class AdsRequest extends PigeonInternalProxyApiBaseClass { } } - /// Specifies the duration of the content in seconds to be shown. - Future setContentDuration(double duration) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecAdsRequest; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = - 'dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentDuration'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = await __pigeon_channel - .send([this, duration]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - } - @override AdsRequest pigeon_copy() { return AdsRequest.pigeon_detached( @@ -1437,45 +1396,7 @@ class AdsRequest extends PigeonInternalProxyApiBaseClass { /// Defines an interface to allow SDK to track progress of the content video. /// /// See https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/player/ContentProgressProvider.html. -<<<<<<< HEAD -class ContentProgressProvider extends PigeonProxyApiBaseClass { - ContentProgressProvider({ - super.pigeon_binaryMessenger, - super.pigeon_instanceManager, - }) { - final int __pigeon_instanceIdentifier = - pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecContentProgressProvider; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - () async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.pigeon_defaultConstructor'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = await __pigeon_channel - .send([__pigeon_instanceIdentifier]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - }(); - } - -======= class ContentProgressProvider extends PigeonInternalProxyApiBaseClass { ->>>>>>> bb53e5d536aeba377b5f8877ad735973293ae200 /// Constructs [ContentProgressProvider] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1486,9 +1407,6 @@ class ContentProgressProvider extends PigeonInternalProxyApiBaseClass { super.pigeon_instanceManager, }); - late final _PigeonProxyApiBaseCodec __pigeon_codecContentProgressProvider = - _PigeonProxyApiBaseCodec(pigeon_instanceManager); - static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, BinaryMessenger? pigeon_binaryMessenger, @@ -1538,37 +1456,6 @@ class ContentProgressProvider extends PigeonInternalProxyApiBaseClass { } } - /// Sets an update on the progress of the video. - /// - /// This is a custom method added to the native class because the native - /// method `getContentProgress` requires a synchronous return value. - Future setContentProgress(VideoProgressUpdate update) async { - final _PigeonProxyApiBaseCodec pigeonChannelCodec = - __pigeon_codecContentProgressProvider; - final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; - const String __pigeon_channelName = - 'dev.flutter.pigeon.interactive_media_ads.ContentProgressProvider.setContentProgress'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = - await __pigeon_channel.send([this, update]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - } - @override ContentProgressProvider pigeon_copy() { return ContentProgressProvider.pigeon_detached( diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart index 5777bb838ace..4422830e7d72 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart @@ -6,7 +6,7 @@ // https://github.com/flutter/packages/pull/6602 lands. This file uses the // Swift ProxyApi feature from pigeon. // ignore_for_file: avoid_unused_constructor_parameters - +/* import 'package:pigeon/pigeon.dart'; @ConfigurePigeon( @@ -507,3 +507,4 @@ abstract class IMAAdsRenderingSettings extends NSObject { /// See https://developer.apple.com/documentation/objectivec/nsobject. @ProxyApi() abstract class NSObject {} +*/ From a799357b3d59c275cda38bea74296c6348de1988 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:15:51 -0400 Subject: [PATCH 18/26] fix version bump --- .../interactive_media_ads/AdsRequestProxyAPIDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift index a929dae41f5e..4ecd85c58c2f 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift @@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest { /// The current version of the `interactive_media_ads` plugin. /// /// This must match the version in pubspec.yaml. - static let pluginVersion = "0.2.0" + static let pluginVersion = "0.2.1" func pigeonDefaultConstructor( pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer, From 4f2e9fff787137dea1d8747ae5a853f468452bb4 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:51:35 -0400 Subject: [PATCH 19/26] update geng --- .../interactive_media_ads/AdsRequestProxyApi.kt | 4 ---- .../interactive_media_ads/AdsRequestProxyApiTest.kt | 10 ---------- packages/interactive_media_ads/example/lib/main.dart | 1 - .../lib/src/android/android_ads_loader.dart | 4 ---- 4 files changed, 19 deletions(-) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt index dd43279a7c26..4f07af1d8142 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt @@ -38,8 +38,4 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : ) { pigeon_instance.contentProgressProvider = provider } - - override fun setContentDuration(pigeon_instance: AdsRequest, duration: Double) { - pigeon_instance.setContentDuration(duration.toFloat()) - } } diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt index ee4061771de5..42f0cc88b84e 100644 --- a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApiTest.kt @@ -32,14 +32,4 @@ class AdsRequestProxyApiTest { verify(instance).contentProgressProvider = mockProvider } - - @Test - fun setContentDuration() { - val api = TestProxyApiRegistrar().getPigeonApiAdsRequest() - - val instance = mock() - api.setContentDuration(instance, 2.0) - - verify(instance).setContentDuration(2.0f) - } } diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index 9402af40cb4a..081b8a272d59 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -164,7 +164,6 @@ class _AdExampleWidgetState extends State return _adsLoader.requestAds(AdsRequest( adTagUrl: _adTagUrl, contentProgressProvider: _contentProgressProvider, - //contentDuration: _contentVideoController.value.duration, )); } diff --git a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart index 3da8d2fb4274..2ccbd4b62e04 100644 --- a/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart +++ b/packages/interactive_media_ads/lib/src/android/android_ads_loader.dart @@ -87,10 +87,6 @@ base class AndroidAdsLoader extends PlatformAdsLoader { await Future.wait(>[ androidRequest.setAdTagUrl(request.adTagUrl), - if (request.contentDuration != null) - androidRequest.setContentDuration( - request.contentDuration!.inSeconds.toDouble(), - ), if (request.contentProgressProvider != null) androidRequest.setContentProgressProvider( (request.contentProgressProvider! as AndroidContentProgressProvider) From 9e883fecf0d537951d12daeca67633c457387288 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:14:54 -0400 Subject: [PATCH 20/26] update pr to other pr --- .../InteractiveMediaAdsLibrary.g.kt | 2 +- packages/interactive_media_ads/example/lib/main.dart | 4 ++++ .../interactive_media_ads/lib/src/ads_request.dart | 5 ----- .../src/platform_interface/platform_ads_request.dart | 4 ---- .../pigeons/interactive_media_ads_android.dart | 3 --- .../pigeons/interactive_media_ads_ios.dart | 1 + .../interactive_media_ads/test/ads_loader_test.dart | 10 +++++++++- .../test/android/ads_loader_test.dart | 2 -- .../test/android/ads_loader_test.mocks.dart | 10 ---------- .../test/ios/ads_loader_test.dart | 1 - 10 files changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index 1bf8431d1eb0..11de60925fae 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -3,7 +3,7 @@ // found in the LICENSE file. // Autogenerated from Pigeon (v22.3.0), do not edit directly. // See also: https://pub.dev/packages/pigeon -@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass". "SyntheticAccessor") package dev.flutter.packages.interactive_media_ads diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index 081b8a272d59..a1d48d5a58c2 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -67,8 +67,12 @@ class _AdExampleWidgetState extends State }, ); + // Periodically updates the SDK of the current playback progress of the + // content video. Timer? _contentProgressTimer; + // Provides the SDK with the current playback progress of the content video. + // This is required to support mid-roll ads. final ContentProgressProvider _contentProgressProvider = ContentProgressProvider(); diff --git a/packages/interactive_media_ads/lib/src/ads_request.dart b/packages/interactive_media_ads/lib/src/ads_request.dart index 3f37699c2bf7..11043892df28 100644 --- a/packages/interactive_media_ads/lib/src/ads_request.dart +++ b/packages/interactive_media_ads/lib/src/ads_request.dart @@ -10,12 +10,10 @@ class AdsRequest { /// Creates an [AdsRequest]. AdsRequest({ required String adTagUrl, - Duration? contentDuration, ContentProgressProvider? contentProgressProvider, }) : this.fromPlatform( PlatformAdsRequest( adTagUrl: adTagUrl, - contentDuration: contentDuration, contentProgressProvider: contentProgressProvider?.platform, ), ); @@ -29,9 +27,6 @@ class AdsRequest { /// The URL from which ads will be requested. String get adTagUrl => platform.adTagUrl; - /// The duration of the content video to be shown. - Duration? get contentDuration => platform.contentDuration; - /// A [ContentProgressProvider] instance to allow scheduling of ad breaks /// based on content progress (cue points). ContentProgressProvider? get contentProgressProvider => platform diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_request.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_request.dart index 8f7035346d70..b9ef51b0ec8c 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_request.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_ads_request.dart @@ -9,16 +9,12 @@ class PlatformAdsRequest { /// Creates an [PlatformAdsRequest]. PlatformAdsRequest({ required this.adTagUrl, - this.contentDuration, this.contentProgressProvider, }); /// The URL from which ads will be requested. final String adTagUrl; - /// The duration of the content video to be shown. - final Duration? contentDuration; - /// A [PlatformContentProgressProvider] instance to allow scheduling of ad /// breaks based on content progress (cue points). final PlatformContentProgressProvider? contentProgressProvider; diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart index 1ca297d58469..4ac4afdf7e04 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(bparrishMines): Uncomment this file once -// https://github.com/flutter/packages/pull/6371 lands. This file uses the -// Kotlin ProxyApi feature from pigeon. // ignore_for_file: avoid_unused_constructor_parameters import 'package:pigeon/pigeon.dart'; diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart index 4422830e7d72..17046ad0b3a2 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart @@ -6,6 +6,7 @@ // https://github.com/flutter/packages/pull/6602 lands. This file uses the // Swift ProxyApi feature from pigeon. // ignore_for_file: avoid_unused_constructor_parameters + /* import 'package:pigeon/pigeon.dart'; diff --git a/packages/interactive_media_ads/test/ads_loader_test.dart b/packages/interactive_media_ads/test/ads_loader_test.dart index bea867e371fa..7b4c8a8aea67 100644 --- a/packages/interactive_media_ads/test/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/ads_loader_test.dart @@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:interactive_media_ads/interactive_media_ads.dart'; +import 'package:interactive_media_ads/src/platform_interface/platform_content_progress_provider.dart'; import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart'; import 'test_stubs.dart'; @@ -38,7 +39,14 @@ void main() { final AdsLoader loader = AdsLoader.fromPlatform(adsLoader); await loader.requestAds( - AdsRequest.fromPlatform(PlatformAdsRequest(adTagUrl: '')), + AdsRequest.fromPlatform( + PlatformAdsRequest( + adTagUrl: 'adTagUrl', + contentProgressProvider: TestContentProgressProvider( + const PlatformContentProgressProviderCreationParams(), + ), + ), + ), ); }); } diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.dart b/packages/interactive_media_ads/test/android/ads_loader_test.dart index 5b772c054e22..ae25fdde99f9 100644 --- a/packages/interactive_media_ads/test/android/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/android/ads_loader_test.dart @@ -115,14 +115,12 @@ void main() { await adsLoader.requestAds( PlatformAdsRequest( adTagUrl: 'url', - contentDuration: const Duration(seconds: 1), contentProgressProvider: progressProvider, ), ); verifyInOrder(>[ mockAdsRequest.setAdTagUrl('url'), - mockAdsRequest.setContentDuration(1.0), mockAdsRequest.setContentProgressProvider( progressProvider.progressProvider, ), diff --git a/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart b/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart index 76dedaa3d567..a56865191d6f 100644 --- a/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart +++ b/packages/interactive_media_ads/test/android/ads_loader_test.mocks.dart @@ -829,16 +829,6 @@ class MockAdsRequest extends _i1.Mock implements _i2.AdsRequest { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override - _i6.Future setContentDuration(double? duration) => (super.noSuchMethod( - Invocation.method( - #setContentDuration, - [duration], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override _i2.AdsRequest pigeon_copy() => (super.noSuchMethod( Invocation.method( diff --git a/packages/interactive_media_ads/test/ios/ads_loader_test.dart b/packages/interactive_media_ads/test/ios/ads_loader_test.dart index eb4e32687958..633e96e9803f 100644 --- a/packages/interactive_media_ads/test/ios/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/ios/ads_loader_test.dart @@ -103,7 +103,6 @@ void main() { await loader.requestAds(PlatformAdsRequest( adTagUrl: adTag, - contentDuration: const Duration(seconds: 10), contentProgressProvider: provider, )); From f1e6897c8c3abc1eb89d884964903fb9af7c79af Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:20:43 -0400 Subject: [PATCH 21/26] try to test requestads --- .../test/ads_loader_test.dart | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/interactive_media_ads/test/ads_loader_test.dart b/packages/interactive_media_ads/test/ads_loader_test.dart index 7b4c8a8aea67..1cea934f1585 100644 --- a/packages/interactive_media_ads/test/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/ads_loader_test.dart @@ -27,27 +27,27 @@ void main() { }); test('requestAds', () async { + final PlatformAdsRequest platformRequest = PlatformAdsRequest( + adTagUrl: 'adTagUrl', + contentProgressProvider: TestContentProgressProvider( + const PlatformContentProgressProviderCreationParams(), + ), + ); + final TestPlatformAdsLoader adsLoader = TestPlatformAdsLoader( PlatformAdsLoaderCreationParams( container: createTestAdDisplayContainer(), onAdsLoaded: (PlatformOnAdsLoadedData data) {}, onAdsLoadError: (AdsLoadErrorData data) {}, ), - onRequestAds: expectAsync1((PlatformAdsRequest request) async {}), + onRequestAds: expectAsync1((PlatformAdsRequest request) async { + expect(request, platformRequest); + }), onContentComplete: () async {}, ); final AdsLoader loader = AdsLoader.fromPlatform(adsLoader); - await loader.requestAds( - AdsRequest.fromPlatform( - PlatformAdsRequest( - adTagUrl: 'adTagUrl', - contentProgressProvider: TestContentProgressProvider( - const PlatformContentProgressProviderCreationParams(), - ), - ), - ), - ); + await loader.requestAds(AdsRequest.fromPlatform(platformRequest)); }); } From a5d73a85bd06accf5bfd4450f1434b5bb55b9688 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:04:22 -0400 Subject: [PATCH 22/26] version bump --- packages/interactive_media_ads/CHANGELOG.md | 4 ++++ .../packages/interactive_media_ads/AdsRequestProxyApi.kt | 2 +- packages/interactive_media_ads/example/lib/main.dart | 2 +- .../interactive_media_ads/AdsRequestProxyAPIDelegate.swift | 2 +- packages/interactive_media_ads/pubspec.yaml | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/interactive_media_ads/CHANGELOG.md b/packages/interactive_media_ads/CHANGELOG.md index 211bf9ea278e..317d9079954b 100644 --- a/packages/interactive_media_ads/CHANGELOG.md +++ b/packages/interactive_media_ads/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.2 + +* Adds support for mid-roll ads. See `AdsRequest.contentProgressProvider`. + ## 0.2.1 * Adds internal wrapper for Android native `ContentProgressProvider`. diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt index 4f07af1d8142..fda8eb07e9bd 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : * * This must match the version in pubspec.yaml. */ - const val pluginVersion = "0.2.1" + const val pluginVersion = "0.2.2" } override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) { diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index a1d48d5a58c2..ff1a20d480e4 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -34,7 +34,7 @@ class AdExampleWidget extends StatefulWidget { class _AdExampleWidgetState extends State with WidgetsBindingObserver { - // IMA sample tag for a single skippable inline video ad. See more IMA sample + // IMA sample tag for skippable a pre-, mid-, and post-roll, single inline video ad. See more IMA sample // tags at https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags static const String _adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpost&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator='; diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift index 4ecd85c58c2f..051f7540aa8f 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift @@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest { /// The current version of the `interactive_media_ads` plugin. /// /// This must match the version in pubspec.yaml. - static let pluginVersion = "0.2.1" + static let pluginVersion = "0.2.2" func pigeonDefaultConstructor( pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer, diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml index 925eae18beb6..e43e2c33f7f9 100644 --- a/packages/interactive_media_ads/pubspec.yaml +++ b/packages/interactive_media_ads/pubspec.yaml @@ -2,7 +2,7 @@ name: interactive_media_ads description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS. repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22 -version: 0.2.1 # This must match the version in +version: 0.2.2 # This must match the version in # `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` and # `ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift` From e458f49157eab0a5f97ce65f17e28814ff0b762a Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:13:18 -0400 Subject: [PATCH 23/26] readme update --- packages/interactive_media_ads/README.md | 45 ++++++++++++++++--- .../InteractiveMediaAdsLibrary.g.kt | 2 +- .../example/lib/main.dart | 2 +- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/packages/interactive_media_ads/README.md b/packages/interactive_media_ads/README.md index 70922f1001f1..9347aa051d91 100644 --- a/packages/interactive_media_ads/README.md +++ b/packages/interactive_media_ads/README.md @@ -81,10 +81,10 @@ class AdExampleWidget extends StatefulWidget { class _AdExampleWidgetState extends State with WidgetsBindingObserver { - // IMA sample tag for a single skippable inline video ad. See more IMA sample + // IMA sample tag for a skippable pre-, mid-, and post-roll, single inline video ad. See more IMA sample // tags at https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags static const String _adTagUrl = - 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator='; + 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpost&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator='; // The AdsLoader instance exposes the request ads method. late final AdsLoader _adsLoader; @@ -123,6 +123,15 @@ late final AdDisplayContainer _adDisplayContainer = AdDisplayContainer( }, ); +// Periodically updates the SDK of the current playback progress of the +// content video. +Timer? _contentProgressTimer; + +// Provides the SDK with the current playback progress of the content video. +// This is required to support mid-roll ads. +final ContentProgressProvider _contentProgressProvider = + ContentProgressProvider(); + @override void initState() { super.initState(); @@ -240,20 +249,45 @@ Future _requestAds(AdDisplayContainer container) { }, ); - return _adsLoader.requestAds(AdsRequest(adTagUrl: _adTagUrl)); + return _adsLoader.requestAds(AdsRequest( + adTagUrl: _adTagUrl, + contentProgressProvider: _contentProgressProvider, + )); } -Future _resumeContent() { +Future _resumeContent() async { setState(() { _shouldShowContentVideo = true; }); - return _contentVideoController.play(); + + if (_adsManager != null) { + _contentProgressTimer = Timer.periodic( + const Duration(milliseconds: 500), + (Timer timer) async { + if (_contentVideoController.value.isInitialized) { + final Duration? progress = await _contentVideoController.position; + if (progress != null) { + await _contentProgressProvider.setProgress( + progress: progress, + duration: _contentVideoController.value.duration, + ); + } + } + }, + ); + } + + if (!_contentVideoController.value.isCompleted) { + await _contentVideoController.play(); + } } Future _pauseContent() { setState(() { _shouldShowContentVideo = false; }); + _contentProgressTimer?.cancel(); + _contentProgressTimer = null; return _contentVideoController.pause(); } ``` @@ -267,6 +301,7 @@ Dispose the content player and destroy the [AdsManager][6]. @override void dispose() { super.dispose(); + _contentProgressTimer?.cancel(); _contentVideoController.dispose(); _adsManager?.destroy(); // ··· diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index 11de60925fae..4056a3d980b6 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -3,7 +3,7 @@ // found in the LICENSE file. // Autogenerated from Pigeon (v22.3.0), do not edit directly. // See also: https://pub.dev/packages/pigeon -@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass". "SyntheticAccessor") +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass", "SyntheticAccessor") package dev.flutter.packages.interactive_media_ads diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index ff1a20d480e4..da68ea1ce57f 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -34,7 +34,7 @@ class AdExampleWidget extends StatefulWidget { class _AdExampleWidgetState extends State with WidgetsBindingObserver { - // IMA sample tag for skippable a pre-, mid-, and post-roll, single inline video ad. See more IMA sample + // IMA sample tag for a skippable pre-, mid-, and post-roll, single inline video ad. See more IMA sample // tags at https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags static const String _adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpost&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator='; From 5fb899b8fec6502b5b877e3904023cca626a08bd Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:23:26 -0400 Subject: [PATCH 24/26] update i think --- packages/interactive_media_ads/README.md | 24 +++++++++---------- .../example/lib/main.dart | 24 +++++++++---------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/packages/interactive_media_ads/README.md b/packages/interactive_media_ads/README.md index 9347aa051d91..7d9316140c84 100644 --- a/packages/interactive_media_ads/README.md +++ b/packages/interactive_media_ads/README.md @@ -81,7 +81,7 @@ class AdExampleWidget extends StatefulWidget { class _AdExampleWidgetState extends State with WidgetsBindingObserver { - // IMA sample tag for a skippable pre-, mid-, and post-roll, single inline video ad. See more IMA sample + // IMA sample tag for a pre-, mid-, and post-roll, single inline video ad. See more IMA sample // tags at https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags static const String _adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpost&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator='; @@ -99,6 +99,15 @@ class _AdExampleWidgetState extends State // Controls the content video player. late final VideoPlayerController _contentVideoController; + + // Periodically updates the SDK of the current playback progress of the + // content video. + Timer? _contentProgressTimer; + + // Provides the SDK with the current playback progress of the content video. + // This is required to support mid-roll ads. + final ContentProgressProvider _contentProgressProvider = + ContentProgressProvider(); // ··· @override Widget build(BuildContext context) { @@ -123,15 +132,6 @@ late final AdDisplayContainer _adDisplayContainer = AdDisplayContainer( }, ); -// Periodically updates the SDK of the current playback progress of the -// content video. -Timer? _contentProgressTimer; - -// Provides the SDK with the current playback progress of the content video. -// This is required to support mid-roll ads. -final ContentProgressProvider _contentProgressProvider = - ContentProgressProvider(); - @override void initState() { super.initState(); @@ -277,9 +277,7 @@ Future _resumeContent() async { ); } - if (!_contentVideoController.value.isCompleted) { - await _contentVideoController.play(); - } + await _contentVideoController.play(); } Future _pauseContent() { diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index da68ea1ce57f..b5973f1e876b 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -34,7 +34,7 @@ class AdExampleWidget extends StatefulWidget { class _AdExampleWidgetState extends State with WidgetsBindingObserver { - // IMA sample tag for a skippable pre-, mid-, and post-roll, single inline video ad. See more IMA sample + // IMA sample tag for a pre-, mid-, and post-roll, single inline video ad. See more IMA sample // tags at https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags static const String _adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpost&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator='; @@ -56,6 +56,15 @@ class _AdExampleWidgetState extends State // Controls the content video player. late final VideoPlayerController _contentVideoController; + + // Periodically updates the SDK of the current playback progress of the + // content video. + Timer? _contentProgressTimer; + + // Provides the SDK with the current playback progress of the content video. + // This is required to support mid-roll ads. + final ContentProgressProvider _contentProgressProvider = + ContentProgressProvider(); // #enddocregion example_widget // #docregion ad_and_content_players @@ -67,15 +76,6 @@ class _AdExampleWidgetState extends State }, ); - // Periodically updates the SDK of the current playback progress of the - // content video. - Timer? _contentProgressTimer; - - // Provides the SDK with the current playback progress of the content video. - // This is required to support mid-roll ads. - final ContentProgressProvider _contentProgressProvider = - ContentProgressProvider(); - @override void initState() { super.initState(); @@ -193,9 +193,7 @@ class _AdExampleWidgetState extends State ); } - if (!_contentVideoController.value.isCompleted) { - await _contentVideoController.play(); - } + await _contentVideoController.play(); } Future _pauseContent() { From c80ef68b4e909ff5dfc5d0447eab23028698c61b Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:52:49 -0400 Subject: [PATCH 25/26] improve imports --- packages/interactive_media_ads/lib/src/ads_request.dart | 2 +- .../lib/src/content_progress_provider.dart | 2 +- .../lib/src/platform_interface/platform_interface.dart | 1 + packages/interactive_media_ads/test/ads_loader_test.dart | 1 - packages/interactive_media_ads/test/test_stubs.dart | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/interactive_media_ads/lib/src/ads_request.dart b/packages/interactive_media_ads/lib/src/ads_request.dart index 11043892df28..ecc8e2f2ccc5 100644 --- a/packages/interactive_media_ads/lib/src/ads_request.dart +++ b/packages/interactive_media_ads/lib/src/ads_request.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'content_progress_provider.dart'; -import 'platform_interface/platform_ads_request.dart'; +import 'platform_interface/platform_interface.dart'; /// An object containing the data used to request ads from the server. class AdsRequest { diff --git a/packages/interactive_media_ads/lib/src/content_progress_provider.dart b/packages/interactive_media_ads/lib/src/content_progress_provider.dart index 46b569709e66..60154729910b 100644 --- a/packages/interactive_media_ads/lib/src/content_progress_provider.dart +++ b/packages/interactive_media_ads/lib/src/content_progress_provider.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'platform_interface/platform_content_progress_provider.dart'; +import 'platform_interface/platform_interface.dart'; /// Allow the SDK to track progress of the content video. /// diff --git a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart index cc727464b60c..fad06fe592f5 100644 --- a/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart +++ b/packages/interactive_media_ads/lib/src/platform_interface/platform_interface.dart @@ -10,3 +10,4 @@ export 'platform_ads_loader.dart'; export 'platform_ads_manager.dart'; export 'platform_ads_manager_delegate.dart'; export 'platform_ads_request.dart'; +export 'platform_content_progress_provider.dart'; diff --git a/packages/interactive_media_ads/test/ads_loader_test.dart b/packages/interactive_media_ads/test/ads_loader_test.dart index 1cea934f1585..c571830fc4f3 100644 --- a/packages/interactive_media_ads/test/ads_loader_test.dart +++ b/packages/interactive_media_ads/test/ads_loader_test.dart @@ -5,7 +5,6 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:interactive_media_ads/interactive_media_ads.dart'; -import 'package:interactive_media_ads/src/platform_interface/platform_content_progress_provider.dart'; import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart'; import 'test_stubs.dart'; diff --git a/packages/interactive_media_ads/test/test_stubs.dart b/packages/interactive_media_ads/test/test_stubs.dart index 3b2779e9598f..328f58f46995 100644 --- a/packages/interactive_media_ads/test/test_stubs.dart +++ b/packages/interactive_media_ads/test/test_stubs.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/material.dart'; -import 'package:interactive_media_ads/src/platform_interface/platform_content_progress_provider.dart'; import 'package:interactive_media_ads/src/platform_interface/platform_interface.dart'; final class TestInteractiveMediaAdsPlatform From d183264347032c7eb9431c25bca66e666a603956 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:49:54 -0400 Subject: [PATCH 26/26] update interval --- packages/interactive_media_ads/README.md | 2 +- packages/interactive_media_ads/example/lib/main.dart | 2 +- .../lib/src/content_progress_provider.dart | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/interactive_media_ads/README.md b/packages/interactive_media_ads/README.md index 7d9316140c84..74441a71def5 100644 --- a/packages/interactive_media_ads/README.md +++ b/packages/interactive_media_ads/README.md @@ -262,7 +262,7 @@ Future _resumeContent() async { if (_adsManager != null) { _contentProgressTimer = Timer.periodic( - const Duration(milliseconds: 500), + const Duration(milliseconds: 200), (Timer timer) async { if (_contentVideoController.value.isInitialized) { final Duration? progress = await _contentVideoController.position; diff --git a/packages/interactive_media_ads/example/lib/main.dart b/packages/interactive_media_ads/example/lib/main.dart index b5973f1e876b..9bafdda819e9 100644 --- a/packages/interactive_media_ads/example/lib/main.dart +++ b/packages/interactive_media_ads/example/lib/main.dart @@ -178,7 +178,7 @@ class _AdExampleWidgetState extends State if (_adsManager != null) { _contentProgressTimer = Timer.periodic( - const Duration(milliseconds: 500), + const Duration(milliseconds: 200), (Timer timer) async { if (_contentVideoController.value.isInitialized) { final Duration? progress = await _contentVideoController.position; diff --git a/packages/interactive_media_ads/lib/src/content_progress_provider.dart b/packages/interactive_media_ads/lib/src/content_progress_provider.dart index 60154729910b..0b0f0e6df8b5 100644 --- a/packages/interactive_media_ads/lib/src/content_progress_provider.dart +++ b/packages/interactive_media_ads/lib/src/content_progress_provider.dart @@ -80,6 +80,9 @@ class ContentProgressProvider { final PlatformContentProgressProvider platform; /// Sends an update on the progress of the content video. + /// + /// When using a `Timer` to periodically send updates through this method, an + /// interval of 200ms is recommended. Future setProgress({ required Duration progress, required Duration duration,