@@ -7,14 +7,57 @@ import 'platform_interface/platform_interface.dart';
7
7
8
8
/// An object containing the data used to request ads from the server.
9
9
class AdsRequest {
10
- /// Creates an [AdsRequest] .
10
+ /// Creates an [AdsRequest] with the given ad tag URL .
11
11
AdsRequest ({
12
12
required String adTagUrl,
13
13
ContentProgressProvider ? contentProgressProvider,
14
+ bool ? adWillAutoPlay,
15
+ bool ? adWillPlayMuted,
16
+ bool ? continuousPlayback,
17
+ Duration ? contentDuration,
18
+ List <String >? contentKeywords,
19
+ String ? contentTitle,
20
+ Duration ? liveStreamPrefetchMaxWaitTime,
21
+ Duration ? vastLoadTimeout,
14
22
}) : this .fromPlatform (
15
- PlatformAdsRequest (
23
+ PlatformAdsRequest . withAdTagUrl (
16
24
adTagUrl: adTagUrl,
17
25
contentProgressProvider: contentProgressProvider? .platform,
26
+ adWillAutoPlay: adWillAutoPlay,
27
+ adWillPlayMuted: adWillPlayMuted,
28
+ continuousPlayback: continuousPlayback,
29
+ contentDuration: contentDuration,
30
+ contentKeywords: contentKeywords,
31
+ contentTitle: contentTitle,
32
+ liveStreamPrefetchMaxWaitTime: liveStreamPrefetchMaxWaitTime,
33
+ vastLoadTimeout: vastLoadTimeout,
34
+ ),
35
+ );
36
+
37
+ /// Creates an [AdsRequest] with the given canned ads response.
38
+ AdsRequest .withAdsResponse ({
39
+ required String adsResponse,
40
+ ContentProgressProvider ? contentProgressProvider,
41
+ bool ? adWillAutoPlay,
42
+ bool ? adWillPlayMuted,
43
+ bool ? continuousPlayback,
44
+ Duration ? contentDuration,
45
+ List <String >? contentKeywords,
46
+ String ? contentTitle,
47
+ Duration ? liveStreamPrefetchMaxWaitTime,
48
+ Duration ? vastLoadTimeout,
49
+ }) : this .fromPlatform (
50
+ PlatformAdsRequest .withAdsResponse (
51
+ adsResponse: adsResponse,
52
+ contentProgressProvider: contentProgressProvider? .platform,
53
+ adWillAutoPlay: adWillAutoPlay,
54
+ adWillPlayMuted: adWillPlayMuted,
55
+ continuousPlayback: continuousPlayback,
56
+ contentDuration: contentDuration,
57
+ contentKeywords: contentKeywords,
58
+ contentTitle: contentTitle,
59
+ liveStreamPrefetchMaxWaitTime: liveStreamPrefetchMaxWaitTime,
60
+ vastLoadTimeout: vastLoadTimeout,
18
61
),
19
62
);
20
63
@@ -25,7 +68,20 @@ class AdsRequest {
25
68
final PlatformAdsRequest platform;
26
69
27
70
/// The URL from which ads will be requested.
28
- String get adTagUrl => platform.adTagUrl;
71
+ String get adTagUrl => switch (platform) {
72
+ final PlatformAdsRequestWithAdTagUrl request => request.adTagUrl,
73
+ // TODO(bparrishMines): This returns an empty string rather than null
74
+ // to prevent a breaking change. This should be updated to return null
75
+ // on the next major release.
76
+ PlatformAdsRequestWithAdsResponse () => '' ,
77
+ };
78
+
79
+ /// Specifies a VAST, VMAP, or ad rules response to be used instead of making
80
+ /// a request through an ad tag URL.
81
+ String ? get adsResponse => switch (platform) {
82
+ final PlatformAdsRequestWithAdsResponse request => request.adsResponse,
83
+ PlatformAdsRequestWithAdTagUrl () => null ,
84
+ };
29
85
30
86
/// A [ContentProgressProvider] instance to allow scheduling of ad breaks
31
87
/// based on content progress (cue points).
@@ -34,4 +90,33 @@ class AdsRequest {
34
90
null
35
91
? ContentProgressProvider .fromPlatform (platform.contentProgressProvider! )
36
92
: null ;
93
+
94
+ /// Notifies the SDK whether the player intends to start the content and ad in
95
+ /// response to a user action or whether it will be automatically played.
96
+ bool ? get adWillAutoPlay => platform.adWillAutoPlay;
97
+
98
+ /// Notifies the SDK whether the player intends to start the content and ad
99
+ /// while muted.
100
+ bool ? get adWillPlayMuted => platform.adWillPlayMuted;
101
+
102
+ /// Notifies the SDK whether the player intends to continuously play the
103
+ /// content videos one after another similar to TV broadcast.
104
+ bool ? get continuousPlayback => platform.continuousPlayback;
105
+
106
+ /// Specifies the duration of the content to be shown.
107
+ Duration ? get contentDuration => platform.contentDuration;
108
+
109
+ /// Specifies the keywords used to describe the content to be shown.
110
+ List <String >? get contentKeywords => platform.contentKeywords;
111
+
112
+ /// Specifies the title of the content to be shown.
113
+ String ? get contentTitle => platform.contentTitle;
114
+
115
+ /// Specifies the maximum amount of time to wait, after calling requestAds,
116
+ /// before requesting the ad tag URL.
117
+ Duration ? get liveStreamPrefetchMaxWaitTime =>
118
+ platform.liveStreamPrefetchMaxWaitTime;
119
+
120
+ /// Specifies the VAST load timeout in milliseconds for a single wrapper.
121
+ Duration ? get vastLoadTimeout => platform.vastLoadTimeout;
37
122
}
0 commit comments