Skip to content

Commit 702df31

Browse files
committed
Merge branch 'adobe-edge/alloy' of github.com:THEOplayer/react-native-connectors into adobe-edge/alloy
2 parents e7d9733 + 05e4aa4 commit 702df31

4 files changed

Lines changed: 55 additions & 16 deletions

File tree

adobe-edge/README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const config = {
3636
datastreamId: 'abcde123-abcd-1234-abcd-abcde1234567',
3737
orgId: 'ADB3LETTERSANDNUMBERS@AdobeOrg',
3838
edgeBasePath: 'ee',
39+
edgeDomain: 'my.domain.com',
3940
debugEnabled: true,
4041
},
4142
mobile: {
@@ -58,7 +59,7 @@ const customIdentityMap = {
5859
}
5960

6061
const App = () => {
61-
const [adobe, initAdobe] = useAdobe(config, customIdentityMap);
62+
const [adobe, initAdobe] = useAdobe(config, /* optional */ customIdentityMap);
6263

6364
const onPlayerReady = (player: THEOplayer) => {
6465
// Initialize Adobe connector
@@ -87,3 +88,39 @@ const onUpdateMetadata = () => {
8788
adobe.current?.updateMetadata(metadata);
8889
};
8990
```
91+
92+
### Setting an custom identity map
93+
94+
Besides passing a custom identity map during initialization, you can also set or update the identity map at any time:
95+
96+
```typescript
97+
import {AdobeIdentityMap} from "@theoplayer/react-native-analytics-adobe-edge";
98+
99+
const onUpdateIdentityMap = () => {
100+
const identityMap: AdobeIdentityMap = {
101+
CUSTOMER_ID: [
102+
{
103+
id: 'customer-12345',
104+
authenticatedState: 'authenticated',
105+
primary: true,
106+
},
107+
],
108+
};
109+
adobe.current?.setIdentityMap(identityMap);
110+
};
111+
```
112+
113+
### Starting a new session during a live stream
114+
115+
By default, the connector will start a new session when a new asset is loaded. However, during live streams, you might
116+
want to start a new session
117+
periodically when a new program starts. You can do this by calling `stopAndStartNewSession` with the new program's
118+
metadata:
119+
120+
```typescript
121+
const onNewProgram = () => {
122+
adobe.current?.stopAndStartNewSession({
123+
'friendlyName': 'Evening News',
124+
});
125+
};
126+
```

adobe-edge/android/src/main/java/com/theoplayer/reactnative/adobe/edge/AdobeEdgeHandler.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,20 +393,20 @@ class AdobeEdgeHandler(
393393
logDebug("onAdBreakBegin")
394394
isPlayingAd = true
395395
val currentAdBreakTimeOffset = event.adBreak.timeOffset
396-
val index = when {
397-
currentAdBreakTimeOffset == 0 -> 0
398-
currentAdBreakTimeOffset < 0 -> -1
396+
// The pod position should start at 1.
397+
val position = when {
398+
currentAdBreakTimeOffset <= 0 -> 1
399399
else -> adBreakPodIndex + 1
400400
}
401401
queueOrSendEvent(
402402
EventType.AD_BREAK_START, Media.createAdBreakObject(
403403
PROP_NA,
404-
index,
404+
position,
405405
currentAdBreakTimeOffset
406406
)
407407
)
408408

409-
if (index > adBreakPodIndex) {
409+
if (position > adBreakPodIndex) {
410410
adBreakPodIndex++
411411
}
412412
}

adobe-edge/android/src/main/java/com/theoplayer/reactnative/adobe/edge/Utils.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.adobe.marketing.mobile.edge.identity.AuthenticatedState
44
import com.adobe.marketing.mobile.edge.identity.IdentityItem
55
import com.facebook.react.bridge.ReadableMap
66
import com.adobe.marketing.mobile.edge.identity.IdentityMap
7+
import java.util.Calendar
78

89
fun sanitiseContentLength(mediaLength: Double?): Int {
910
return if (mediaLength == Double.POSITIVE_INFINITY) { 86400 } else mediaLength?.toInt() ?: 0
@@ -15,8 +16,10 @@ fun sanitisePlayhead(playhead: Double?, mediaLength: Double?): Int {
1516
}
1617
if (mediaLength == Double.POSITIVE_INFINITY) {
1718
// If content is live, the playhead must be the current second of the day.
18-
val now = System.currentTimeMillis()
19-
return ((now / 1000) % 86400).toInt()
19+
val calendar = Calendar.getInstance()
20+
return calendar.get(Calendar.SECOND) +
21+
60 * (calendar.get(Calendar.MINUTE) +
22+
60 * calendar.get(Calendar.HOUR_OF_DAY))
2023
}
2124
return playhead.toInt()
2225
}

adobe-edge/src/internal/web/AdobeEdgeHandler.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,15 @@ class AdobeEdgeHandler {
326326
private handleAdBreakBegin = (event: AdBreakEvent<'adbreakbegin'>) => {
327327
this.logDebug('onAdBreakBegin');
328328
const currentAdBreakTimeOffset = event.adBreak.timeOffset;
329-
let index: number;
330-
if (currentAdBreakTimeOffset === 0) {
331-
index = 0;
332-
} else if (currentAdBreakTimeOffset < 0) {
333-
index = -1;
329+
let position: number;
330+
// The pod position should start at 1.
331+
if (currentAdBreakTimeOffset <= 0) {
332+
position = 1;
334333
} else {
335-
index = this._adBreakPodIndex + 1;
334+
position = this._adBreakPodIndex + 1;
336335
}
337-
this.queueOrSendEvent(EventType.adBreakStart, this._media?.createAdBreakObject(PROP_NA, index, currentAdBreakTimeOffset));
338-
if (index > this._adBreakPodIndex) {
336+
this.queueOrSendEvent(EventType.adBreakStart, this._media?.createAdBreakObject(PROP_NA, position, currentAdBreakTimeOffset));
337+
if (position > this._adBreakPodIndex) {
339338
this._adBreakPodIndex++;
340339
}
341340
};

0 commit comments

Comments
 (0)