diff --git a/.changeset/khaki-planes-end.md b/.changeset/khaki-planes-end.md new file mode 100644 index 00000000..159e7e8f --- /dev/null +++ b/.changeset/khaki-planes-end.md @@ -0,0 +1,5 @@ +--- +"@theoplayer/conviva-connector-web": patch +--- + +Fixed an issue where the stream type, either `VOD` or `Live`, would sometimes be set with a wrong value for live streams. diff --git a/conviva/src/integration/ConvivaHandler.ts b/conviva/src/integration/ConvivaHandler.ts index d2c474e0..c5dcfd2b 100644 --- a/conviva/src/integration/ConvivaHandler.ts +++ b/conviva/src/integration/ConvivaHandler.ts @@ -243,18 +243,19 @@ export class ConvivaHandler { private reportMetadata() { const src = this.player.src ?? ''; - const streamType = this.player.duration === Infinity ? Constants.StreamType.LIVE : Constants.StreamType.VOD; const assetName = this.customMetadata[Constants.ASSET_NAME] ?? this.convivaMetadata[Constants.ASSET_NAME] ?? this.currentSource?.metadata?.title ?? 'NA'; const playerName = this.customMetadata[Constants.PLAYER_NAME] ?? 'THEOplayer'; - const metadata = { + const hasDuration = !Number.isNaN(this.player.duration); + const isLive = Number.isFinite(this.player.duration) ? Constants.StreamType.VOD : Constants.StreamType.LIVE; + const metadata: ConvivaMetadata = { [Constants.STREAM_URL]: src, - [Constants.IS_LIVE]: streamType, [Constants.ASSET_NAME]: assetName, - [Constants.PLAYER_NAME]: playerName + [Constants.PLAYER_NAME]: playerName, + ...(!hasDuration ? {} : { [Constants.IS_LIVE]: isLive }) }; this.setContentInfo(metadata); }