initial version

This commit is contained in:
Tim Bentley 2019-05-05 09:13:10 +01:00
parent 22db084375
commit 54aea66a16
4 changed files with 49 additions and 8845 deletions

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2019 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
The :mod:`~openlp.core.ui.media.vendor` module contains any scripts or libraries
from 3rd party vendors which are required to make certain media modules work.
"""

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@ import os
import sys import sys
import threading import threading
from datetime import datetime from datetime import datetime
import vlc
from distutils.version import LooseVersion from distutils.version import LooseVersion
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
@ -65,59 +66,61 @@ def get_vlc():
:return: The "vlc" module, or None :return: The "vlc" module, or None
""" """
if 'openlp.core.ui.media.vendor.vlc' in sys.modules: if 'vlc' in sys.modules:
# If VLC has already been imported, no need to do all the stuff below again # If VLC has already been imported, no need to do all the stuff below again
is_vlc_available = False is_vlc_available = False
try: try:
is_vlc_available = bool(sys.modules['openlp.core.ui.media.vendor.vlc'].get_default_instance()) is_vlc_available = bool(sys.modules['vlc'].get_default_instance())
except Exception: except Exception:
pass pass
if is_vlc_available: if is_vlc_available:
return sys.modules['openlp.core.ui.media.vendor.vlc'] return sys.modules['vlc']
else: else:
return None return None
is_vlc_available = False
try:
if is_macosx():
# Newer versions of VLC on OS X need this. See https://forum.videolan.org/viewtopic.php?t=124521
os.environ['VLC_PLUGIN_PATH'] = '/Applications/VLC.app/Contents/MacOS/plugins'
# On Windows when frozen in PyInstaller, we need to blank SetDllDirectoryW to allow loading of the VLC dll.
# This is due to limitations (by design) in PyInstaller. SetDllDirectoryW original value is restored once
# VLC has been imported.
if is_win():
buffer_size = 1024
dll_directory = ctypes.create_unicode_buffer(buffer_size)
new_buffer_size = ctypes.windll.kernel32.GetDllDirectoryW(buffer_size, dll_directory)
dll_directory = ''.join(dll_directory[:new_buffer_size]).replace('\0', '')
log.debug('Original DllDirectory: %s' % dll_directory)
ctypes.windll.kernel32.SetDllDirectoryW(None)
from openlp.core.ui.media.vendor import vlc
if is_win():
ctypes.windll.kernel32.SetDllDirectoryW(dll_directory)
is_vlc_available = bool(vlc.get_default_instance())
except (ImportError, NameError, NotImplementedError):
pass
except OSError as e:
# this will get raised the first time
if is_win():
if not isinstance(e, WindowsError) and e.winerror != 126:
raise
else: else:
pass
if is_vlc_available:
try:
VERSION = vlc.libvlc_get_version().decode('UTF-8')
except Exception:
VERSION = '0.0.0'
# LooseVersion does not work when a string contains letter and digits (e. g. 2.0.5 Twoflower).
# http://bugs.python.org/issue14894
if LooseVersion(VERSION.split()[0]) < LooseVersion('1.1.0'):
is_vlc_available = False
log.debug('VLC could not be loaded, because the vlc version is too old: %s' % VERSION)
if is_vlc_available:
return vlc return vlc
else: #is_vlc_available = False
return None # try:
# if is_macosx():
# # Newer versions of VLC on OS X need this. See https://forum.videolan.org/viewtopic.php?t=124521
# os.environ['VLC_PLUGIN_PATH'] = '/Applications/VLC.app/Contents/MacOS/plugins'
# # On Windows when frozen in PyInstaller, we need to blank SetDllDirectoryW to allow loading of the VLC dll.
# # This is due to limitations (by design) in PyInstaller. SetDllDirectoryW original value is restored once
# # VLC has been imported.
# if is_win():
# buffer_size = 1024
# dll_directory = ctypes.create_unicode_buffer(buffer_size)
# new_buffer_size = ctypes.windll.kernel32.GetDllDirectoryW(buffer_size, dll_directory)
# dll_directory = ''.join(dll_directory[:new_buffer_size]).replace('\0', '')
# log.debug('Original DllDirectory: %s' % dll_directory)
# ctypes.windll.kernel32.SetDllDirectoryW(None)
# from openlp.core.ui.media.vendor import vlc
# if is_win():
# ctypes.windll.kernel32.SetDllDirectoryW(dll_directory)
# is_vlc_available = bool(vlc.get_default_instance())
# except (ImportError, NameError, NotImplementedError):
# pass
# except OSError as e:
# # this will get raised the first time
# if is_win():
# if not isinstance(e, WindowsError) and e.winerror != 126:
# raise
# else:
# pass
# if is_vlc_available:
# try:
# VERSION = vlc.libvlc_get_version().decode('UTF-8')
# except Exception:
# VERSION = '0.0.0'
# # LooseVersion does not work when a string contains letter and digits (e. g. 2.0.5 Twoflower).
# # http://bugs.python.org/issue14894
# if LooseVersion(VERSION.split()[0]) < LooseVersion('1.1.0'):
# is_vlc_available = False
# log.debug('VLC could not be loaded, because the vlc version is too old: %s' % VERSION)
#if is_vlc_available:
# return vlc
#else:
# return None
# On linux we need to initialise X threads, but not when running tests. # On linux we need to initialise X threads, but not when running tests.

View File

@ -89,7 +89,8 @@ MODULES = [
'webob', 'webob',
'requests', 'requests',
'qtawesome', 'qtawesome',
'pymediainfo' 'pymediainfo',
'vlc'
] ]