How to make a player, without an interface, but with the ability to rewind in python?

Viewed 50

I have found many ways to interact with music in python, but in all there are only a few commands, start, stop, volume change, but I can't find a banal rewind.

The code at the moment:

import vlc
import time
import os
import random


def sound(sound):
    vlc_instance = vlc.Instance()
    player = vlc_instance.media_player_new()
    media = vlc_instance.media_new(sound)
    player.set_media(media) 
    player.play()
    time.sleep(1.5)
    duration = player.get_length() / 1000
    time.sleep(duration)


path = r'C:\Hobby\Music'
files = os.listdir(path)
random.shuffle(files)

for i in files:
    print(sound(os.path.join(path, i)))
1 Answers

Use Pygame's mixer music. It is not exactly a rewind, but it allows you to start playing the audio from a certain time. Documentation here.

Related