我正在尝试让python将音乐文件排入Winamp。我尝试过以下几种方法:
某些功能有效,但添加到播放列表不起作用
WACommand
同样,一些命令行开关可以工作,但是加载文件不能
有没有人知道怎么解决这个问题?我不是在寻找一个完整的winamp控制器,只是在一个已经运行的实例中推送文件到播放列表的一种方式。
我使用的是winamp 5.63和windows7 x64以及python2.7
发布于 2013-09-03 16:19:22
不太确定这是否是你要找的,但我希望它能有所帮助…
我找到了一个粗略的方法,那就是:
进入Winamp,进入选项->首选项->文件类型,然后选中“双击时将文件入队”的复选框,然后接受首选项。
完成后,下面的Python代码将把20首歌曲(或者while循环设置为多少首歌曲)放入给定目录的播放列表中。
此外,如果您不希望歌曲是随机的,可以将path变量指定为您选择的任何文件的文件路径
import os
import random
import dircache
i = 0
while i < 20: # change 20 to how ever many songs you want to generate
# set your directory in line bellow
dir = "C:\"
filename = random.choice(dircache.listdir(dir))
path = os.path.join(dir, filename)
os.startfile(path)
i+=1发布于 2015-07-15 01:54:21
我在Windows864位上使用Python3,使用pywinamp.py我可以将文件添加到播放列表中并播放该文件。下面是我的代码:
# Run winamp.exe
try:
with open(os.devnull, 'wb') as devnull:
devnull = open(os.devnull)
winamp_path = 'C:\\Program Files\\Winamp\\winamp.exe'
p = subprocess.Popen([winamp_path], stdout=devnull, stderr=devnull)
except OSError as e:
# handle the exception
pass
w = Winamp() # class from pywinamp.py
# Wait for app to start
''' For some reason i couldn't access __mainWindowHWND attribute of Winamp class so i added this line in __init__ method of Winamp class: self.wid = self.__mainWindowHWND. This way i know if winamp is open'''
while not w.wid:
w = Winamp()
time.sleep(2)
# Enqueue file in Winamp
w.enqueueFile(filepath.encode('utf-8')) # ctypes needs bytes type
# Get length of winamp playlist and set position on the last track
w.setPlaylistPosition(w.getListLength())
# Play song
w.play()发布于 2013-08-26 03:54:05
pywinamp可以正常使用Python2.7 x86,但不能使用Python2.7 x64。所以。
https://stackoverflow.com/questions/18413229
复制相似问题