Leggi le statistiche relative a riproduzione, buffering e dispositivo QOS

È possibile leggere le statistiche di riproduzione, buffering e dispositivo dalla classe QOSProvider.

La classe QOSProvider fornisce diverse statistiche, tra cui buffering, bit rate, frame rate, dati temporali e così via.

Fornisce inoltre informazioni sul dispositivo, ad esempio il produttore, il modello, il sistema operativo, la versione SDK, l'ID dispositivo del produttore e la dimensione/densità dello schermo.

  1. Creare un'istanza di un lettore multimediale.

  2. Crea un oggetto QOSProvider e allegalo al lettore multimediale.

    Il costruttore QOSProvider prende il contesto di un lettore in modo che possa recuperare informazioni specifiche per il dispositivo.

    // Create Media Player.
    _mediaQosProvider = new QOSProvider(getActivity().getApplicationContext());
    _mediaQosProvider.attachMediaPlayer(_mediaPlayer);
    
  3. (Facoltativo) Leggere le statistiche di riproduzione.

    Una soluzione per leggere le statistiche di riproduzione è avere un timer, che recupera periodicamente i nuovi valori QoS dal QOSProvider. Ad esempio:

    _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. (Facoltativo) Leggi le informazioni specifiche 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 + ")");
    

In questa pagina