如何在python、Windows下载使用QtMultimedia?
How to download and use QtMultimedia in python, Windows?
如何在pyqt5中使用QtMultimedia
。
我正在使用 Windows 操作系统。
我研究了QtMultimedia
,但我还是不知道怎么下载,你能帮我吗?
如果您已经安装了 PyQt
,那么您只需将其添加到您的代码中:
import PyQt5.QtMultimedia
如果你没有,那么你可以使用 pip 命令安装 PyQt
pip install PyQt5
。
要使用它,请查看 the PyQt source code where they include examples of QtMultimedia
仅此而已。这是您可以使用的一个简单示例:
def load_soundtrack_playlist():
"""
Loads the play list of the soundtracks and replaces the file name with the full path.
A playlist is a list where each entry is a list of two strings: file path, title
"""
global soundtrack_playlist
# create playlist
soundtrack_playlist = QtMultimedia.QMediaPlaylist()
soundtrack_playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop)
# read information file
data = utils.read_as_yaml(constants.SOUNDTRACK_INFO_FILE)
# add the soundtrack folder to each file name
for entry in data:
file = constants.extend(constants.SOUNDTRACK_FOLDER, entry[0])
url = qt.local_url(file)
media = QtMultimedia.QMediaContent(url)
soundtrack_playlist.addMedia(media)
如何在pyqt5中使用QtMultimedia
。
我正在使用 Windows 操作系统。
我研究了QtMultimedia
,但我还是不知道怎么下载,你能帮我吗?
如果您已经安装了 PyQt
,那么您只需将其添加到您的代码中:
import PyQt5.QtMultimedia
如果你没有,那么你可以使用 pip 命令安装 PyQt
pip install PyQt5
。
要使用它,请查看 the PyQt source code where they include examples of QtMultimedia
仅此而已。这是您可以使用的一个简单示例:
def load_soundtrack_playlist():
"""
Loads the play list of the soundtracks and replaces the file name with the full path.
A playlist is a list where each entry is a list of two strings: file path, title
"""
global soundtrack_playlist
# create playlist
soundtrack_playlist = QtMultimedia.QMediaPlaylist()
soundtrack_playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop)
# read information file
data = utils.read_as_yaml(constants.SOUNDTRACK_INFO_FILE)
# add the soundtrack folder to each file name
for entry in data:
file = constants.extend(constants.SOUNDTRACK_FOLDER, entry[0])
url = qt.local_url(file)
media = QtMultimedia.QMediaContent(url)
soundtrack_playlist.addMedia(media)