Я пытаюсь воспроизвести видео со звуком в python Tkinter через VLC, но не могу запустить файл, так как я получаю сообщение об ошибке при запуске строки import vlc.
У меня есть Python 3 на 32 бита, VLC player на 32 бита, и я установил его через pip install python-VLC
, что прошло успешно, а затем попробуйте запустить код и получить эту ошибку:
File "C:/Users/momoh/Documents/GitHub/CNDH/CNDH.py", line 5, in <module>
import vlc
File "C:\Users\momoh\AppData\Local\Programs\Python\Python36-32\lib\site-packages\vlc.py", line 207, in <module>
dll, plugin_path = find_lib()
File "C:\Users\momoh\AppData\Local\Programs\Python\Python36-32\lib\site-packages\vlc.py", line 163, in find_lib
dll = ctypes.CDLL(libname)
File "C:\Users\momoh\AppData\Local\Programs\Python\Python36-32\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
Это код, который я пытаюсь запустить:
Мой импорт:
import sys
import tkinter as tk
from tkinter import font as tkfont
from PIL import ImageTk, Image
import vlc
и класс для кадра, в котором есть видео
class PageThree(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.grid_columnconfigure(0, weight=0)
self.grid_columnconfigure(1, weight=1)
self.grid_columnconfigure(2, weight=2)
self.grid_columnconfigure(3, weight=1)
self.grid_columnconfigure(4, weight=0)
self.grid_rowconfigure(0, weight=0)
self.grid_rowconfigure(1, weight=1)
self.grid_rowconfigure(2, weight=2)
self.grid_rowconfigure(3, weight=3)
self.grid_rowconfigure(4, weight=2)
self.grid_rowconfigure(5, weight=1)
self.grid_rowconfigure(6, weight=6)
self.configure(background="white")
# Open the video source |temporary
self.video_source = "assetsCNDH/prueba.mp4"
# Canvas where to draw video output
self.canvas = tk.Canvas(self, width= controller.winfo_screenwidth(),
height=controller.winfo_screenheight(), bg="black",
highlightthickness=0)
self.canvas.pack()
# Creating VLC player
self.instance = vlc.Instance()
self.player = self.instance.media_player_new()
def GetHandle(self):
# Getting frame ID
return self.winfo_id()
def play(self, _source):
# Function to start player from given source
Media = self.instance.media_new(_source)
Media.get_mrl()
self.player.set_media(Media)
# self.player.play()
self.player.set_hwnd(self.GetHandle())
self.player.play()
Как запустить видео?