Skip to content

Commit

Permalink
This fixes the Windows build.
Browse files Browse the repository at this point in the history
  • Loading branch information
ozankaraali committed May 20, 2024
1 parent b7314f5 commit fa45822
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 76 deletions.
36 changes: 17 additions & 19 deletions qitv-windows.spec
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
import site
import os
# -*- mode: python ; coding: utf-8 -*-

PACKAGES_PATH = site.getsitepackages()[0]
VLC_PATH = 'C:\\Program Files\\VideoLAN\\VLC' # Adjust this path if necessary
VLC_PATH = 'C:\\Program Files\\VideoLAN\\VLC'

block_cipher = None

a = Analysis(
['main.py'],
pathex=[],
pathex=[VLC_PATH], #insert your base VLC path here, ex: pathex=["D:\KivySchool\VLC"],
binaries=[
(os.path.join(VLC_PATH, 'libvlc.dll'), '.'),
(os.path.join(VLC_PATH, 'libvlccore.dll'), '.'),
(os.path.join(VLC_PATH, 'axvlc.dll'), '.'),
(os.path.join(VLC_PATH, 'npvlc.dll'), '.'),
],
datas=[
('assets/qitv.ico', 'assets/qitv.ico')
(os.path.join(VLC_PATH, 'plugins/*'), 'plugins'),
],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.binaries + [("libVLC.dll", os.path.join(VLC_PATH, 'libVLC.dll'), "BINARY")],
a.datas,
[],
name='qitv.exe',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon='assets/qitv.ico'
)
62 changes: 5 additions & 57 deletions video_player.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import sys
import vlc
import json
import platform
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QFrame, QWidget
from PyQt5.QtGui import QPalette, QColor

import vlc
from PyQt5.QtCore import Qt
import os
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtWidgets import QMainWindow, QVBoxLayout, QWidget


class VideoPlayer(QMainWindow):
Expand All @@ -18,59 +17,8 @@ def __init__(self):
palette.setColor(QPalette.Window, QColor(0, 0, 0))
self.setPalette(palette)

if platform.system() == "Windows":
if getattr(sys, 'frozen', False):
vlc_dir = sys._MEIPASS # Temporary extraction path used by PyInstaller
else:
vlc_dir = os.path.dirname(os.path.abspath(__file__))

# Ensure the VLC path is set in the environment
libvlc_path = os.path.join(vlc_dir, 'libvlc.dll')
libvlccore_path = os.path.join(vlc_dir, 'libvlccore.dll')

# Log paths for debugging
print(f"VLC Path: {libvlc_path}")
print(f"VLC Core Path: {libvlccore_path}")

# Ensure the paths are set correctly
os.environ['PYTHON_VLC_LIB_PATH'] = vlc_dir

if platform.system() == "Linux":
if getattr(sys, 'frozen', False):
vlc_dir = sys._MEIPASS # Temporary extraction path used by PyInstaller
else:
vlc_dir = os.path.dirname(os.path.abspath(__file__))
# Ensure the VLC path is set in the environment
libvlc_path = os.path.join(vlc_dir, 'libvlc.so')
libvlccore_path = os.path.join(vlc_dir, 'libvlccore.so')

# Log paths for debugging
print(f"VLC Path: {libvlc_path}")
print(f"VLC Core Path: {libvlccore_path}")

# Ensure the paths are set correctly
os.environ['PYTHON_VLC_LIB_PATH'] = vlc_dir
if platform.system() == "Darwin":
if getattr(sys, 'frozen', False):
vlc_dir = sys._MEIPASS # Temporary extraction path used by PyInstaller
else:
vlc_dir = os.path.dirname(os.path.abspath(__file__))
# Ensure the VLC path is set in the environment
libvlc_path = os.path.join(vlc_dir, 'libvlc.dylib')
libvlccore_path = os.path.join(vlc_dir, 'libvlccore.dylib')

# Log paths for debugging
print(f"VLC Path: {libvlc_path}")
print(f"VLC Core Path: {libvlccore_path}")

# Ensure the paths are set correctly
os.environ['PYTHON_VLC_LIB_PATH'] = vlc_dir

# Initialize VLC instance
try:
self.instance = vlc.Instance(['--plugin-path', vlc_dir])
if not self.instance:
raise Exception("Failed to create VLC instance")
self.instance = vlc.Instance()
except Exception as e:
print(f"Exception occurred while creating VLC instance: {e}")
raise
Expand Down

0 comments on commit fa45822

Please sign in to comment.