-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[interactive_media_ads] Adds support for accessing data for an Ad #9972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
131811f
dc9ed24
406e507
07122c9
9acd11c
038f303
bf56d72
2f37abc
db23655
84a9fba
dff3de9
660aa72
3af4706
5929f30
b00649e
52d7635
7f77c09
473357a
37ce423
711064b
88541d8
3f2bc4a
5839848
457ffe5
701e8e7
6bff03f
7f30199
634dbf5
575eebd
8567b5a
ccc3ad1
4e93744
bc89942
f2bccf7
76693c0
ba27a6a
dda426c
abdfa17
7d8f720
88c1c05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'platform_interface/platform_interface.dart'; | ||
|
|
||
| /// Data object representing a single ad. | ||
| class Ad { | ||
| /// Constructs an [Ad] from a specific platform implementation. | ||
| Ad.fromPlatform(this.platform); | ||
|
|
||
| /// Implementation of [PlatformAd] for the current platform. | ||
| final PlatformAd platform; | ||
|
|
||
| /// The ad ID as specified in the VAST response. | ||
| String get adId => platform.adId; | ||
|
|
||
| /// The pod metadata object. | ||
| AdPodInfo get adPodInfo => AdPodInfo.fromPlatform(platform.adPodInfo); | ||
|
|
||
| /// The ad system as specified in the VAST response. | ||
| String get adSystem => platform.adSystem; | ||
|
|
||
| /// The IDs of the ads' creatives, starting with the first wrapper ad. | ||
| List<String> get wrapperCreativeIds => platform.wrapperCreativeIds; | ||
|
|
||
| /// The wrapper ad IDs as specified in the VAST response. | ||
| List<String> get wrapperIds => platform.wrapperIds; | ||
|
|
||
| /// The wrapper ad systems as specified in the VAST response. | ||
| List<String> get wrapperSystems => platform.wrapperSystems; | ||
|
|
||
| /// The advertiser name as defined by the serving party. | ||
| String get advertiserName => platform.advertiserName; | ||
|
|
||
| /// The companions for the current ad while using DAI. | ||
| /// | ||
| /// Returns an empty list in any other scenario. | ||
| List<CompanionAd> get companionAds => List<CompanionAd>.unmodifiable( | ||
| platform.companionAds.map(CompanionAd.fromPlatform), | ||
| ); | ||
|
|
||
| /// The content type of the currently selected creative, or null if no | ||
| /// creative is selected or the content type is unavailable. | ||
| String? get contentType => platform.contentType; | ||
|
|
||
| /// The ISCI (Industry Standard Commercial Identifier) code for an ad. | ||
| String get creativeAdId => platform.creativeAdId; | ||
|
|
||
| /// The ID of the selected creative for the ad, | ||
| String get creativeId => platform.creativeId; | ||
|
|
||
| /// The first deal ID present in the wrapper chain for the current ad, | ||
| /// starting from the top. | ||
| String get dealId => platform.dealId; | ||
|
|
||
| /// The description of this ad from the VAST response. | ||
| String? get description => platform.description; | ||
|
|
||
| /// The duration of the ad. | ||
| Duration? get duration => platform.duration; | ||
|
|
||
| /// The width of the selected creative if non-linear, else returns 0. | ||
| int get width => platform.width; | ||
|
|
||
| /// The height of the selected creative if non-linear, else returns 0. | ||
| int get height => platform.height; | ||
|
|
||
| /// The playback time before the ad becomes skippable. | ||
| /// | ||
| /// The value is null for non-skippable ads, or if the value is unavailable. | ||
| Duration? get skipTimeOffset => platform.skipTimeOffset; | ||
|
|
||
| /// The URL associated with the survey for the given ad. | ||
| String? get surveyUrl => platform.surveyUrl; | ||
|
|
||
| /// The title of this ad from the VAST response. | ||
| String? get title => platform.title; | ||
|
|
||
| /// The custom parameters associated with the ad at the time of ad | ||
| /// trafficking. | ||
| String get traffickingParameters => platform.traffickingParameters; | ||
|
|
||
| /// The set of ad UI elements rendered by the IMA SDK for this ad. | ||
| Set<AdUIElement> get uiElements => platform.uiElements; | ||
|
|
||
| /// The list of all universal ad IDs for this ad. | ||
| List<UniversalAdId> get universalAdIds => List<UniversalAdId>.unmodifiable( | ||
| platform.universalAdIds.map(UniversalAdId.fromPlatform), | ||
| ); | ||
|
|
||
| /// The VAST bitrate in Kbps of the selected creative. | ||
| int get vastMediaBitrate => platform.vastMediaBitrate; | ||
|
|
||
| /// The VAST media height in pixels of the selected creative. | ||
| int get vastMediaHeight => platform.vastMediaHeight; | ||
|
|
||
| /// The VAST media width in pixels of the selected creative. | ||
| int get vastMediaWidth => platform.vastMediaWidth; | ||
|
|
||
| /// Indicates whether the ad’s current mode of operation is linear or | ||
| /// non-linear. | ||
| bool get isLinear => platform.isLinear; | ||
|
|
||
| /// Indicates whether the ad can be skipped by the user. | ||
| bool get isSkippable => platform.isSkippable; | ||
| } | ||
|
|
||
| /// Simple data object containing podding metadata. | ||
| class AdPodInfo { | ||
| /// Constructs an [AdPodInfo] from a specific platform implementation. | ||
| AdPodInfo.fromPlatform(this.platform); | ||
|
|
||
| /// Implementation of [PlatformAdPodInfo] for the current platform. | ||
| final PlatformAdPodInfo platform; | ||
|
|
||
| /// 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. | ||
| int get adPosition => platform.adPosition; | ||
|
|
||
| /// The maximum duration of the pod. | ||
| /// | ||
| /// For unknown duration, null. | ||
| Duration? get maxDuration => platform.maxDuration; | ||
|
|
||
| /// Returns the index of the ad pod. | ||
| /// | ||
| /// Client side: For a preroll pod, returns 0. For midrolls, returns 1, 2,…, | ||
| /// N. For a postroll pod, returns -1. Defaults to 0 if this ad is not part of | ||
| /// a pod, or this pod is not part of a playlist. | ||
| /// | ||
| /// DAI VOD: Returns the index of the ad pod. For a preroll pod, returns 0. | ||
| /// For midrolls, returns 1, 2,…,N. For a postroll pod, returns N+1…N+X. | ||
| /// Defaults to 0 if this ad is not part of a pod, or this pod is not part of | ||
| /// a playlist. | ||
| /// | ||
| /// DAI live stream: For a preroll pod, returns 0. For midrolls, returns the | ||
| /// break ID. Returns -2 if pod index cannot be determined (internal error). | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make constants for these magic values, and document those instead of the raw values?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I don't know how to reconcile that this value can be any positive integer when it's a mid rolls. Also, postroll are represented differently depending if you are using client side ads or DAI VOD and there isn't a way to get the type in the class. |
||
| int get podIndex => platform.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. 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. | ||
| Duration get timeOffset => platform.timeOffset; | ||
|
|
||
| /// Total number of ads in the pod this ad belongs to, including bumpers. | ||
| /// | ||
| /// Will be 1 for standalone ads. | ||
| int get totalAds => platform.totalAds; | ||
|
|
||
| /// Specifies whether the ad is a bumper. | ||
| /// | ||
| /// Bumpers are short videos used to open and close ad breaks. | ||
| bool get isBumper => platform.isBumper; | ||
| } | ||
|
|
||
| /// An object that holds data corresponding to the companion Ad. | ||
| class CompanionAd { | ||
| /// Constructs a [CompanionAd] from a specific platform implementation. | ||
| CompanionAd.fromPlatform(this.platform); | ||
|
|
||
| /// Implementation of [PlatformCompanionAd] for the current platform. | ||
| final PlatformCompanionAd platform; | ||
|
|
||
| /// The width of the companion in pixels. | ||
| /// | ||
| /// `null` if unavailable. | ||
| int? get width => platform.width; | ||
|
|
||
| /// The height of the companion in pixels. | ||
| /// | ||
| /// `null` if unavailable. | ||
| int? get height => platform.height; | ||
|
|
||
| /// The API needed to execute this ad, or null if unavailable. | ||
| String? get apiFramework => platform.apiFramework; | ||
|
|
||
| /// The URL for the static resource of this companion. | ||
| String? get resourceValue => platform.resourceValue; | ||
| } | ||
|
|
||
| /// Simple data object containing universal ad ID information. | ||
| class UniversalAdId { | ||
| /// Constructs an [UniversalAdId] from a specific platform implementation. | ||
| UniversalAdId.fromPlatform(this.platform); | ||
|
|
||
| /// Implementation of [PlatformUniversalAdId] for the current platform. | ||
| final PlatformUniversalAdId platform; | ||
|
|
||
| /// The universal ad ID value. | ||
| /// | ||
| /// This will be null if it isn’t defined by the ad. | ||
| String? get adIdValue => platform.adIdValue; | ||
|
|
||
| /// The universal ad ID registry with which the value is registered. | ||
| /// | ||
| /// This will be null if it isn’t defined by the ad. | ||
| String? get adIdRegistry => platform.adIdRegistry; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is inconsistent with the previous file's capitalization of ID; the Dart API surface should consistently use one or the other. (Same with other names below.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Android and iOS use different capitalization so I end up switching on accident. It looks like the precedent is already to use lowercase so I updated the other values.