Skip to content
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

Allow configuration of ad load timeout for Google IMA plugin #468

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion android/src/main/java/com/theoplayer/PlayerConfigAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private const val PROP_RETRY_MAX_BACKOFF = "maximumBackoff"
private const val PROP_CAST_CONFIGURATION = "cast"
private const val PROP_ADS_CONFIGURATION = "ads"
private const val PROP_IMA_CONFIGURATION = "ima"
private const val PROP_IMA_AD_LOAD_TIMEOUT = "adLoadTimeout"
private const val PROP_MEDIA_CONTROL = "mediaControl"
private const val PROP_PPID = "ppid"
private const val PROP_MAX_REDIRECTS = "maxRedirects"
Expand Down Expand Up @@ -169,11 +170,17 @@ class PlayerConfigAdapter(private val configProps: ReadableMap?) {
}
}
}
// bitrate is configured under the ima config
// bitrate and timeout are configured under the ima config
configProps?.getMap(PROP_ADS_CONFIGURATION)?.getMap(PROP_IMA_CONFIGURATION)?.run {
if (hasKey(PROP_BITRATE)) {
bitrateKbps = getInt(PROP_BITRATE)
}

// The time needs to be in milliseconds on android but seconds on ios.
// we unify the prop from javascript by multiplying it by 1000 here
if (hasKey(PROP_IMA_AD_LOAD_TIMEOUT)) {
setLoadVideoTimeout(getInt(PROP_IMA_AD_LOAD_TIMEOUT) * 1000)
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions ios/ads/THEOplayerRCTView+Ads.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
imaRenderSettings.mimeTypes = allowedMimeTypes
}

if let adLoadTimeout = self.adsConfig.adsImaConfig.adLoadTimeout {
imaRenderSettings.loadVideoTimeout = adLoadTimeout

Check failure on line 61 in ios/ads/THEOplayerRCTView+Ads.swift

View workflow job for this annotation

GitHub Actions / Build for tvOS using XCode version 15.4.0

cannot assign value of type 'Int' to type 'TimeInterval' (aka 'Double')
}

// setup integration
let imaIntegration = GoogleIMAIntegrationFactory.createIntegration(on: player, with: imaSettings)
imaIntegration.renderingSettings = imaRenderSettings
Expand Down
7 changes: 6 additions & 1 deletion ios/ads/THEOplayerRCTView+AdsConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ struct AdsImaConfig {
var autoPlayAdBreaks: Bool?
var sessionID: String?
var bitrate: Int
var adLoadTimeout: Int?

init(maxRedirects: UInt, enableDebugMode: Bool, ppid: String? = nil, featureFlags: [String : String]? = nil, autoPlayAdBreaks: Bool? = nil, sessionID: String? = nil, bitrate: Int? = -1) {
init(maxRedirects: UInt, enableDebugMode: Bool, ppid: String? = nil, featureFlags: [String : String]? = nil, autoPlayAdBreaks: Bool? = nil, sessionID: String? = nil, bitrate: Int? = -1, adLoadTimeout: Int? = nil) {
self.maxRedirects = maxRedirects
self.enableDebugMode = enableDebugMode
self.ppid = ppid
self.featureFlags = featureFlags
self.autoPlayAdBreaks = autoPlayAdBreaks
self.sessionID = sessionID
self.adLoadTimeout = adLoadTimeout
#if canImport(THEOplayerGoogleIMAIntegration)
self.bitrate = bitrate ?? kIMAAutodetectBitrate
#else
Expand Down Expand Up @@ -67,6 +69,9 @@ extension THEOplayerRCTView {
if let bitrate = adsImaConfig["bitrate"] as? Int {
self.adsConfig.adsImaConfig.bitrate = bitrate
}
if let adLoadTimeout = adsImaConfig["adLoadTimeout"] as? Int {
self.adsConfig.adsImaConfig.adLoadTimeout = adLoadTimeout
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/api/ads/GoogleImaConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ export interface GoogleImaConfiguration {
* @defaultValue `-1`
*/
bitrate?: number;

/**
* The amount of time that the SDK will wait before moving onto the next ad for loading.
* This value will be specified in seconds.
*/
adLoadTimeout?: number;
}
Loading