Skip to content

Commit

Permalink
Merge pull request #52 from kvolkers/feature/reuse-released-integration
Browse files Browse the repository at this point in the history
Allow for registering a new ConvivaAnalyticsIntegration to a reused Player
  • Loading branch information
dweinber authored Jul 18, 2023
2 parents 2cd2a8d + e5631db commit 023543c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Updated Kotlin to 1.7.0
- Updated compileSdkVersion to 33

### Added
- New `release(Boolean releaseConvivaSdk)` function allows for registering a new `ConvivaAnalyticsIntegration` to a
reused `Player`, when called with `releaseConvivaSdk = false` on the previous instance.

## [2.1.4]
### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,15 @@ public void updateContentMetadata(MetadataOverrides metadataOverrides) {
}

public void release() {
release(true);
}

public void release(Boolean releaseConvivaSdk) {
convivaVideoAnalytics.release();
ConvivaAnalytics.release();
detachBitmovinEventListeners();
if (releaseConvivaSdk) {
ConvivaAnalytics.release();
}
}

/**
Expand Down Expand Up @@ -369,6 +376,42 @@ private void attachBitmovinEventListeners() {
bitmovinPlayer.on(PlayerEvent.VideoPlaybackQualityChanged.class, onVideoPlaybackQualityChangedListener);
}

private void detachBitmovinEventListeners() {
bitmovinPlayer.off(SourceEvent.Unloaded.class, onSourceUnloadedListener);
bitmovinPlayer.off(PlayerEvent.Error.class, onPlayerErrorListener);
bitmovinPlayer.off(SourceEvent.Error.class, onSourceErrorListener);
bitmovinPlayer.off(PlayerEvent.Warning.class, onPlayerWarningListener);
bitmovinPlayer.off(SourceEvent.Warning.class, onSourceWarningListener);

bitmovinPlayer.off(PlayerEvent.Muted.class, onMutedListener);
bitmovinPlayer.off(PlayerEvent.Unmuted.class, onUnmutedListener);

// Playback state events
bitmovinPlayer.off(PlayerEvent.Play.class, onPlayListener);
bitmovinPlayer.off(PlayerEvent.Playing.class, onPlayingListener);
bitmovinPlayer.off(PlayerEvent.Paused.class, onPausedListener);
bitmovinPlayer.off(PlayerEvent.StallEnded.class, onStallEndedListener);
bitmovinPlayer.off(PlayerEvent.StallStarted.class, onStallStartedListener);
bitmovinPlayer.off(PlayerEvent.PlaybackFinished.class, onPlaybackFinishedListener);

// Seek events
bitmovinPlayer.off(PlayerEvent.Seeked.class, onSeekedListener);
bitmovinPlayer.off(PlayerEvent.Seek.class, onSeekListener);

// Timeshift events
bitmovinPlayer.off(PlayerEvent.TimeShift.class, onTimeShiftListener);
bitmovinPlayer.off(PlayerEvent.TimeShifted.class, onTimeShiftedListener);

// Ad events
bitmovinPlayer.off(PlayerEvent.AdStarted.class, onAdStartedListener);
bitmovinPlayer.off(PlayerEvent.AdFinished.class, onAdFinishedListener);
bitmovinPlayer.off(PlayerEvent.AdSkipped.class, onAdSkippedListener);
bitmovinPlayer.off(PlayerEvent.AdError.class, onAdErrorListener);

bitmovinPlayer.off(PlayerEvent.VideoPlaybackQualityChanged.class,
onVideoPlaybackQualityChangedListener);
}

private synchronized void transitionState(ConvivaSdkConstants.PlayerState state) {
Log.d(TAG, "Transitioning to :" + state.name());
convivaVideoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.PLAYER_STATE, state);
Expand Down

0 comments on commit 023543c

Please sign in to comment.