Leer las estadísticas de reproducción, almacenamiento en búfer y dispositivo de QOS

Puede leer las estadísticas de reproducción, almacenamiento en búfer y dispositivo de la clase QOSProvider.

El QOSProvider proporciona varias estadísticas, incluida información sobre el almacenamiento en búfer, las velocidades de bits, las velocidades de fotogramas, los datos de tiempo, etc.

También proporciona información sobre el dispositivo, como el fabricante, el modelo, el sistema operativo, la versión del SDK, el ID de dispositivo del fabricante y el tamaño/densidad de la pantalla.

  1. Cree una instancia de un reproductor multimedia.

  2. Crear un QOSProvider y adjuntarlo al reproductor de contenidos.

    El QOSProvider toma un contexto del reproductor para poder recuperar información específica del dispositivo.

    // Create Media Player.
    _mediaQosProvider = new QOSProvider(getActivity().getApplicationContext());
    _mediaQosProvider.attachMediaPlayer(_mediaPlayer);
    
  3. (Opcional) Lea las estadísticas de reproducción.

    Una solución para leer las estadísticas de reproducción es tener un temporizador, que recupere periódicamente los nuevos valores de QoS de la QOSProvider. Por ejemplo:

    _playbackClock = new Clock(PLAYBACK_CLOCK, 1000); // every 1 second
    
    _playbackClockEventListener = new Clock.ClockEventListener() {
        @Override
        public void onTick(String name) {
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    PlaybackInformation playbackInformation = _mediaQosProvider.getPlaybackInformation();
                    setQosItem("Frame rate", (int) playbackInformation.getFrameRate());
                    setQosItem("Dropped frames", (int) playbackInformation.getDroppedFrameCount());
                    setQosItem("Bitrate", (int) playbackInformation.getBitrate());
                    setQosItem("Buffering time", (int) playbackInformation.getBufferingTime());
                    setQosItem("Buffer length", (int) playbackInformation.getBufferLength());
                    setQosItem("Buffer time", (int) playbackInformation.getBufferTime());
                    setQosItem("Empty buffer count", (int) playbackInformation.getEmptyBufferCount());
                    setQosItem("Time to load", (int) playbackInformation.getTimeToLoad());
                    setQosItem("Time to start", (int) playbackInformation.getTimeToStart());
                    setQosItem("Time to prepare", (int) playbackInformation.getTimeToPrepare());
                    setQosItem("Perceived Bandwidth", (int) playbackInformation.getPerceivedBandwidth());
                    playbackInformation.getPerceivedBandwidth());
                }
            });
        };
    };
    
  4. (Opcional) Lea la información específica del dispositivo.

    // Show device information
    DeviceInformation deviceInfo =
      new QOSProvider(parent.getApplicationContext()).getDeviceInformation();
    tv = (TextView) view.findViewById(R.id.aboutDeviceModel);
    tv.setText(parent.getString(R.string.aboutDeviceModel) + " " +
      deviceInfo.getManufacturer() + " - " + deviceInfo.getModel());
    
    tv = (TextView) view.findViewById(R.id.aboutDeviceSoftware);
    tv.setText(parent.getString(R.string.aboutDeviceSoftware) + " " +
      deviceInfo.getOS() + ", SDK: " + deviceInfo.getSDK());
    
    tv = (TextView) view.findViewById(R.id.aboutDeviceResolutin);
    String orientation = parent.getResources().getConfiguration().orientation ==
      Configuration.ORIENTATION_LANDSCAPE ? "landscape" : "portrait";
    tv.setText(parent.getString(R.string.aboutDeviceResolution) + " " +
      deviceInfo.getWidthPixels() + "x" + deviceInfo.getHeightPixels() +
      " (" + orientation + ")");
    

En esta página