-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[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
Open
bparrishMines
wants to merge
39
commits into
flutter:main
Choose a base branch
from
bparrishMines:ima_ad_event_ad
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
131811f
run pigeon
bparrishMines dc9ed24
add missing apis
bparrishMines 406e507
tests
bparrishMines 07122c9
fix tests sort of
bparrishMines 9acd11c
try fix tests maybe
bparrishMines 038f303
fix version bump
bparrishMines bf56d72
fix tests
bparrishMines 2f37abc
update adevent to
bparrishMines db23655
changelog update
bparrishMines 84a9fba
Merge branch 'main' of github.com:flutter/packages into ima_ad_ios
bparrishMines dff3de9
fix pigeon code
bparrishMines 660aa72
support a string value
bparrishMines 3af4706
fix tests
bparrishMines 5929f30
Merge branch 'main' of github.com:flutter/packages into ima_ad_ios
bparrishMines b00649e
comment the code
bparrishMines 52d7635
Merge branch 'main' of github.com:flutter/packages into ima_ad_ios
bparrishMines 7f77c09
version bump
bparrishMines 473357a
improve ad proxy code
bparrishMines 37ce423
Merge branch 'main' of github.com:flutter/packages into ima_ad_ios
bparrishMines 711064b
start of implementation
bparrishMines 88541d8
platform implementations
bparrishMines 3f2bc4a
Merge branch 'main' of github.com:flutter/packages into ima_ad_event_ad
bparrishMines 5839848
app facing interface implementation
bparrishMines 457ffe5
fix tests
bparrishMines 701e8e7
version bump
bparrishMines 6bff03f
make resource value nullable
bparrishMines 7f30199
analyze error
bparrishMines 634dbf5
Merge branch 'main' of github.com:flutter/packages into ima_ad_event_ad
bparrishMines 575eebd
update docs and add null checks
bparrishMines 8567b5a
add test for android ads
bparrishMines ccc3ad1
tests for ios
bparrishMines 4e93744
actually add ios tests
bparrishMines bc89942
include ad for test
bparrishMines f2bccf7
Merge branch 'main' of github.com:flutter/packages into ima_ad_event_ad
bparrishMines 76693c0
Merge branch 'main' of github.com:flutter/packages into ima_ad_event_ad
bparrishMines ba27a6a
update licenses
bparrishMines dda426c
update mocks
bparrishMines abdfa17
Merge branch 'main' of github.com:flutter/packages into ima_ad_event_ad
bparrishMines 7d8f720
some comment fixes
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). | ||
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? |
||
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; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.)