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

Feature/report play head time #54

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
- New `TimeChanged` callback for reporting Playhead to conviva playback metric. Calculates Live and Vod playback for report.

### Changed
- Updated conviva-core to 4.0.35

## 2.2.0 - 2023-07-18
### Added
- New `release(Boolean releaseConvivaSdk)` function allows for registering a new `ConvivaAnalyticsIntegration` to a
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ allprojects {
And these lines to your main project
```
dependencies {
implementation 'com.conviva.sdk:conviva-core-sdk:4.0.20' // <-- conviva sdk
implementation 'com.conviva.sdk:conviva-core-sdk:4.0.35' // <-- conviva sdk
implementation 'com.bitmovin.analytics:conviva:2.2.0'
}
```
Expand Down
2 changes: 1 addition & 1 deletion conviva/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
testImplementation testingDependencies.junit
androidTestImplementation testingDependencies.androidx_junit
androidTestImplementation testingDependencies.androidx_espresso_core
api 'com.conviva.sdk:conviva-core-sdk:4.0.20'
api 'com.conviva.sdk:conviva-core-sdk:4.0.35'
implementation bitmovinPlayerDependencies.bitmovinPlayer
implementation 'org.apache.commons:commons-text:1.7'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ private void attachBitmovinEventListeners() {
bitmovinPlayer.on(PlayerEvent.AdFinished.class, onAdFinishedListener);
bitmovinPlayer.on(PlayerEvent.AdSkipped.class, onAdSkippedListener);
bitmovinPlayer.on(PlayerEvent.AdError.class, onAdErrorListener);
bitmovinPlayer.on(PlayerEvent.TimeChanged.class, onTimeChangedListener);
dweinber marked this conversation as resolved.
Show resolved Hide resolved

bitmovinPlayer.on(PlayerEvent.VideoPlaybackQualityChanged.class, onVideoPlaybackQualityChangedListener);
}
Expand Down Expand Up @@ -407,6 +408,7 @@ private void detachBitmovinEventListeners() {
bitmovinPlayer.off(PlayerEvent.AdFinished.class, onAdFinishedListener);
bitmovinPlayer.off(PlayerEvent.AdSkipped.class, onAdSkippedListener);
bitmovinPlayer.off(PlayerEvent.AdError.class, onAdErrorListener);
bitmovinPlayer.off(PlayerEvent.TimeChanged.class, onTimeChangedListener);

bitmovinPlayer.off(PlayerEvent.VideoPlaybackQualityChanged.class,
onVideoPlaybackQualityChangedListener);
Expand Down Expand Up @@ -680,5 +682,28 @@ public void onEvent(PlayerEvent.VideoPlaybackQualityChanged videoPlaybackQuality
updateSession();
}
};

private EventListener<PlayerEvent.TimeChanged> onTimeChangedListener = new EventListener<PlayerEvent.TimeChanged>() {
@Override
public void onEvent(PlayerEvent.TimeChanged timeChangedEvent) {
if (bitmovinPlayer.isLive()) {
double playerTimeshiftMax = bitmovinPlayer.getMaxTimeShift();
double playerTimeshift = bitmovinPlayer.getTimeShift();
long playerDurationMs = -(Math.round(playerTimeshiftMax * 1000));
long playerPositionMs = playerDurationMs - -(Math.round(playerTimeshift * 1000));
reportPlayHeadTime(playerPositionMs);
} else {
double currentTime = bitmovinPlayer.getCurrentTime();
long playerDurationMs = (long) (currentTime * 1000);
reportPlayHeadTime(playerDurationMs);
}
}
};

private void reportPlayHeadTime(long playerDurationMs) {
if (isSessionActive) {
convivaVideoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME, playerDurationMs);
}
}
// endregion
}