You can read playback and device statistics from the QOSProvider as often as needed.
The QOSProvider class provides various statistics, including the frame rate, the profile bit rate, the total time spent in buffering, the number of buffering attempts, the time it took to get the first byte from the first video fragment, the time it took to render the first frame, the currently buffered length, and the buffer time.
You can also get information about the device, such as manufacturer, model, operating system, SDK version, and screen size/density.
// Create Media Player. _mediaQosProvider = new QOSProvider(getActivity().getApplicationContext()); _mediaQosProvider.attachMediaPlayer(_mediaPlayer);
The QOSProvider constructor takes a Context, because it will need it to retrieve device-specific information such as the model, manufacturer, and operating system.
One solution for reading playback statistics would be to have a timer that periodically fetches the new QoS values from the QOSProvider. The PMPDemoApp demonstrates this. For example:
_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());
}
});
}
};
// Show device information
DeviceInformation deviceInfo = new QOSProvider(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.aboutDeviceResolution); String orientation = parent.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE ? "landscape" : "portrait";
tv.setText(parent.getString(R.string.aboutDeviceResolution) +
" " + deviceInfo.getWidthPixels() + "x" + deviceInfo.getHeightPixels() +
" (" + orientation + ")");