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

UplynkAdBreak and UplynkAd as a customData in SSAI #33

Merged
merged 4 commits into from
Sep 9, 2024
Merged
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
43 changes: 42 additions & 1 deletion connectors/uplynk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,46 @@ theoplayerView.player.source = SourceDescription
.build()
```

[uplynk-documentation]: https://docs.edgecast.com/video/#Setup/Setup-Overview.htm%3FTocPath%3DBasic%2520Setup%7C_____0
### Getting Ad Information

To retrieve information about the currently playing ad or ad break, you can use the following properties of THEOplayer:

- `player.ads.currentAds`: Provides a list of currently playing ads.
- `player.ads.currentAdBreak`: Provides information about the currently active ad break.

These fields contain generic data for any ad or ad break in THEOplayer.
However, for Uplynk-specific ad data, you can access the `customData` property.
Below are examples demonstrating how to do that:

```kotlin
fun logCurrentAd() {
val uplynkAd =
theoplayerView.player.ads.currentAds.firstOrNull()?.customData as? UplynkAd ?: return
Log.d(
TAG, "UplynkAd: " +
"apiFramework = ${uplynkAd.apiFramework}, " +
"events = ${uplynkAd.events}, " +
"duration = ${uplynkAd.duration}, " +
"height = ${uplynkAd.height}, " +
"width = ${uplynkAd.width}, " +
"fwParameters = ${uplynkAd.fwParameters}, " +
"mimeType = ${uplynkAd.mimeType}"
)
}

fun logCurrentAdBreak() {
val uplynkAdBreak =
theoplayerView.player.ads.currentAdBreak?.customData as? UplynkAdBreak ?: return
Log.d(
TAG, "UplynkAdBreak: " +
"type = ${uplynkAdBreak.type}, " +
"ads = ${uplynkAdBreak.ads.size}, " +
"duration = ${uplynkAdBreak.duration}, " +
"timeOffset = ${uplynkAdBreak.timeOffset}, " +
"position = ${uplynkAdBreak.position}"
)
}
```

[uplynk-documentation]: https://docs.edgecast.com/video/#Setup/Setup-Overview.htm
[android-getting-started]: https://www.theoplayer.com/docs/theoplayer/getting-started/sdks/android/getting-started/
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ internal class AdHandler(private val controller: ServerSideAdIntegrationControll
private val scheduledAds = WeakHashMap<UplynkAd, Ad>()

fun createAdBreak(adBreak: UplynkAdBreak) {
val adBreakInit = AdBreakInit(adBreak.timeOffset.secToMs, adBreak.duration.secToMs)
val adBreakInit = AdBreakInit(
timeOffset = adBreak.timeOffset.secToMs,
maxDuration = adBreak.duration.secToMs,
customData = adBreak
)
val currentAdBreak = controller.createAdBreak(adBreakInit)
adBreak.ads.forEach {
val adInit = AdInit(type = adBreak.type, duration = it.duration.secToMs)
val adInit = AdInit(
type = adBreak.type,
duration = it.duration.secToMs,
customData = it
)
scheduledAds[it] = controller.createAd(adInit, currentAdBreak)
}
}
Expand Down