我有一个由PyQt编写的程序,该程序通过绑定libvlc来播放视频。
# -*- coding: utf-8 -*-
import sys
import os
import vlc
from PySide2.QtGui import *
from PySide2.QtCore import *
from PySide2.QtWidgets import *
class vlc_demo(QWidget):
def __init__(self):
super(vlc_demo, self).__init__()
self.__ui__()
self.__load__()
def __ui__(self):
self.setFixedSize(800,600)
t_lay_parent = QVBoxLayout()
self.m_label_media = QLabel()
t_lay_bottom = QHBoxLayout()
self.m_button_one = QPushButton("one")
self.m_button_too = QPushButton("too")
self.m_button_three = QPushButton("three")
t_lay_bottom.addWidget(self.m_button_one)
t_lay_bottom.addWidget(self.m_button_too)
t_lay_bottom.addWidget(self.m_button_three)
self.m_button_one.clicked.connect(self.slt_one)
self.m_button_too.clicked.connect(self.slt_too)
self.m_button_three.clicked.connect(self.slt_three)
t_lay_parent.addWidget(self.m_label_media)
t_lay_parent.addLayout(t_lay_bottom)
self.setLayout(t_lay_parent)
def __load__(self):
self.m_instance = vlc.Instance()
self.m_player = self.m_instance.media_player_new()
self.m_win_id = self.m_label_media.winId()
if sys.platform.startswith('linux'): # linux
self.m_player.set_xwindow(self.m_win_id)
elif sys.platform == "win32": # windows
self.m_player.set_hwnd(self.m_win_id)
elif sys.platform == "darwin": # mac
self.m_player.set_nsobject(self.m_win_id)
def slt_one(self):
self.m_label_media.show()
media = self.m_instance.media_new("1.mp4")
self.m_player.set_media(media)
self.m_player.play()
def slt_too(self):
self.m_label_media.show()
media = self.m_instance.media_new("2.mp4")
self.m_player.set_media(media)
self.m_player.play()
def slt_three(self):
self.m_label_media.hide()
if __name__ == "__main__":
app = QApplication(sys.argv)
win = vlc_demo()
win.show()
sys.exit(app.exec_())
在Windows下,将以下文件和目录复制到VLC媒体播放器目录中。该程序可以在没有VLC媒体播放器的计算机上运行。
- libvlc.dll
- libvlccore.dll
- plugins
在CentOS7下,没有安装VLC媒体播放器就可以运行该程序吗?
答案 0 :(得分:0)
我相信您可能会使用AFAIU专为此设计的Snapcraft零件。
对于VLC为https://github.com/videolan/vlc/blob/master/extras/package/snap/snapcraft.yaml