Once you have a player up and running is interesting to get the statistics about the url/local video you are playing, this can help to locate problems related to the content you are using and give you several hints about performance.
Following example retrieves statistical information about how content is currently being handled by NexPlayer. If statistics like the rate of video frames being dropped or of frames being rendered are desired, this property can be used to retrieve the FPS (frames per second) for short intervals (about 2 seconds) of content, as well as the total number of decoded video frames and the number of frames rendered during that interval of content.
func setupTimer(player: NXPlayer) {
statisticsAPI = NXStatisticsAPI(player: player)
statTimer = Timer.scheduledTimer(timeInterval: 2.0, target: self, selector: #selector(NexVideoPlayer.updateStats), userInfo: nil, repeats: true)
}
@objc func updateStats() {
print("------PLAYER STATS------")
print("avgAudioBitrate : \(player.statsInfo.avgAudioBitrate)")
print("avgTimeDecodingVideoFrames : \(player.statsInfo.avgTimeDecodingVideoFrames)")
print("avgTimeRenderingVideoFrames : \(player.statsInfo.avgTimeRenderingVideoFrames)")
print("avgVideoBitrate : \(player.statsInfo.avgVideoBitrate)")
print("decodedVideoFramesLastInterval : \(player.statsInfo.decodedVideoFramesLastInterval)")
print("decodedVideoFramesPerSec : \(player.statsInfo.decodedVideoFramesPerSec)")
print("numDecodingVideoFrames : \(player.statsInfo.numDecodingVideoFrames)")
print("numRenderingVideoFrames : \(player.statsInfo.numRenderingVideoFrames)")
print("renderedVideoFramesLastInterval : \(player.statsInfo.renderedVideoFramesLastInterval)")
print("renderedVideoFramesPerSec : \(player.statsInfo.renderedVideoFramesPerSec)")
print("timeDecodingSingleVideoFrame : \(player.statsInfo.timeDecodingSingleVideoFrame)")
print("timeRenderingSingleVideoFrame : \(player.statsInfo.timeRenderingSingleVideoFrame)")
print("totalAudioFrameBytes : \(player.statsInfo.totalAudioFrameBytes)")
print("totalVideoFrames : \(player.statsInfo.totalVideoFrames)")
print("totalDecodedVideoFrames : \(player.statsInfo.totalDecodedVideoFrames)")
print("totalDroppedVideoFrames : \(player.statsInfo.totalDroppedVideoFrames)")
print("totalRenderedVideoFrames : \(player.statsInfo.totalRenderedVideoFrames)")
print("videoFramesLastInterval : \(player.statsInfo.videoFramesLastInterval)")
print("------BUFFER STATS------")
print("video buffer rate : \(statisticsAPI.bufferInfo.bufferRate(NXBufferInfoMediaType.video))")
print("audio buffer rate : \(statisticsAPI.bufferInfo.bufferRate(NXBufferInfoMediaType.audio))")
print("video buffer size : \(statisticsAPI.bufferInfo.bufferSize(NXBufferInfoMediaType.video))")
print("audio buffer size : \(statisticsAPI.bufferInfo.bufferSize(NXBufferInfoMediaType.audio))")
print("------Streaming STATS------")
print("curNetworkBw : \(statisticsAPI.rtStreamingInfo.curNetworkBw)")
print("curTrackBw : \(statisticsAPI.rtStreamingInfo.curTrackBw)")
print("numOfBytesRecv : \(statisticsAPI.rtStreamingInfo.numOfBytesRecv)")
print("numOfRedirect : \(statisticsAPI.rtStreamingInfo.numOfRedirect)")
print("numOfSegmentDownRate : \(statisticsAPI.rtStreamingInfo.numOfSegmentDownRate)")
print("numOfSegmentRecv : \(statisticsAPI.rtStreamingInfo.numOfSegmentRecv)")
print("numOfSegmentRequest : \(statisticsAPI.rtStreamingInfo.numOfSegmentRequest)")
print("numOfSegmentInBuf : \(statisticsAPI.rtStreamingInfo.numOfSegmentInBuf)")
print("numOfSegmentTimeout : \(statisticsAPI.rtStreamingInfo.numOfSegmentTimeout)")
print("numOfTrackSwitchUp : \(statisticsAPI.rtStreamingInfo.numOfTrackSwitchUp)")
print("numOfSegmentFailToParse : \(statisticsAPI.rtStreamingInfo.numOfSegmentFailToParse)")
print("numOfSegmentFailToRecv : \(statisticsAPI.rtStreamingInfo.numOfSegmentFailToRecv)")
print("numOfTrackSwitchDown : \(statisticsAPI.rtStreamingInfo.numOfTrackSwitchDown)")
print("numOfTrackSwitchUp : \(statisticsAPI.rtStreamingInfo.numOfTrackSwitchUp)")
print("numOfSegmentInBuf : \(statisticsAPI.rtStreamingInfo.numOfSegmentInBuf)")
}
This interface provides playback statistics about the current content in NexPlayer.
This interface can be used to retrieve playback statistics such as the decoded frame rate and the rate of frames being rendered in the player over a short interval of content playback, which may be useful in monitoring player performance and user experience.
The average bitrate of the audio content currently playing.
The average time took to decode a video frame.
The average time took to render a video frame.
The average bitrate of the video currently playing.
Number of video frames decoded by NexPlayer during the last interval of content.
The default interval of content is 2seconds.
The average number of video frames decoded per second.
Number of video frames decoded by NexPlayer during the last interval of content. The default interval of content is 2 seconds.
!> Deprecated Use decodedVideoFramesLastInterval
Instead.
Number of video frames rendered and displayed by NexPlayer over the last interval of content.
Even though data for more frames of current content may be decoded during an interval, it may be necessary at times for some frames to be skipped in certain circumstances, and this value provides clearer information about what is actually displayed by NexPlayer.
!> Deprecated Use renderedVideoFramesLastInterval
Instead.
Number of video frames rendered and displayed by NexPlayer over the last interval of content.
Even though data for more frames of current content may be decoded during an interval, it may be necessary at times for some frames to be skipped in certain circumstances, and this value provides clearer information about what is actually displayed by the NexPlayer.
The average number of video frames displayed per second.
The time took to decode a video frame.
The time took to render a video frame.
The total size of all the audio frames, in bytes.
The total number of video frames decoded to play video content.
The total number of video frames skipped while playing video content.
The total number of video frames displayed during playing video content.
The total size of all the video frames of a video, in bytes.
The total number of video frames to decode.
The number of video frames available to be decoded during the last interval of content.
This class manages the playback statistics of the content.
Designated initializer.
Parameters
Name | Description |
---|---|
player | The NXPlayer instance. |
Returns
An instance of NXStatisticsAPI class.
Instance of NXBufferInfo class to access buffer information-related methods such asNSUInteger.
See Also
NXBufferInfo
The information about the current device streaming HLS content.
See Also
NXDeviceInfo
An object that conforms to NXHttpStateDelegate which delivers HTTP state information.
See Also
NXHttpStateDelegate
Information about the current HLS content.
See Also
NXRTStreamingInfo
A delegate method for NXStatisticsAPI
. Implement this to receive HTTP state information. These methods are optional; implement the methods if you wish to receive the HTTP state information.
- (void) nexPlayer: (NXPlayer ∗) nxplayer urlString:(NSString ∗) URLString stateInfoDataReceived:(NXHttpStateInfoDataReceived ∗) dataReceived [optional]
This event occurs when NexPlayer is downloading a file which is one of NXHttpStateInfoFileType.
Parameters
Name | Description |
---|---|
dataReceived | The detailed dataReceived information (see NXHttpStateInfoDataReceived ). |
- (void) nexPlayer: (NXPlayer ∗) nxplayer urlString:(NSString ∗) URLString stateInfoDownEnd:(NXHttpStateInfo- DownEnd ∗) downEnd [optional]
This event occurs when NexPlayer finished downloading a file which is one of NXHttpStateInfoFileType.
Parameters
Name | Description |
---|---|
downEnd | The detailed downEnd information (see NXHttpStateInfoDownEnd ). |
- (void) nexPlayer: (NXPlayer ∗) nxplayer urlString:(NSString ∗) URLString stateInfoDownStart:(NXHttpStateInfo- DownStart ∗) downStart [optional]
This event occurs when NexPlayer started downloading a file which is one of the NXHttpStateInfoFileType.
Parameters
Name | Description |
---|---|
downStart | The detailed downStart information (see NXHttpStateInfoDownStart ). |
- (void) nexPlayer: (NXPlayer ∗) nxplayer urlString:(NSString ∗) URLString stateInfoHttpError:(NXHttpStateInfo- HttpError ∗) httpError [optional]
This event occurs when NexPlayer encountered an error during download.
Parameters
Name | Description |
---|---|
httpError | The detailed error information(see NXHttpStateInfoHttpError). |
The current number of bytes received, as an integer.
The total bytes of the content to be downloaded. -1 represents unknown.
The current number of bytes received, as an integer.
The file type to be downloaded.
- NXHttpStateInfoFileTypeUnknown = 0,
- NXHttpStateInfoFileTypeMPD = 1,
- NXHttpStateInfoFileTypeSegment = 2,
- NXHttpStateInfoFileTypeInitialSegment = 3,
- NXHttpStateInfoFileTypeKey = 4,
- NXHttpStateInfoFileTypeSegmentIndex = 5
The media type of the current content.
- NXHttpStateInfoMediaTypeNone = 0
- NXHttpStateInfoMediaTypeAudio = 1
- NXHttpStateInfoMediaTypeBaseVideo = 2
- NXHttpStateInfoMediaTypeText = 4
- NXHttpStateInfoMediaTypeEnhancedVideo = 8
The duration of the current segment, as an integer.
The current segment number, as an integer.
The bandwidth of the current track, as an integer.
This class provides information about the current device.
The type of current data connection of a device.
The ID of a device.
The device type name.
The IP address of a device.
The current iOS version of a device.
This class manages information about the current streaming content.
The actual bitrate, in bps, of the read segments. The read bitrate is the average speed at which the streaming segments are read from the network server.
The bitrate, in bps, as specified in the segment profile.
Full content of an initial manifest file.
The actual URI (after all the redirects) for the request of a manifest file.
Full content of a master manifest file.
Master manifest URL.
The number of bytes received from the server by the player.
The total number of redirects. This includes redirects for both the manifest file and the individual segments.
The number of the segments with a lower read bitrate than the bitrate specified on the profile. The read bitrate is the average speed at which the streaming segments are read from the network server.
The number of segments failed to receive during the streaming.
The number of segments failed to receive from the server.
The total number of segments in the buffer.
The number of received segments from the server by the player.
The number of requested segments from the server by the player.
The number of segments that results in a timeout.
The number of times that a content profile has changed to a profile with a lower bitrate.
The number of times that a content profile has changed to a profile with a higher bitrate.
The description of an initially selected profile.
This class retrieves the specified buffer information.
?> Note Do not create an instance of this class directly. Instead, use the NXStatisticsAPI::bufferInfo property.
See Also
- NXStatisticsAPI::bufferInfo
This method gets the buffered size of current media stream.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The buffered size.
This method gets the buffering state of current media content.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The buffering state of the current media content.
This method gets the buffer rate : (Buffered size)∗100 / (Total buffer size), or how much percentage full the current buffer is.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The buffer rate of current media stream.
This method gets the buffer size of current media stream.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The buffer size of current media stream.
This method gets the CTS of first frame in the buffer.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The CTS of first frame in the buffer. If there is no frame, return NXBufferInfoValueNotAvailable.
This method gets the initial buffering size of current media stream.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The Initial buffering size of current media stream.
This method gets the initial buffering time of current media stream.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The initial buffering time of current media stream.
This method gets the CTS of last frame in the buffer.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The CTS of last frame in the buffer. If there is no frame, return NXBufferInfoValueNotAvailable.
This method gets the total duration of frames in the buffer.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The total duration of all the frames in the buffer, in milliseconds.
This method gets the total count of frames in the buffer.
Parameters
Name | Description |
---|---|
mediaType | The type of current media stream. |
Returns
The total count of all the frames in the buffer.