Skip to content

Commit

Permalink
feat: support fetching AbsoluteTime in yospace integration
Browse files Browse the repository at this point in the history
  • Loading branch information
martinstark committed Mar 21, 2024
1 parent bce09ec commit 037ad18
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 45 deletions.
28 changes: 21 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed

- added mode argument to getCurrentTime to enable fetching absolute time
- added mode argument to getDuration to enable fetching absolute duration

## 2.3.1 - 2024-02-14

### Removed
Expand Down Expand Up @@ -47,7 +52,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `shownToUser` method to Companion Ads, which should be fired when the ad is shown to the user
- `hiddenFromUser` method to Companion Ads, which should be fired when the ad is hidden from the user
- `UNKNOWN_FORMAT` error (code `1011`)
- `YospaceConfiguration.debugYospaceSdk` to enable debug logs of the Yospace SDK without enabling logs for the `BitmovinYospacePlayer` (helpful for Yospace validation)
- `YospaceConfiguration.debugYospaceSdk` to enable debug logs of the Yospace SDK without enabling logs for
the `BitmovinYospacePlayer` (helpful for Yospace validation)
- Support for tracking muted/unmuted changes

### Changed
Expand Down Expand Up @@ -121,7 +127,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Use standalone Bitmovin Analytics Adapter for flexibility. And move initialization to `load()` to dynamically attach to the correct player based on source.
- Use standalone Bitmovin Analytics Adapter for flexibility. And move initialization to `load()` to dynamically attach
to the correct player based on source.
- Note: This change required updating to TypeScript version 3.

## 1.2.20-2 - 2021-07-28
Expand All @@ -145,13 +152,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Remove the [arrayAccessForm](https://github.com/x2js/x2js/blob/development/x2js.d.ts#L116), config option from `X2JS` initialization for parsing VAST Extensions. This was causing unpredictable arrays for the `Extension.CreativeParameters` property. Without the option, it consistently returns an object when there is only one `CreativeParameter` property.
- Remove the [arrayAccessForm](https://github.com/x2js/x2js/blob/development/x2js.d.ts#L116), config option from `X2JS`
initialization for parsing VAST Extensions. This was causing unpredictable arrays for
the `Extension.CreativeParameters` property. Without the option, it consistently returns an object when there is only
one `CreativeParameter` property.

## 1.2.19 - 2021-01-20

### Fixed

- Added a temporary fix for a bug on Safari mobile that results in duplicate ad events from Yospace, as a result of incorrect Position updates reported to the YS SDK.
- Added a temporary fix for a bug on Safari mobile that results in duplicate ad events from Yospace, as a result of
incorrect Position updates reported to the YS SDK.

### Added

Expand Down Expand Up @@ -259,7 +270,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- When the `disableServiceWorker` flag is set to true, don't make calls to `navigator.serviceWorker.getRegistrations()`. This was causing issues on Tizen devices.
- When the `disableServiceWorker` flag is set to true, don't make calls to `navigator.serviceWorker.getRegistrations()`.
This was causing issues on Tizen devices.

## 1.2.5 - 2020-04-15

Expand All @@ -283,7 +295,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Fire `TruexAdFree` in the `adBreakFinished` listener instead of `adFinished`, as the stream isn't fully reloaded for seeking after `adFinished`
- Fire `TruexAdFree` in the `adBreakFinished` listener instead of `adFinished`, as the stream isn't fully reloaded for
seeking after `adFinished`
- Update Bitmovin Web SDK to 08.31.0
- `player.isLive()` returns false when in a VPAID, so store `isLiveStream` in a variable upon playing the stream.

Expand All @@ -297,7 +310,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- Always fire the `TrueXAdFree` event
- Reduce the replaceContentDuration by 2 seconds in order to allow the player to properly skip the VPAID / TrueX ad if needed
- Reduce the replaceContentDuration by 2 seconds in order to allow the player to properly skip the VPAID / TrueX ad if
needed
- Updated Bitmovin Web SDK to 8.30.0
- Fire a new `TruexAdBreakFinished` event

Expand Down
17 changes: 5 additions & 12 deletions src/ts/BitmovinYospacePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
SupportedTechnologyMode,
Technology,
Thumbnail,
TimeMode,
TimeRange,
VideoQuality,
ViewMode,
Expand Down Expand Up @@ -335,16 +336,8 @@ export class BitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
return this.player.getContainer();
}

getCurrentTime(): number {
return this.player.getCurrentTime();
}

getCurrentAdBreakDuration(): number {
return this.player.getCurrentAdBreakDuration();
}

getCurrentTimeWithAds(): number {
return this.player.getCurrentTimeWithAds();
getCurrentTime(mode?: TimeMode): number {
return this.player.getCurrentTime(mode);
}

getDownloadedAudioData(): DownloadedAudioData {
Expand All @@ -359,8 +352,8 @@ export class BitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
return this.player.getDroppedVideoFrames();
}

getDuration(): number {
return this.player.getDuration();
getDuration(mode?: TimeMode): number {
return this.player.getDuration(mode);
}

get adaptation(): AdaptationAPI {
Expand Down
7 changes: 3 additions & 4 deletions src/ts/BitmovinYospacePlayerAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
PlayerExports,
SourceConfig,
} from 'bitmovin-player';
import { TimeMode } from 'bitmovin-player/modules/bitmovinplayer-core';

// Enums

Expand Down Expand Up @@ -49,11 +50,9 @@ export interface BitmovinYospacePlayerAPI extends PlayerAPI {

getCurrentPlayerType(): YospacePlayerType;

getCurrentAdBreakDuration(): number;
getCurrentTime(mode?: TimeMode): number;

getCurrentTimeWithAds(): number;

getDurationWithAds(): number;
getDuration(mode?: TimeMode): number;

forceSeek(time: number, issuer?: string): boolean;
}
Expand Down
33 changes: 11 additions & 22 deletions src/ts/InternalBitmovinYospacePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
SeekEvent,
SourceConfig,
TimeChangedEvent,
TimeMode,
TimeRange,
UserInteractionEvent,
} from 'bitmovin-player/modules/bitmovinplayer-core';
Expand Down Expand Up @@ -406,7 +407,11 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
return this.player.seek(magicSeekTarget, issuer);
}

getCurrentTime(): number {
getCurrentTime(mode?: TimeMode): number {
if (mode === TimeMode.AbsoluteTime) {
return this.player.getCurrentTime();
}

if (this.isAdActive()) {
// return currentTime in AdBreak
const currentAdPosition = this.player.getCurrentTime();
Expand All @@ -416,13 +421,13 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
return this.toMagicTime(this.player.getCurrentTime());
}

getCurrentTimeWithAds(): number {
return this.player.getCurrentTime();
}

getDuration(): number {
getDuration(mode?: TimeMode): number {
if (!this.session) return 0;

if (mode === TimeMode.AbsoluteTime) {
return this.player.getDuration();
}

if (this.isAdActive()) {
return this.getCurrentAdDuration();
}
Expand All @@ -436,18 +441,6 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
);
}

getCurrentAdBreakDuration(): number {
if (this.isAdActive()) {
return this.getAdBreakDuration(this.getCurrentAdBreak());
}

return 0;
}

getDurationWithAds(): number {
return this.player.getDuration();
}

/**
* @deprecated Use {@link PlayerBufferAPI.getLevel} instead.
*/
Expand Down Expand Up @@ -787,10 +780,6 @@ export class InternalBitmovinYospacePlayer implements BitmovinYospacePlayerAPI {
return toSeconds(ad.getDuration());
}

private getAdBreakDuration(adbreak: AdBreak): number {
return toSeconds(adbreak.getDuration());
}

private getAdStartTime(ad: Advert): number {
if (this.isLive()) {
return this.adStartedTimestamp || 0;
Expand Down

0 comments on commit 037ad18

Please sign in to comment.