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

Release/v3.3.2 #240

Merged
merged 11 commits into from
Dec 12, 2023
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [3.3.2] - 23-12-12

### Fixed

- Fixed an issue on iOS & Android where timestamps in ad events were not consistently defined in seconds.
- Fixed an issue on tvOS where unknown AdIntegrationKind values resulted in build issues.

## [3.3.1] - 23-12-11

### Fixed
Expand Down
21 changes: 9 additions & 12 deletions android/src/main/java/com/theoplayer/ads/AdAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object AdAdapter {
adPayload.putInt(PROP_AD_BITRATE, ad.vastMediaBitrate)
try {
adPayload.putString(PROP_AD_TITLE, ad.imaAd.title)
adPayload.putInt(PROP_AD_DURATION, (1e3 * ad.imaAd.duration).toInt())
adPayload.putDouble(PROP_AD_DURATION, ad.imaAd.duration)
adPayload.putDouble(PROP_AD_WIDTH, ad.imaAd.vastMediaWidth.toDouble())
adPayload.putDouble(PROP_AD_HEIGHT, ad.imaAd.vastMediaHeight.toDouble())
adPayload.putString(PROP_AD_CONTENT_TYPE, ad.imaAd.contentType)
Expand Down Expand Up @@ -139,12 +139,9 @@ object AdAdapter {
return adbreakPayload
}
adbreakPayload.putString(PROP_ADBREAK_INTEGRATION, adbreak.integration.type)
adbreakPayload.putInt(PROP_ADBREAK_MAXDURATION, (1e3 * adbreak.maxDuration).toInt())
adbreakPayload.putInt(PROP_ADBREAK_TIMEOFFSET, (1e3 * adbreak.timeOffset).toInt())
adbreakPayload.putInt(
PROP_ADBREAK_MAXREMAININGDURATION,
(1e3 * adbreak.maxRemainingDuration).toInt()
)
adbreakPayload.putInt(PROP_ADBREAK_MAXDURATION,adbreak.maxDuration)
adbreakPayload.putInt(PROP_ADBREAK_TIMEOFFSET, adbreak.timeOffset)
adbreakPayload.putDouble(PROP_ADBREAK_MAXREMAININGDURATION, adbreak.maxRemainingDuration)
val adsPayload = Arguments.createArray()
for (ad in adbreak.ads) {
// Some ads in the ad break are possibly not loaded yet.
Expand Down Expand Up @@ -260,21 +257,21 @@ object AdAdapter {

override fun getMaxDuration(): Int {
return if (adBreak.hasKey(PROP_ADBREAK_MAXDURATION))
(1e-3 * adBreak.getInt(PROP_ADBREAK_MAXDURATION)).toInt()
adBreak.getInt(PROP_ADBREAK_MAXDURATION)
else
INVALID_INT
}

override fun getMaxRemainingDuration(): Double {
return if (adBreak.hasKey(PROP_ADBREAK_MAXREMAININGDURATION))
1e-3 * adBreak.getDouble(PROP_ADBREAK_MAXREMAININGDURATION)
adBreak.getDouble(PROP_ADBREAK_MAXREMAININGDURATION)
else
INVALID_DOUBLE
}

override fun getTimeOffset(): Int {
return if (adBreak.hasKey(PROP_ADBREAK_TIMEOFFSET))
(1e-3 * adBreak.getInt(PROP_ADBREAK_TIMEOFFSET)).toInt()
adBreak.getInt(PROP_ADBREAK_TIMEOFFSET)
else
0
}
Expand All @@ -289,13 +286,13 @@ object AdAdapter {
return object: com.google.ads.interactivemedia.v3.api.Ad {
override fun getDuration(): Double {
return ad?.run {
if (hasKey(PROP_AD_DURATION)) 1e-3 * getDouble(PROP_AD_DURATION) else INVALID_DOUBLE
if (hasKey(PROP_AD_DURATION)) getDouble(PROP_AD_DURATION) else INVALID_DOUBLE
} ?: INVALID_DOUBLE
}

override fun getSkipTimeOffset(): Double {
return ad?.run {
if (hasKey(PROP_AD_SKIPOFFSET)) 1e-3 * getDouble(PROP_AD_SKIPOFFSET) else INVALID_DOUBLE
if (hasKey(PROP_AD_SKIPOFFSET)) getDouble(PROP_AD_SKIPOFFSET) else INVALID_DOUBLE
} ?: INVALID_DOUBLE
}

Expand Down
6 changes: 5 additions & 1 deletion example/ios/ReactNativeTHEOplayer/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#import <THEOplayerSDK/THEOplayerSDK-Swift.h>
#endif

#if !TARGET_OS_TV
#import <GoogleCast/GoogleCast.h>
#endif

@implementation AppDelegate

Expand All @@ -32,12 +34,14 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];


#if !TARGET_OS_TV
NSString *receiverAppID = @"CC1AD845"; // default receiver
GCKDiscoveryCriteria *criteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:receiverAppID];
GCKCastOptions* options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:criteria];
options.startDiscoveryAfterFirstTapOnCastButton = false;
[GCKCastContext setSharedInstanceWithOptions:options];
#endif

return YES;
}
Expand Down
2 changes: 2 additions & 0 deletions ios/THEOplayerRCTTypeUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ class THEOplayerRCTTypeUtils {

class func adIntegrationKind(_ integration: String) -> AdIntegrationKind {
switch integration {
#if os(iOS)
case "theo":
return AdIntegrationKind.theo
case "freewheel":
return AdIntegrationKind.freewheel
#endif
case "google-ima":
return AdIntegrationKind.google_ima
case "google-dai":
Expand Down
16 changes: 8 additions & 8 deletions ios/ads/THEOplayerRCTAdAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class THEOplayerRCTAdAdapter {
adData[PROP_AD_RESOURCE_URI] = resourceURI
}
if let skipOffset = ad.skipOffset {
adData[PROP_AD_SKIP_OFFSET] = (skipOffset == -1) ? skipOffset : skipOffset * 1000 // sec -> msec
adData[PROP_AD_SKIP_OFFSET] = (skipOffset == -1) ? skipOffset : skipOffset
}
if processAdBreak,
let adBreak = ad.adBreak {
Expand All @@ -67,7 +67,7 @@ class THEOplayerRCTAdAdapter {
// Add additional properties for Linear Ads
if let linearAd = ad as? LinearAd {
if let adDuration = linearAd.duration {
adData[PROP_AD_DURATION] = adDuration * 1000 // sec -> msec
adData[PROP_AD_DURATION] = adDuration
}
}

Expand Down Expand Up @@ -170,9 +170,9 @@ class THEOplayerRCTAdAdapter {

class func fromAdBreak(adBreak: AdBreak) -> [String:Any] {
var adBreakData: [String:Any] = [:]
adBreakData[PROP_ADBREAK_MAX_DURATION] = adBreak.maxDuration * 1000 // sec -> msec
adBreakData[PROP_ADBREAK_TIME_OFFSET] = adBreak.timeOffset * 1000 // sec -> msec
adBreakData[PROP_ADBREAK_MAX_REMAINING_DURATION] = adBreak.maxRemainingDuration * 1000.0 // sec -> msec
adBreakData[PROP_ADBREAK_MAX_DURATION] = adBreak.maxDuration
adBreakData[PROP_ADBREAK_TIME_OFFSET] = adBreak.timeOffset
adBreakData[PROP_ADBREAK_MAX_REMAINING_DURATION] = adBreak.maxRemainingDuration
// process adds when adbreak contains them
if !adBreak.ads.isEmpty {
var adList: [[String:Any]] = []
Expand Down Expand Up @@ -203,9 +203,9 @@ class THEOplayerRCTAdAdapter {
}

return NativeAdBreak(ads: ads,
maxDuration: lround(Double((adBreakData[PROP_ADBREAK_MAX_DURATION] as? Int) ?? 0) * 0.001), // msec -> sec,
maxRemainingDuration: Double((adBreakData[PROP_ADBREAK_MAX_REMAINING_DURATION] as? Int) ?? 0) * 0.001, // msec -> sec,
timeOffset: lround(Double((adBreakData[PROP_ADBREAK_TIME_OFFSET] as? Int) ?? 0) * 0.001)) // msec -> sec,
maxDuration: lround((adBreakData[PROP_ADBREAK_MAX_DURATION] as? Double) ?? 0),
maxRemainingDuration: (adBreakData[PROP_ADBREAK_MAX_REMAINING_DURATION] as? Double) ?? 0,
timeOffset: lround((adBreakData[PROP_ADBREAK_TIME_OFFSET] as? Double) ?? 0))
}

class private func fromCompanionAds(companionAds: [CompanionAd?]) -> [[String:Any]] {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-theoplayer",
"version": "3.3.1",
"version": "3.3.2",
"description": "A THEOplayer video component for react-native.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
1 change: 1 addition & 0 deletions src/api/track/TextTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum TextTrackType {
webvtt = 'webvtt',
daterange = 'daterange',
eventstream = 'eventstream',
emsg = 'emsg',
}

export enum TextTrackKind {
Expand Down
Loading