When I use:
setNotifyInterval(1)
, I notice that it sometimes skips a millisecond.
For example: When I print the position of the media, often it skips 2 seconds instead of 1. This is a problem because I want the program to stop every 10 seconds, and if it skips a millisecond then it won't stop.
Ex: If I want the video to stop at 10 seconds (10000 ms) it sometimes goes like this when I output the positions:
9999 ms
10001 ms
So the 10000 ms position is skipped and the video won't stop. Has anyone else had this issue before? Is it due to video buffering or computer latency? Thanks for your help.
The documentation for the method is: setNotifyInterval(milliseconds)
EDIT: I appreciate your guys help. Here is some more explanation of the example:
So I have a positionChanged
signal connected to a positionChanged
slot. (positionChanged method is the same name as the signal but can be changed to any other name).
Therefore, I call this to connect signal-slot mechanism: self.mediaPlayer.positionChanged.connect(self.positionChanged)
The positionChanged method tells the video to stop every 10 seconds, so it looks like this:
def positionChanged(self, position):
if position % 10000 == 0: # 10000 milliseconds is 10 seconds
self.mediaPlayer.pause()
Video player sometimes doesn't stop every 10 seconds. This is because setNotifyInterval(1) isn't always accurate
. I will use what musicamante said and just check if it the player is greater or equal to 10 seconds. Thanks for your help