首页 > 解决方案 > vlc.Instance: AttributeError("模块 'vlc' 没有属性 'Instance'")

问题描述

我正在尝试使 VLC 播放器正确导入,以便连续播放一系列 VLC 媒体文件。但是,我似乎无法让 VLC 正确导入!我已经下载了 vlc.py 并将其添加到我的工作区。它看起来像这样;

import vlc

class PlayerWindow(Frame):

    def __init__(self, parent):

        super().__init__()



        self.parent = parent

        self.parent.attributes('-alpha', 0)

        self.parent.attributes("-fullscreen", True)

        self.parent.bind_all("<Key>", self.key)



        # VLC player controls

        self.Instance = vlc.Instance()

        self.player = self.Instance.media_player_new()

        self.player.toggle_fullscreen()

        self.player.video_set_key_input(False)



        self.parent.update()

我正在使用 Microsoft VS 2017

标签: pythonvlc

解决方案


尝试卸载 vlc (pip uninstall vlc) 并重新安装它的组合。与 python-vlc 相同。还要检查您的路径变量是否已设置(VS Code 和 VideoLAN\VLC )。它必须工作。


推荐阅读