I need to get the following data during playback:
- Number of dropped video frames (numberOfDroppedVideoFrames)
- Number of bytes downloaded (numberOfBytesTransferred)
In theory I should be able to get those as they "happen" from AVPlayerItem's access log.
However, the logic for digging them out of the access log is not clear to me. When my observer handles a AVPlayerItemNewAccessLogEntry notification, it typically only looks at the last event. But it seems that by looking only at the last event on each invocation, I will miss more events that were added to the log since the last one - yet I don't know how many events from the end I should look at.
Moreover, the events don't cary a timestamp, so for the numberOfDroppedVideoFrames event I can't tell the period on which they occured, which is important for analytics purposes.
In my notification handler I've added code that prints all events on the log to the console. I only look at the above two metrics, and log them as DROPS and BYTES. This is what was printed after playing for ~30 seconds:
EVENTS: [<DROPS: 0 BYTES: 141752>]
EVENTS: [<DROPS: 0 BYTES: 1694552>, <DROPS: 0 BYTES: 911800>]
EVENTS: [<DROPS: 0 BYTES: 1694552>, <DROPS: 0 BYTES: 911800>, <DROPS: 0 BYTES: 821560>]
Why was the event that appears in the first handler invocation removed from the log?
Why wasn't the handler called when the event that has "BYTES: 1694552" was added to the log, so that I can catch it the the last event?
Please help.
Noam.