如何制作一个播放器,没有界面,但能够在 python 中倒带?
How to make a player, without an interface, but with the ability to rewind in python?
我在python中找到了很多与音乐互动的方法,但总共只有几个命令,开始、停止、音量改变,但我找不到平庸的倒带。
当前代码:
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)))
使用Pygame的混音器音乐。这不完全是倒带,但它允许您从特定时间开始播放音频。文档 here.
我在python中找到了很多与音乐互动的方法,但总共只有几个命令,开始、停止、音量改变,但我找不到平庸的倒带。
当前代码:
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)))
使用Pygame的混音器音乐。这不完全是倒带,但它允许您从特定时间开始播放音频。文档 here.