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

Extract functionality to prepare for SSAI tracking #69

Merged
merged 2 commits into from
Jul 2, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void setUpAdAnalyticsCallback() {
convivaAdAnalytics.setCallback(new ConvivaExperienceAnalytics.ICallback() {
@Override
public void update() {
if (bitmovinPlayer.isAd()) {
if (isAdActive()) {
convivaAdAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME, ((long) (bitmovinPlayer.getCurrentTime() * 1000)));
}
}
Expand All @@ -115,6 +115,10 @@ public void update(String s) {
});
}

private boolean isAdActive() {
return bitmovinPlayer.isAd();
}

// region public methods
public void sendCustomApplicationEvent(String name) {
sendCustomApplicationEvent(name, new HashMap<>());
Expand Down Expand Up @@ -446,7 +450,7 @@ private void detachBitmovinEventListeners() {
private synchronized void transitionState(ConvivaSdkConstants.PlayerState state) {
Log.d(TAG, "Transitioning to :" + state.name());
convivaVideoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.PLAYER_STATE, state);
if (bitmovinPlayer.isAd()) {
if (isAdActive()) {
Log.d(TAG, "Transitioning ad state to: " + state.name());
convivaAdAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.PLAYER_STATE, state);
}
Expand All @@ -468,22 +472,24 @@ private synchronized void transitionState(ConvivaSdkConstants.PlayerState state)
@Override
public void onEvent(PlayerEvent.Error event) {
Log.d(TAG, "[Player Event] Error");
String message = String.format("%s - %s", event.getCode(), event.getMessage());
convivaVideoAnalytics.reportPlaybackError(message, ConvivaSdkConstants.ErrorSeverity.FATAL);
internalEndSession();
handleError(String.format("%s - %s", event.getCode(), event.getMessage()));
}
};

private final EventListener<SourceEvent.Error> onSourceErrorListener = new EventListener<SourceEvent.Error>() {
@Override
public void onEvent(SourceEvent.Error event) {
Log.d(TAG, "[Source Event] Error");
String message = String.format("%s - %s", event.getCode(), event.getMessage());
convivaVideoAnalytics.reportPlaybackError(message, ConvivaSdkConstants.ErrorSeverity.FATAL);
internalEndSession();
handleError(String.format("%s - %s", event.getCode(), event.getMessage()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to make the message creation also reusable? i.e. wrap or move the string format stuff also into the handleError function?

}
};

private void handleError(String message) {
ConvivaSdkConstants.ErrorSeverity severity = ConvivaSdkConstants.ErrorSeverity.FATAL;
convivaVideoAnalytics.reportPlaybackError(message, severity);
internalEndSession();
}

private final EventListener<PlayerEvent.Warning> onPlayerWarningListener = new EventListener<PlayerEvent.Warning>() {
@Override
public void onEvent(PlayerEvent.Warning warningEvent) {
Expand Down