I'm trying to get the total join time in before a video starts using the Exoplayer Demo App , but the app just crashes when I launch the app with the code for this.
I've initiated the playback stats listener as follows in PlayerActivity.js
protected PlaybackStatsListener playerStatsListener = new PlaybackStatsListener(true, null);
Following that, I add that to my player using addAnalyticsListener
player.addAnalyticsListener(playerStatsListener)
Within the onCreate method , I try to retrieve the totalJoinTimeMs using this code:
long totalValidJoinTimeMs = playerStatsListener.getPlaybackStats().getTotalJoinTimeMs();
However, the app just crashes when I have included the above line of code.
Are there code examples of how this should be done?
You can pass a callback to PlaybackStatsListener
to be called when the PlaybackStats
is ready. You can use the following snippet to read analytics stats from exoplayer:
player.addAnalyticsListener(new PlaybackStatsListener(true, new PlaybackStatsListener.Callback() {
@Override
public void onPlaybackStatsReady(AnalyticsListener.EventTime eventTime, PlaybackStats playbackStats) {
// read PlaybackStats fields or call methods here
playbackStats.getTotalJoinTimeMs();
...
}
}));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.