Skip to content

Commit

Permalink
Merge branch 'feature/introduce-player-adapter' into late-player-init…
Browse files Browse the repository at this point in the history
…ialization

# Conflicts:
#	conviva/src/main/java/com/bitmovin/analytics/conviva/ConvivaAnalyticsIntegration.java
#	conviva/src/main/java/com/bitmovin/analytics/conviva/DefaultPlayerAdapter.java
#	conviva/src/main/java/com/bitmovin/analytics/conviva/ssai/DefaultPlaybackInfoProvider.java
#	conviva/src/main/java/com/bitmovin/analytics/conviva/ssai/DefaultPlayerAdapter.java
#	conviva/src/main/java/com/bitmovin/analytics/conviva/ssai/DefaultSsaiApi.java
#	conviva/src/test/kotlin/com/bitmovin/analytics/conviva/ssai/DefaultSsaiApiTest.kt
  • Loading branch information
stonko1994 committed Aug 26, 2024
2 parents 04d22d2 + efc76ad commit 2d8227d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bitmovin.analytics.conviva.ssai.DefaultPlayerAdapter;
import com.bitmovin.analytics.conviva.ssai.DefaultSsaiApi;
import com.bitmovin.analytics.conviva.ssai.PlayerAdapter;

import com.bitmovin.analytics.conviva.ssai.DefaultSsaiApi;
import com.bitmovin.analytics.conviva.ssai.SsaiApi;
import com.bitmovin.player.api.Player;
import com.bitmovin.player.api.advertising.Ad;
Expand Down Expand Up @@ -50,7 +50,6 @@ public class ConvivaAnalyticsIntegration {
@Nullable
private PlayerAdapter playerAdapter;

@Nullable
private MetadataOverrides metadataOverrides;
@NonNull
private final DefaultSsaiApi ssai;
Expand Down Expand Up @@ -125,7 +124,6 @@ public ConvivaAnalyticsIntegration(Player player,
@Nullable ConvivaAdAnalytics adAnalytics,
@Nullable DefaultSsaiApi ssai
) {

Map<String, Object> settings = new HashMap<>();
if (config.getGatewayUrl() != null || config.isDebugLoggingEnabled()) {
if (config.getGatewayUrl() != null) {
Expand Down Expand Up @@ -430,7 +428,7 @@ private void buildDynamicContentMetadata(PlayerAdapter playerAdapter) {
contentMetadataBuilder.setStreamType(ConvivaSdkConstants.StreamType.LIVE);
} else {
contentMetadataBuilder.setStreamType(ConvivaSdkConstants.StreamType.VOD);
contentMetadataBuilder.setDuration(((int) playerAdapter.getDuration()));
contentMetadataBuilder.setDuration((int) playerAdapter.getDuration());
}

contentMetadataBuilder.setStreamUrl(playerAdapter.getStreamUrl());
Expand Down Expand Up @@ -875,4 +873,4 @@ public void attachPlayer(@NonNull Player player) {
ssai.setPlayerAdapter(playerAdapter);
updateSession();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bitmovin.analytics.conviva.ssai;
package com.bitmovin.analytics.conviva;

import com.bitmovin.analytics.conviva.helper.WithEventEmitter;
import com.bitmovin.player.api.Player;
import com.bitmovin.player.api.media.video.quality.VideoQuality;
import com.conviva.sdk.ConvivaSdkConstants;
Expand Down Expand Up @@ -93,7 +94,6 @@ public long getPlayHeadTimeMillis() {
double playerTimeShift = player.getTimeShift();
long playerDurationMs = -(Math.round(playerTimeShiftMax * 1000));
return playerDurationMs - -(Math.round(playerTimeShift * 1000));

} else {
double currentTime = player.getCurrentTime();
return (long) (currentTime * 1000);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.bitmovin.analytics.conviva;

import com.bitmovin.analytics.conviva.helper.WithEventEmitter;
import com.conviva.sdk.ConvivaSdkConstants;

import java.util.HashMap;

public interface PlayerAdapter {
ConvivaSdkConstants.PlayerState getPlayerState();

HashMap<String, Object[]> getPlaybackVideoData();

boolean isAd();

String getStreamTitle();

String getStreamType();

String getStreamUrl();

long getPlayHeadTimeMillis();

boolean isLive();

double getDuration();

void withEventEmitter(WithEventEmitter withEventEmitter);

boolean isPaused();

boolean isPlaying();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.bitmovin.analytics.conviva.helper;

import com.bitmovin.player.api.event.Event;
import com.bitmovin.player.api.event.JavaEventEmitter;

public interface WithEventEmitter {
void call(JavaEventEmitter<Event> player);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import androidx.annotation.Nullable;

import com.bitmovin.analytics.conviva.ConvivaAnalyticsIntegration;
import com.bitmovin.analytics.conviva.PlayerAdapter;
import com.conviva.sdk.ConvivaAdAnalytics;
import com.conviva.sdk.ConvivaSdkConstants;
import com.conviva.sdk.ConvivaVideoAnalytics;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bitmovin.analytics.conviva.ssai

import android.util.Log
import com.bitmovin.analytics.conviva.PlayerAdapter
import com.conviva.sdk.ConvivaAdAnalytics
import com.conviva.sdk.ConvivaSdkConstants
import com.conviva.sdk.ConvivaVideoAnalytics
Expand Down Expand Up @@ -52,8 +53,8 @@ class DefaultSsaiApiTest {
}

ssaiApi = DefaultSsaiApi(
videoAnalytics,
adAnalytics,
videoAnalytics,
adAnalytics,
)
ssaiApi.setPlayerAdapter(playerAdapter)
}
Expand Down

0 comments on commit 2d8227d

Please sign in to comment.