diff --git a/CHANGELOG.md b/CHANGELOG.md index e9319e429..c0b8adee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/android/src/main/java/com/theoplayer/ads/AdAdapter.kt b/android/src/main/java/com/theoplayer/ads/AdAdapter.kt index df5118405..b953326b0 100644 --- a/android/src/main/java/com/theoplayer/ads/AdAdapter.kt +++ b/android/src/main/java/com/theoplayer/ads/AdAdapter.kt @@ -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) @@ -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. @@ -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 } @@ -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 } diff --git a/example/ios/ReactNativeTHEOplayer/AppDelegate.m b/example/ios/ReactNativeTHEOplayer/AppDelegate.m index e5fcaeb0d..71392b0ec 100644 --- a/example/ios/ReactNativeTHEOplayer/AppDelegate.m +++ b/example/ios/ReactNativeTHEOplayer/AppDelegate.m @@ -8,7 +8,9 @@ #import #endif +#if !TARGET_OS_TV #import +#endif @implementation AppDelegate @@ -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; } diff --git a/ios/THEOplayerRCTTypeUtils.swift b/ios/THEOplayerRCTTypeUtils.swift index fda669ad6..56ba974cc 100644 --- a/ios/THEOplayerRCTTypeUtils.swift +++ b/ios/THEOplayerRCTTypeUtils.swift @@ -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": diff --git a/ios/ads/THEOplayerRCTAdAdapter.swift b/ios/ads/THEOplayerRCTAdAdapter.swift index 50def7014..052ccbf1e 100644 --- a/ios/ads/THEOplayerRCTAdAdapter.swift +++ b/ios/ads/THEOplayerRCTAdAdapter.swift @@ -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 { @@ -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 } } @@ -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]] = [] @@ -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]] { diff --git a/package-lock.json b/package-lock.json index cb7dbb757..4b3d93fea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-native-theoplayer", - "version": "3.3.1", + "version": "3.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "react-native-theoplayer", - "version": "3.3.1", + "version": "3.3.2", "license": "SEE LICENSE AT https://www.theoplayer.com/terms", "dependencies": { "buffer": "^6.0.3" diff --git a/package.json b/package.json index e2f306557..2e713fb52 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/api/track/TextTrack.ts b/src/api/track/TextTrack.ts index 301cf7f15..34f96d8ea 100644 --- a/src/api/track/TextTrack.ts +++ b/src/api/track/TextTrack.ts @@ -9,6 +9,7 @@ export enum TextTrackType { webvtt = 'webvtt', daterange = 'daterange', eventstream = 'eventstream', + emsg = 'emsg', } export enum TextTrackKind {