服務質量統計資料

服務質量(QoS)提供視訊引擎執行的詳細檢視。 TVSDK提供播放、緩衝和裝置的詳細統計資料。

TVSDK也提供下列下載資源的相關資訊:

  • 播放清單/資訊清單檔案
  • 檔案片段
  • 檔案的追蹤資訊

使用載入資訊在片段層級追蹤

您可以從LoadInformation類別讀取有關下載資源(如片段和軌道)的服務質量(QoS)資訊。

  1. 實作並註冊MediaPlayerEvent.LOAD_INFORMATION_AVAILABLE事件偵聽器。

  2. 呼叫event.getLoadInformation()以讀取傳遞至回呼的event參數的相關資料。

    注意

    如需LoadInformation的詳細資訊,請參閱 3.0 for Android(Java) API檔案。

讀取QOS回放、緩衝和設備統計資訊

您可以從QOSProvider類別讀取播放、緩衝和裝置統計資料。

QOSProvider類別提供各種統計資料,包括緩衝、位元速率、影格速率、時間資料等資訊。 此外,它也提供有關裝置的資訊,例如製造商、型號、作業系統、SDK版本、製造商的裝置ID和螢幕大小/密度。

  1. 實例化媒體播放器。

  2. 建立QOSProvider物件,並將它附加至媒體播放器。

    QOSProvider建構函式會擷取播放器內容,以便擷取裝置特定資訊。

    // Create Media Player.
    _mediaQosProvider = new QOSProvider(getActivity().getApplicationContext());
    _mediaQosProvider.attachMediaPlayer(_mediaPlayer);
    
  3. (可選)閱讀播放統計資料。

    讀取播放統計資訊的一個解決方案是具有計時器,該計時器定期從QOSProvider中讀取新的QoS值。

    例如:

    _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. (可選)閱讀裝置特定資訊。

    // 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 + ")");
    

本頁內容