Skip to content

Commit

Permalink
Merge pull request #268 from THEOplayer/feature/android_expand_adevents
Browse files Browse the repository at this point in the history
Feature/android expand adevents
  • Loading branch information
Jeroen-Veltmans authored Feb 22, 2024
2 parents 53b550a + d8aca8e commit 9fe2569
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Renamed native modules to avoid name collisions with external packages.

### Added

- Added `adbreakbegin` and `adbreakend` events for Google IMA on Android.

## [3.7.1] - 24-02-09

### Fixed

- Fixed a dependency issue on iOS when using chromecast or google ima features.
- Fixed a dependency issue on iOS when using chromecast or Google IMA features.

## [3.7.0] - 24-02-09

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ dependencies {
println("Using THEOplayer (${versionString(theoplayer_sdk_version)})")
implementation "com.theoplayer.theoplayer-sdk-android:core:${theoplayer_sdk_version}"

implementation "com.theoplayer.theoplayer-sdk-android:ads-wrapper:4.8.0"
implementation "com.theoplayer.theoplayer-sdk-android:ads-wrapper:6.10.0"

if (enabledMediaSession) {
println("Enable THEOplayer MediaSession extension (${versionString(theoplayer_mediasession_version)})")
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.theoplayer.theoplayer-sdk-android</groupId>
<artifactId>ads-wrapper</artifactId>
<version>4.8.0</version>
<version>6.10.0</version>
<packaging>aar</packaging>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<groupId>com.theoplayer.theoplayer-sdk-android</groupId>
<artifactId>ads-wrapper</artifactId>
<versioning>
<latest>4.8.0</latest>
<release>4.8.0</release>
<latest>6.10.0</latest>
<release>6.10.0</release>
<versions>
<version>4.8.0</version>
<version>6.10.0</version>
</versions>
<lastUpdated>20230217111544</lastUpdated>
<lastUpdated>20240221111544</lastUpdated>
</versioning>
</metadata>
13 changes: 9 additions & 4 deletions android/src/main/java/com/theoplayer/ads/AdEventAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.ReadableMap
import com.theoplayer.android.api.ads.wrapper.AdsApiWrapper
import com.facebook.react.bridge.WritableMap
import com.google.ads.interactivemedia.v3.api.AdError
import com.theoplayer.android.api.ads.Ad
import com.theoplayer.android.api.ads.AdBreak
import com.theoplayer.android.api.ads.GoogleImaAd
Expand All @@ -30,7 +31,9 @@ private val ALL_AD_EVENTS = arrayOf(
GoogleImaAdEventType.SKIPPED,
GoogleImaAdEventType.AD_ERROR,
GoogleImaAdEventType.AD_BUFFERING,
GoogleImaAdEventType.AD_BREAK_FETCH_ERROR
GoogleImaAdEventType.AD_BREAK_FETCH_ERROR,
GoogleImaAdEventType.CONTENT_PAUSE_REQUESTED,
GoogleImaAdEventType.CONTENT_RESUME_REQUESTED
)

class AdEventAdapter(private val adsApi: AdsApiWrapper, eventEmitter: AdEventEmitter) {
Expand All @@ -42,7 +45,7 @@ class AdEventAdapter(private val adsApi: AdsApiWrapper, eventEmitter: AdEventEmi

init {
eventListener = object : AdEventListener {
override fun <E : AdEvent<*>?> onAdEvent(type: EventType<E>?, ad: Ad?) {
override fun <E : AdEvent<*>?> onAdEvent(type: EventType<E>?, ad: Ad?, adData: Map<String, String>?, adError: AdError?) {
val payload = Arguments.createMap()
if (type != null) {
payload.putString(EVENT_PROP_TYPE, mapAdType(type))
Expand All @@ -53,7 +56,7 @@ class AdEventAdapter(private val adsApi: AdsApiWrapper, eventEmitter: AdEventEmi
eventEmitter.emit(payload)
}

override fun <E : AdEvent<*>?> onAdBreakEvent(type: EventType<E>?, adBreak: AdBreak?) {
override fun <E : AdEvent<*>?> onAdBreakEvent(type: EventType<E>?, adBreak: AdBreak?, adData: Map<String, String>?, adError: AdError?) {
val payload = Arguments.createMap()
if (type != null) {
payload.putString(EVENT_PROP_TYPE, mapAdType(type))
Expand Down Expand Up @@ -106,7 +109,7 @@ class AdEventAdapter(private val adsApi: AdsApiWrapper, eventEmitter: AdEventEmi
"aderror" -> GoogleImaAdEventType.AD_ERROR
"adbuffering" -> GoogleImaAdEventType.AD_BUFFERING
"adbreakbegin" -> GoogleImaAdEventType.AD_BREAK_STARTED
"adbreakend" -> GoogleImaAdEventType.CONTENT_RESUME_REQUESTED
"adbreakend" -> GoogleImaAdEventType.AD_BREAK_ENDED
else -> null /*unknown*/
}
}
Expand All @@ -122,6 +125,8 @@ class AdEventAdapter(private val adsApi: AdsApiWrapper, eventEmitter: AdEventEmi
GoogleImaAdEventType.SKIPPED -> "adskip"
GoogleImaAdEventType.AD_ERROR -> "aderror"
GoogleImaAdEventType.AD_BUFFERING -> "adbuffering"
GoogleImaAdEventType.CONTENT_PAUSE_REQUESTED -> "adbreakbegin"
GoogleImaAdEventType.CONTENT_RESUME_REQUESTED -> "adbreakend"
GoogleImaAdEventType.AD_BREAK_STARTED -> "adbreakbegin"
GoogleImaAdEventType.AD_BREAK_ENDED -> "adbreakend"
GoogleImaAdEventType.AD_BREAK_FETCH_ERROR -> "aderror"
Expand Down

0 comments on commit 9fe2569

Please sign in to comment.