pygame.error: set_pos unsupported for this codec pygame.error: set_pos unsupported for this codec tkinter tkinter

pygame.error: set_pos unsupported for this codec


Not enough rep to comment.

unfortunately pygame.mixer.music.set_pos() is only supported after v 1.9.2. As you have 1.9.3, it is supposed to run in your code. I can't find out the reason but I can offer you an alternative:

play_time = pygame.mixer.music.get_pos()

This will give you playtime in milliseconds. type of 'play_time' is 'int'. Initialize a variable 'start = 0'. You can now use

start = start + play_time/1000.0

everytime you pause() or stop() to get time in seconds. Why add it to previous value is because if you don't add 'play_time/1000.0' to the previous value of start, then get_pos() will only calculate the time that passed since you started playing and that won't give you the current position at which playback is paused or stopped but only time passed since when the last playback began.

Now you can do this before or after

pygame.mixer.music.pause() #or stop()

You will now have the time at which it paused.

Instead of using set_pos(), go for

pygame.music.play(-1, start)

note that play(loop, start_pos) take start_pos in seconds. so we needed it in secs. you can now remove set_pos()

Alternative:simply use

pygame.mixer.music.pause()pygame.mixer.music.unpause()

you don't need to calculate time and then set it again.


This error is because that the time unit of set_pos() is seconds but get_pos() is millseconds.

So your set_pos() function should pass time/1000 instead of time:

pygame.mixer.music.set_pos(time/1000)