Skip to content

Commit

Permalink
Fixed NPE in DrmSessionManager and the AnaltyicsCollector (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansenji authored and brianwernick committed Aug 4, 2018
1 parent c5d2b0a commit 295267a
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public ExoMediaPlayer(@NonNull Context context) {

ComponentListener componentListener = new ComponentListener();
RendererProvider rendererProvider = new RendererProvider(context, mainHandler, componentListener, componentListener, componentListener, componentListener);
rendererProvider.setDrmSessionManager(generateDrmSessionManager());
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = generateDrmSessionManager();
rendererProvider.setDrmSessionManager(drmSessionManager);

renderers = rendererProvider.generate();

Expand All @@ -171,6 +172,7 @@ public ExoMediaPlayer(@NonNull Context context) {
player.addListener(this);
analyticsCollector = new AnalyticsCollector.Factory().createAnalyticsCollector(player, Clock.DEFAULT);
player.addListener(analyticsCollector);
setupDamSessionManagerAnalytics(drmSessionManager);
}

@Override
Expand Down Expand Up @@ -766,7 +768,6 @@ protected DrmSessionManager<FrameworkMediaCrypto> generateDrmSessionManager() {
try {
DefaultDrmSessionManager<FrameworkMediaCrypto> sessionManager = new DefaultDrmSessionManager<>(uuid, FrameworkMediaDrm.newInstance(uuid), new DelegatedMediaDrmCallback(), null);
sessionManager.addListener(mainHandler, capabilitiesListener);
sessionManager.addListener(mainHandler, analyticsCollector);

return sessionManager;
} catch (Exception e) {
Expand All @@ -775,6 +776,12 @@ protected DrmSessionManager<FrameworkMediaCrypto> generateDrmSessionManager() {
}
}

protected void setupDamSessionManagerAnalytics(DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
if (drmSessionManager instanceof DefaultDrmSessionManager) {
((DefaultDrmSessionManager)drmSessionManager).addListener(mainHandler, analyticsCollector);
}
}

private void reportPlayerState() {
boolean playWhenReady = player.getPlayWhenReady();
int playbackState = getPlaybackState();
Expand Down

0 comments on commit 295267a

Please sign in to comment.