forked from openlp/openlp
media.vendor.vlc has been removed and python3-vlc installed in its place.
bzr-revno: 2870
This commit is contained in:
commit
f7110c69a1
25
openlp/core/ui/media/vendor/__init__.py
vendored
25
openlp/core/ui/media/vendor/__init__.py
vendored
@ -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.
|
|
||||||
"""
|
|
8775
openlp/core/ui/media/vendor/vlc.py
vendored
8775
openlp/core/ui/media/vendor/vlc.py
vendored
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from distutils.version import LooseVersion
|
import vlc
|
||||||
|
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
|
|
||||||
@ -65,59 +65,19 @@ 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:
|
|
||||||
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:
|
else:
|
||||||
return None
|
return vlc
|
||||||
|
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -89,7 +89,8 @@ MODULES = [
|
|||||||
'webob',
|
'webob',
|
||||||
'requests',
|
'requests',
|
||||||
'qtawesome',
|
'qtawesome',
|
||||||
'pymediainfo'
|
'pymediainfo',
|
||||||
|
'vlc'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,21 +65,6 @@ class TestVLCPlayer(TestCase, TestMixin):
|
|||||||
# THEN: The extra environment variable should be there
|
# THEN: The extra environment variable should be there
|
||||||
assert 'openlp.core.ui.media.vendor.vlc' not in sys.modules
|
assert 'openlp.core.ui.media.vendor.vlc' not in sys.modules
|
||||||
|
|
||||||
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
|
|
||||||
def test_fix_vlc_22_plugin_path(self, mocked_is_macosx):
|
|
||||||
"""
|
|
||||||
Test that on OS X we set the VLC plugin path to fix a bug in the VLC module
|
|
||||||
"""
|
|
||||||
# GIVEN: We're on OS X and we don't have the VLC plugin path set
|
|
||||||
mocked_is_macosx.return_value = True
|
|
||||||
|
|
||||||
# WHEN: An checking if the player is available
|
|
||||||
get_vlc()
|
|
||||||
|
|
||||||
# THEN: The extra environment variable should be there
|
|
||||||
assert 'VLC_PLUGIN_PATH' in os.environ, 'The plugin path should be in the environment variables'
|
|
||||||
assert '/Applications/VLC.app/Contents/MacOS/plugins' == os.environ['VLC_PLUGIN_PATH']
|
|
||||||
|
|
||||||
@patch.dict(os.environ)
|
@patch.dict(os.environ)
|
||||||
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
|
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
|
||||||
def test_not_osx_fix_vlc_22_plugin_path(self, mocked_is_macosx):
|
def test_not_osx_fix_vlc_22_plugin_path(self, mocked_is_macosx):
|
||||||
|
Loading…
Reference in New Issue
Block a user