com.google.android.exoplayer2.analytics.AnalyticsListener Java Examples

The following examples show how to use com.google.android.exoplayer2.analytics.AnalyticsListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadCanceled(EventTime eventTime,
                           MediaSourceEventListener.LoadEventInfo loadEventInfo,
                           MediaSourceEventListener.MediaLoadData mediaLoadData) {
    for (AnalyticsListener listener : listeners) {
        listener.onLoadCanceled(eventTime, loadEventInfo, mediaLoadData);
    }
}
 
Example #2
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadCompleted(EventTime eventTime,
                            MediaSourceEventListener.LoadEventInfo loadEventInfo,
                            MediaSourceEventListener.MediaLoadData mediaLoadData) {
    for (AnalyticsListener listener : listeners) {
        listener.onLoadCompleted(eventTime, loadEventInfo, mediaLoadData);
    }
}
 
Example #3
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadStarted(EventTime eventTime,
                          MediaSourceEventListener.LoadEventInfo loadEventInfo,
                          MediaSourceEventListener.MediaLoadData mediaLoadData) {
    for (AnalyticsListener listener : listeners) {
        listener.onLoadStarted(eventTime, loadEventInfo, mediaLoadData);
    }
}
 
Example #4
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onVideoSizeChanged(EventTime eventTime,
                               int width,
                               int height,
                               int unappliedRotationDegrees,
                               float pixelWidthHeightRatio) {
    for (AnalyticsListener listener : listeners) {
        listener.onVideoSizeChanged(eventTime, width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
    }
}
 
Example #5
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadError(EventTime eventTime,
                        MediaSourceEventListener.LoadEventInfo loadEventInfo,
                        MediaSourceEventListener.MediaLoadData mediaLoadData,
                        IOException error,
                        boolean wasCanceled) {
    for (AnalyticsListener listener : listeners) {
        listener.onLoadError(eventTime, loadEventInfo, mediaLoadData, error, wasCanceled);
    }
}
 
Example #6
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onDownstreamFormatChanged(EventTime eventTime,
                                      MediaSourceEventListener.MediaLoadData mediaLoadData) {
    for (AnalyticsListener listener : listeners) {
        listener.onDownstreamFormatChanged(eventTime, mediaLoadData);
    }
}
 
Example #7
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onUpstreamDiscarded(EventTime eventTime,
                                MediaSourceEventListener.MediaLoadData mediaLoadData) {
    for (AnalyticsListener listener : listeners) {
        listener.onUpstreamDiscarded(eventTime, mediaLoadData);
    }
}
 
Example #8
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onDecoderInputFormatChanged(EventTime eventTime,
                                        int trackType,
                                        Format format) {
    for (AnalyticsListener listener : listeners) {
        listener.onDecoderInputFormatChanged(eventTime, trackType, format);
    }
}
 
Example #9
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onDecoderInitialized(EventTime eventTime,
                                 int trackType,
                                 String decoderName,
                                 long initializationDurationMs) {
    for (AnalyticsListener listener : listeners) {
        listener.onDecoderInitialized(eventTime, trackType, decoderName, initializationDurationMs);
    }
}
 
Example #10
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onBandwidthEstimate(EventTime eventTime,
                                int totalLoadTimeMs,
                                long totalBytesLoaded,
                                long bitrateEstimate) {
    for (AnalyticsListener listener : listeners) {
        listener.onBandwidthEstimate(eventTime, totalLoadTimeMs, totalBytesLoaded, bitrateEstimate);
    }
}
 
Example #11
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onMetadata(EventTime eventTime, Metadata metadata) {
    for (AnalyticsListener listener : listeners) {
        listener.onMetadata(eventTime, metadata);
    }
}
 
Example #12
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onMediaPeriodCreated(EventTime eventTime) {
    for (AnalyticsListener listener : listeners) {
        listener.onMediaPeriodCreated(eventTime);
    }
}
 
Example #13
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onMediaPeriodReleased(EventTime eventTime) {
    for (AnalyticsListener listener : listeners) {
        listener.onMediaPeriodReleased(eventTime);
    }
}
 
Example #14
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onReadingStarted(EventTime eventTime) {
    for (AnalyticsListener listener : listeners) {
        listener.onReadingStarted(eventTime);
    }
}
 
Example #15
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onSurfaceSizeChanged(EventTime eventTime, int width, int height) {
    for (AnalyticsListener listener : listeners) {
        listener.onSurfaceSizeChanged(eventTime, width, height);
    }
}
 
Example #16
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onDrmKeysRestored(EventTime eventTime) {
    for (AnalyticsListener listener : listeners) {
        listener.onDrmKeysRestored(eventTime);
    }
}
 
Example #17
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onDecoderEnabled(EventTime eventTime, int trackType, DecoderCounters decoderCounters) {
    for (AnalyticsListener listener : listeners) {
        listener.onDecoderEnabled(eventTime, trackType, decoderCounters);
    }
}
 
Example #18
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onDecoderDisabled(EventTime eventTime, int trackType, DecoderCounters decoderCounters) {
    for (AnalyticsListener listener : listeners) {
        listener.onDecoderDisabled(eventTime, trackType, decoderCounters);
    }
}
 
Example #19
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onAudioSessionId(EventTime eventTime, int audioSessionId) {
    for (AnalyticsListener listener : listeners) {
        listener.onAudioSessionId(eventTime, audioSessionId);
    }
}
 
Example #20
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onAudioUnderrun(EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {
    for (AnalyticsListener listener : listeners) {
        listener.onAudioUnderrun(eventTime, bufferSize, bufferSizeMs, elapsedSinceLastFeedMs);
    }
}
 
Example #21
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onRenderedFirstFrame(EventTime eventTime, Surface surface) {
    for (AnalyticsListener listener : listeners) {
        listener.onRenderedFirstFrame(eventTime, surface);
    }
}
 
Example #22
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onDrmKeysLoaded(EventTime eventTime) {
    for (AnalyticsListener listener : listeners) {
        listener.onDrmKeysLoaded(eventTime);
    }
}
 
Example #23
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onDrmSessionManagerError(EventTime eventTime, Exception error) {
    for (AnalyticsListener listener : listeners) {
        listener.onDrmSessionManagerError(eventTime, error);
    }
}
 
Example #24
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onPlayerError(EventTime eventTime, ExoPlaybackException error) {
    for (AnalyticsListener listener : listeners) {
        listener.onPlayerError(eventTime, error);
    }
}
 
Example #25
Source File: BackgroundAudioPlayer.java    From flutter_exoplayer with MIT License 4 votes vote down vote up
private void initEventListeners() {
    player.addAnalyticsListener(new AnalyticsListener() {
        @Override
        public void onAudioSessionId(EventTime eventTime, int audioSessionId) {
            ref.handleAudioSessionIdChange(backgroundAudioPlayer, audioSessionId);
        }
    });
    player.addListener(new Player.EventListener() {

        @Override
        public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
            ref.handlePlayerIndex(backgroundAudioPlayer);
        }

        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            switch (playbackState) {
            case Player.STATE_BUFFERING: {
                // buffering
                buffering = true;
                ref.handleStateChange(backgroundAudioPlayer, PlayerState.BUFFERING);
                break;
            }
            case Player.STATE_READY: {
                if (completed) {
                    buffering = false;
                    ref.handleStateChange(backgroundAudioPlayer, PlayerState.COMPLETED);
                } else if (buffering) {
                    // playing
                    buffering = false;
                    if (playWhenReady) {
                        playing = true;
                        ref.handlePositionUpdates();
                        ref.handleStateChange(backgroundAudioPlayer, PlayerState.PLAYING);
                    } else {
                        ref.handleStateChange(backgroundAudioPlayer, PlayerState.PAUSED);
                    }
                } else if (playWhenReady) {
                    // resumed
                    playing = true;
                    ref.handlePositionUpdates();
                    ref.handleStateChange(backgroundAudioPlayer, PlayerState.PLAYING);
                } else if (!playWhenReady) {
                    // paused
                    playing = false;
                    ref.handleStateChange(backgroundAudioPlayer, PlayerState.PAUSED);
                }
                break;
            }
            case Player.STATE_ENDED: {
                // completed
                playing = false;
                completed = true;
                player.setPlayWhenReady(false);
                player.seekTo(0, 0);
                break;
            }
            case Player.STATE_IDLE: {
                // stopped
                playing = false;
                stopped = true;
                completed = false;
                buffering = false;
                ref.handleStateChange(backgroundAudioPlayer, PlayerState.STOPPED);
                break;
            }
            // handle of released is in release method!
            }
        }

        @Override
        public void onPlayerError(ExoPlaybackException error) {
            Log.e(TAG, error.getMessage());
        }
    });
}
 
Example #26
Source File: ForegroundAudioPlayer.java    From flutter_exoplayer with MIT License 4 votes vote down vote up
private void initEventListeners() {
    player.addAnalyticsListener(new AnalyticsListener() {
        @Override
        public void onAudioSessionId(EventTime eventTime, int audioSessionId) {
            ref.handleAudioSessionIdChange(foregroundAudioPlayer, audioSessionId);
        }
    });
    player.addListener(new Player.EventListener() {

        @Override
        public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
            if (mediaNotificationManager.isShowing() || !mediaNotificationManager.isInitialized()) {
                if (playerMode == PlayerMode.PLAYLIST) {
                    mediaNotificationManager.makeNotification(audioObjects.get(player.getCurrentWindowIndex()),
                            true);
                } else {
                    mediaNotificationManager.makeNotification(audioObject, true);
                }
            } else {
                mediaNotificationManager.setIsInitialized(false); // the player was stopped.
            }
            ref.handlePlayerIndex(foregroundAudioPlayer);
        }

        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            switch (playbackState) {
            case Player.STATE_BUFFERING: {
                // buffering
                buffering = true;
                ref.handleStateChange(foregroundAudioPlayer, PlayerState.BUFFERING);
                break;
            }
            case Player.STATE_READY: {
                if (completed) {
                    buffering = false;
                    if (mediaNotificationManager.isShowing()) {
                        mediaNotificationManager.makeNotification(false);
                    }
                    ref.handleStateChange(foregroundAudioPlayer, PlayerState.COMPLETED);
                } else if (buffering) {
                    // playing
                    buffering = false;
                    if (playWhenReady) {
                        playing = true;
                        if (mediaNotificationManager.isShowing()) {
                            mediaNotificationManager.makeNotification(true);
                        }
                        ref.handleStateChange(foregroundAudioPlayer, PlayerState.PLAYING);
                        ref.handlePositionUpdates();
                    } else {
                        ref.handleStateChange(foregroundAudioPlayer, PlayerState.PAUSED);
                    }
                } else if (playWhenReady) {
                    // resumed
                    playing = true;
                    if (mediaNotificationManager.isShowing()) {
                        mediaNotificationManager.makeNotification(true);
                    }
                    ref.handlePositionUpdates();
                    ref.handleStateChange(foregroundAudioPlayer, PlayerState.PLAYING);
                } else if (!playWhenReady) {
                    // paused
                    playing = false;
                    if (mediaNotificationManager.isShowing()) {
                        mediaNotificationManager.makeNotification(false);
                    }
                    ref.handleStateChange(foregroundAudioPlayer, PlayerState.PAUSED);
                }

                break;
            }
            case Player.STATE_ENDED: {
                // completed
                playing = false;
                completed = true;

                stopForeground(false);
                player.setPlayWhenReady(false);
                player.seekTo(0, 0);
                break;
            }
            case Player.STATE_IDLE: {
                // stopped
                playing = false;
                stopped = true;
                completed = false;
                buffering = false;
                ref.handleStateChange(foregroundAudioPlayer, PlayerState.STOPPED);

                break;
            } // handle of released is in release method!
            }
        }

        @Override
        public void onPlayerError(ExoPlaybackException error) {
            Log.e(TAG, error.getMessage());
        }
    });
}
 
Example #27
Source File: AudioPlayerService.java    From googleads-ima-android with Apache License 2.0 4 votes vote down vote up
public void addAnalyticsListener(AnalyticsListener listener) {
  player.addAnalyticsListener(listener);
}
 
Example #28
Source File: ExoPlayerForwarder.java    From no-player with Apache License 2.0 4 votes vote down vote up
public AnalyticsListener analyticsListener() {
    return analyticsListener;
}
 
Example #29
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onDrmKeysRemoved(EventTime eventTime) {
    for (AnalyticsListener listener : listeners) {
        listener.onDrmKeysRemoved(eventTime);
    }
}
 
Example #30
Source File: NoPlayerAnalyticsListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
public void add(AnalyticsListener listener) {
    listeners.add(listener);
}