/** Returns the debugging information string to be shown by the target {@link TextView}. */ protected String getDebugString() { return getPlayerStateString() + getVideoString() + getAudioString(); }
@Override public final void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) { updateAndPost(); }
/** Returns a string containing video debugging information. */ protected String getVideoString() { Format format = player.getVideoFormat(); DecoderCounters decoderCounters = player.getVideoDecoderCounters(); if (format == null || decoderCounters == null) { return ""; } return "\n" + format.sampleMimeType + "(id:" + format.id + " r:" + format.width + "x" + format.height + getPixelAspectRatioString(format.pixelWidthHeightRatio) + getDecoderCountersBufferCountString(decoderCounters) + ")"; }
@SuppressLint("SetTextI18n") protected final void updateAndPost() { textView.setText(getDebugString()); textView.removeCallbacks(this); textView.postDelayed(this, REFRESH_INTERVAL_MS); }
/** Returns a string containing audio debugging information. */ protected String getAudioString() { Format format = player.getAudioFormat(); DecoderCounters decoderCounters = player.getAudioDecoderCounters(); if (format == null || decoderCounters == null) { return ""; } return "\n" + format.sampleMimeType + "(id:" + format.id + " hz:" + format.sampleRate + " ch:" + format.channelCount + getDecoderCountersBufferCountString(decoderCounters) + ")"; }
@Override public final void onPlayerStateChanged(boolean playWhenReady, int playbackState) { updateAndPost(); }
@Override public final void run() { updateAndPost(); }
/** * Starts periodic updates of the {@link TextView}. Must be called from the application's main * thread. */ public final void start() { if (started) { return; } started = true; player.addListener(this); updateAndPost(); }