2011-07-10 21:43:07 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-04-13 13:00:22 +00:00
|
|
|
##########################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# ---------------------------------------------------------------------- #
|
2022-02-01 10:10:57 +00:00
|
|
|
# Copyright (c) 2008-2022 OpenLP Developers #
|
2019-04-13 13:00:22 +00:00
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# 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/>. #
|
|
|
|
##########################################################################
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
The :mod:`~openlp.core.ui.media.vlcplayer` module contains our VLC component wrapper
|
|
|
|
"""
|
2017-12-28 08:27:44 +00:00
|
|
|
import ctypes
|
2011-07-10 21:43:07 +00:00
|
|
|
import logging
|
2012-04-28 11:13:16 +00:00
|
|
|
import os
|
2015-03-18 22:04:30 +00:00
|
|
|
import sys
|
2017-12-28 08:27:44 +00:00
|
|
|
import threading
|
|
|
|
from datetime import datetime
|
2019-11-03 21:17:47 +00:00
|
|
|
from time import sleep
|
2017-12-28 08:27:44 +00:00
|
|
|
|
2019-09-21 04:56:43 +00:00
|
|
|
from PyQt5 import QtCore, QtWidgets
|
2012-04-28 11:13:16 +00:00
|
|
|
|
2018-10-02 04:39:42 +00:00
|
|
|
from openlp.core.common import is_linux, is_macosx, is_win
|
2020-02-04 20:35:35 +00:00
|
|
|
from openlp.core.common.i18n import translate
|
2019-09-21 04:56:43 +00:00
|
|
|
from openlp.core.display.screens import ScreenList
|
2020-02-04 20:35:35 +00:00
|
|
|
from openlp.core.lib.ui import critical_error_message_box
|
2014-03-04 22:33:50 +00:00
|
|
|
from openlp.core.ui.media import MediaState, MediaType
|
2012-09-09 06:06:44 +00:00
|
|
|
from openlp.core.ui.media.mediaplayer import MediaPlayer
|
2012-04-28 12:27:18 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2015-03-18 20:44:35 +00:00
|
|
|
# Audio and video extensions copied from 'include/vlc_interface.h' from vlc 2.2.0 source
|
2011-11-02 20:27:53 +00:00
|
|
|
|
|
|
|
|
2015-04-25 14:32:09 +00:00
|
|
|
def get_vlc():
|
|
|
|
"""
|
|
|
|
In order to make this module more testable, we have to wrap the VLC import inside a method. We do this so that we
|
|
|
|
can mock out the VLC module entirely.
|
|
|
|
|
|
|
|
:return: The "vlc" module, or None
|
|
|
|
"""
|
2019-06-06 20:10:39 +00:00
|
|
|
# Import the VLC module if not already done
|
|
|
|
if 'vlc' not in sys.modules:
|
2018-03-18 14:56:02 +00:00
|
|
|
try:
|
2019-06-09 20:22:43 +00:00
|
|
|
import vlc # noqa module is not used directly, but is used via sys.modules['vlc']
|
2019-06-10 20:44:24 +00:00
|
|
|
except (ImportError, OSError):
|
2018-03-18 14:56:02 +00:00
|
|
|
return None
|
2019-06-06 20:10:39 +00:00
|
|
|
# Verify that VLC is also loadable
|
|
|
|
is_vlc_available = False
|
|
|
|
try:
|
|
|
|
is_vlc_available = bool(sys.modules['vlc'].get_default_instance())
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
if is_vlc_available:
|
|
|
|
return sys.modules['vlc']
|
|
|
|
return None
|
2015-04-25 14:32:09 +00:00
|
|
|
|
|
|
|
|
2015-07-20 20:33:58 +00:00
|
|
|
# On linux we need to initialise X threads, but not when running tests.
|
|
|
|
# This needs to happen on module load and not in get_vlc(), otherwise it can cause crashes on some DE on some setups
|
|
|
|
# (reported on Gnome3, Unity, Cinnamon, all GTK+ based) when using native filedialogs...
|
2019-06-06 20:10:39 +00:00
|
|
|
if is_linux() and 'pytest' not in sys.argv[0] and get_vlc():
|
2015-07-20 20:33:58 +00:00
|
|
|
try:
|
2015-09-04 09:01:07 +00:00
|
|
|
try:
|
|
|
|
x11 = ctypes.cdll.LoadLibrary('libX11.so.6')
|
|
|
|
except OSError:
|
|
|
|
# If libx11.so.6 was not found, fallback to more generic libx11.so
|
|
|
|
x11 = ctypes.cdll.LoadLibrary('libX11.so')
|
2015-07-20 20:33:58 +00:00
|
|
|
x11.XInitThreads()
|
2018-10-27 01:40:20 +00:00
|
|
|
except Exception:
|
2015-07-20 20:33:58 +00:00
|
|
|
log.exception('Failed to run XInitThreads(), VLC might not work properly!')
|
|
|
|
|
|
|
|
|
2011-11-11 16:45:25 +00:00
|
|
|
class VlcPlayer(MediaPlayer):
|
2011-07-10 21:43:07 +00:00
|
|
|
"""
|
2013-07-18 14:19:01 +00:00
|
|
|
A specialised version of the MediaPlayer class, which provides a VLC display.
|
2011-07-10 21:43:07 +00:00
|
|
|
"""
|
2011-09-22 18:22:35 +00:00
|
|
|
|
2011-07-10 21:43:07 +00:00
|
|
|
def __init__(self, parent):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Constructor
|
|
|
|
"""
|
2013-08-31 18:17:38 +00:00
|
|
|
super(VlcPlayer, self).__init__(parent, 'vlc')
|
|
|
|
self.original_name = 'VLC'
|
|
|
|
self.display_name = '&VLC'
|
2011-07-10 21:43:07 +00:00
|
|
|
self.parent = parent
|
2013-03-06 23:00:57 +00:00
|
|
|
self.can_folder = True
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2020-05-18 18:00:40 +00:00
|
|
|
def setup(self, controller, display):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Set up the media player
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2021-08-28 07:04:15 +00:00
|
|
|
:param controller: The controller where the media is
|
|
|
|
:param display: The display where the media is.
|
2016-01-01 20:39:26 +00:00
|
|
|
:return:
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2015-04-25 14:32:09 +00:00
|
|
|
vlc = get_vlc()
|
2019-11-03 21:17:47 +00:00
|
|
|
if controller.is_live:
|
|
|
|
controller.vlc_widget = QtWidgets.QFrame()
|
|
|
|
controller.vlc_widget.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool |
|
|
|
|
QtCore.Qt.WindowStaysOnTopHint)
|
2019-09-21 04:56:43 +00:00
|
|
|
else:
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_widget = QtWidgets.QFrame(display)
|
|
|
|
controller.vlc_widget.setFrameStyle(QtWidgets.QFrame.NoFrame)
|
2011-07-10 21:43:07 +00:00
|
|
|
# creating a basic vlc instance
|
2021-04-28 06:19:47 +00:00
|
|
|
command_line_options = '--no-video-title-show --input-repeat=99999999 '
|
2020-05-18 18:00:40 +00:00
|
|
|
if self.settings.value('advanced/hide mouse') and controller.is_live:
|
2019-04-20 20:29:12 +00:00
|
|
|
command_line_options += '--mouse-hide-timeout=0 '
|
2020-01-12 21:03:40 +00:00
|
|
|
if self.settings.value('media/vlc arguments'):
|
2020-02-04 20:35:35 +00:00
|
|
|
options = command_line_options + ' ' + self.settings.value('media/vlc arguments')
|
|
|
|
controller.vlc_instance = vlc.Instance(options)
|
|
|
|
# if the instance is None, it is likely that the comamndline options were invalid, so try again without
|
|
|
|
if not controller.vlc_instance:
|
|
|
|
controller.vlc_instance = vlc.Instance(command_line_options)
|
|
|
|
if controller.vlc_instance:
|
|
|
|
critical_error_message_box(message=translate('MediaPlugin.VlcPlayer',
|
|
|
|
'The VLC arguments are invalid.'))
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
controller.vlc_instance = vlc.Instance(command_line_options)
|
|
|
|
if not controller.vlc_instance:
|
|
|
|
return
|
2021-09-12 08:28:58 +00:00
|
|
|
log.debug(f"VLC version: {vlc.libvlc_get_version()}")
|
2011-07-10 21:43:07 +00:00
|
|
|
# creating an empty vlc media player
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media_player = controller.vlc_instance.media_player_new()
|
|
|
|
controller.vlc_widget.resize(controller.size())
|
|
|
|
controller.vlc_widget.hide()
|
2012-10-27 14:52:51 +00:00
|
|
|
# The media player has to be 'connected' to the QFrame.
|
2011-07-10 21:43:07 +00:00
|
|
|
# (otherwise a video would be displayed in it's own window)
|
2012-10-27 14:52:51 +00:00
|
|
|
# This is platform specific!
|
|
|
|
# You have to give the id of the QFrame (or similar object)
|
|
|
|
# to vlc, different platforms have different functions for this.
|
2019-11-03 21:17:47 +00:00
|
|
|
win_id = int(controller.vlc_widget.winId())
|
2014-08-27 23:18:06 +00:00
|
|
|
if is_win():
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media_player.set_hwnd(win_id)
|
2014-08-27 23:18:06 +00:00
|
|
|
elif is_macosx():
|
2015-11-07 00:49:40 +00:00
|
|
|
# We have to use 'set_nsobject' since Qt5 on OSX uses Cocoa
|
2012-08-18 17:26:54 +00:00
|
|
|
# framework and not the old Carbon.
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media_player.set_nsobject(win_id)
|
2012-03-13 19:54:16 +00:00
|
|
|
else:
|
2015-04-28 14:01:09 +00:00
|
|
|
# for Linux/*BSD using the X Server
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media_player.set_xwindow(win_id)
|
2013-03-06 22:54:16 +00:00
|
|
|
self.has_own_widget = True
|
2011-07-10 21:43:07 +00:00
|
|
|
|
|
|
|
def check_available(self):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Return the availability of VLC
|
|
|
|
"""
|
2015-04-25 14:32:09 +00:00
|
|
|
return get_vlc() is not None
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2020-02-04 20:35:35 +00:00
|
|
|
def load(self, controller, output_display, file):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Load a video into VLC
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The controller where the media is
|
2019-03-24 07:53:19 +00:00
|
|
|
:param output_display: The display where the media is
|
2020-02-04 20:35:35 +00:00
|
|
|
:param file: file/stream to be played
|
2016-01-01 20:39:26 +00:00
|
|
|
:return:
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2020-02-04 20:35:35 +00:00
|
|
|
if not controller.vlc_instance:
|
|
|
|
return False
|
2015-04-25 14:32:09 +00:00
|
|
|
vlc = get_vlc()
|
2020-10-04 19:20:10 +00:00
|
|
|
log.debug('load video in VLC Controller')
|
2019-11-03 21:17:47 +00:00
|
|
|
path = None
|
2020-02-04 20:35:35 +00:00
|
|
|
if file and not controller.media_info.media_type == MediaType.Stream:
|
2019-06-11 19:48:34 +00:00
|
|
|
path = os.path.normcase(file)
|
2011-07-10 21:43:07 +00:00
|
|
|
# create the media
|
2019-11-03 21:17:47 +00:00
|
|
|
if controller.media_info.media_type == MediaType.CD:
|
2014-10-31 22:44:22 +00:00
|
|
|
if is_win():
|
|
|
|
path = '/' + path
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media = controller.vlc_instance.media_new_location('cdda://' + path)
|
|
|
|
controller.vlc_media_player.set_media(controller.vlc_media)
|
|
|
|
controller.vlc_media_player.play()
|
2014-05-23 13:39:25 +00:00
|
|
|
# Wait for media to start playing. In this case VLC actually returns an error.
|
2021-08-28 07:04:15 +00:00
|
|
|
self.media_state_wait(controller, vlc.State.Playing)
|
2014-05-23 13:39:25 +00:00
|
|
|
# If subitems exists, this is a CD
|
2019-11-03 21:17:47 +00:00
|
|
|
audio_cd_tracks = controller.vlc_media.subitems()
|
2014-05-23 13:39:25 +00:00
|
|
|
if not audio_cd_tracks or audio_cd_tracks.count() < 1:
|
|
|
|
return False
|
2021-08-28 07:04:15 +00:00
|
|
|
controller.vlc_media = audio_cd_tracks.item_at_index(int(controller.media_info.title_track))
|
2021-09-12 08:28:58 +00:00
|
|
|
if not controller.vlc_media:
|
|
|
|
return False
|
2021-08-28 07:04:15 +00:00
|
|
|
# VLC's start and stop time options work on seconds
|
|
|
|
controller.vlc_media.add_option(f"start-time={int(controller.media_info.start_time // 1000)}")
|
|
|
|
controller.vlc_media.add_option(f"stop-time={int(controller.media_info.end_time // 1000)}")
|
2021-09-12 08:28:58 +00:00
|
|
|
controller.vlc_media_player.set_media(controller.vlc_media)
|
|
|
|
elif controller.media_info.media_type == MediaType.DVD:
|
|
|
|
if is_win():
|
|
|
|
path = '/' + path
|
|
|
|
dvd_location = 'dvd://' + path + '#' + controller.media_info.title_track
|
|
|
|
controller.vlc_media = controller.vlc_instance.media_new_location(dvd_location)
|
|
|
|
log.debug(f"vlc dvd load: {dvd_location}")
|
|
|
|
controller.vlc_media.add_option(f"start-time={int(controller.media_info.start_time // 1000)}")
|
|
|
|
controller.vlc_media.add_option(f"stop-time={int(controller.media_info.end_time // 1000)}")
|
|
|
|
controller.vlc_media_player.set_media(controller.vlc_media)
|
|
|
|
controller.vlc_media_player.play()
|
|
|
|
# Wait for media to start playing. In this case VLC returns an error.
|
|
|
|
self.media_state_wait(controller, vlc.State.Playing)
|
|
|
|
if controller.media_info.audio_track > 0:
|
|
|
|
res = controller.vlc_media_player.audio_set_track(controller.media_info.audio_track)
|
|
|
|
log.debug('vlc play, audio_track set: ' + str(controller.media_info.audio_track) + ' ' + str(res))
|
|
|
|
if controller.media_info.subtitle_track > 0:
|
|
|
|
res = controller.vlc_media_player.video_set_spu(controller.media_info.subtitle_track)
|
|
|
|
log.debug('vlc play, subtitle_track set: ' + str(controller.media_info.subtitle_track) + ' ' + str(res))
|
2019-11-03 21:17:47 +00:00
|
|
|
elif controller.media_info.media_type == MediaType.Stream:
|
2020-02-04 20:35:35 +00:00
|
|
|
controller.vlc_media = controller.vlc_instance.media_new_location(file[0])
|
|
|
|
controller.vlc_media.add_options(file[1])
|
2021-09-12 08:28:58 +00:00
|
|
|
controller.vlc_media_player.set_media(controller.vlc_media)
|
2014-05-23 13:39:25 +00:00
|
|
|
else:
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media = controller.vlc_instance.media_new_path(path)
|
2021-09-12 08:28:58 +00:00
|
|
|
controller.vlc_media_player.set_media(controller.vlc_media)
|
|
|
|
controller.media_info.start_time = 0
|
|
|
|
controller.media_info.end_time = controller.media_info.length
|
2011-07-10 21:43:07 +00:00
|
|
|
# parse the metadata of the file
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media.parse()
|
2021-09-12 08:28:58 +00:00
|
|
|
controller.seek_slider.setMinimum(controller.media_info.start_time)
|
|
|
|
controller.seek_slider.setMaximum(controller.media_info.end_time)
|
2019-11-03 21:17:47 +00:00
|
|
|
self.volume(controller, controller.media_info.volume)
|
2011-07-10 21:43:07 +00:00
|
|
|
return True
|
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
def media_state_wait(self, controller, media_state):
|
2011-07-10 21:43:07 +00:00
|
|
|
"""
|
|
|
|
Wait for the video to change its state
|
2011-12-02 22:00:28 +00:00
|
|
|
Wait no longer than 60 seconds. (loading an iso file needs a long time)
|
2016-01-01 20:39:26 +00:00
|
|
|
|
|
|
|
:param media_state: The state of the playing media
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The controller where the media is
|
2016-01-01 20:39:26 +00:00
|
|
|
:return:
|
2011-07-10 21:43:07 +00:00
|
|
|
"""
|
2015-04-25 14:32:09 +00:00
|
|
|
vlc = get_vlc()
|
2011-07-10 21:43:07 +00:00
|
|
|
start = datetime.now()
|
2019-11-03 21:17:47 +00:00
|
|
|
while media_state != controller.vlc_media.get_state():
|
|
|
|
sleep(0.1)
|
|
|
|
if controller.vlc_media.get_state() == vlc.State.Error:
|
2011-07-10 21:43:07 +00:00
|
|
|
return False
|
2013-02-03 19:23:12 +00:00
|
|
|
self.application.process_events()
|
2011-12-02 22:00:28 +00:00
|
|
|
if (datetime.now() - start).seconds > 60:
|
2011-07-10 21:43:07 +00:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
def resize(self, controller):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Resize the player
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The display where the media is stored within the controller.
|
2016-01-01 20:39:26 +00:00
|
|
|
:return:
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2019-11-03 21:17:47 +00:00
|
|
|
if controller.is_live:
|
|
|
|
controller.vlc_widget.setGeometry(ScreenList().current.display_geometry)
|
2019-09-21 04:56:43 +00:00
|
|
|
else:
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_widget.resize(controller.preview_display.size())
|
2012-01-19 19:13:19 +00:00
|
|
|
|
2019-03-24 07:53:19 +00:00
|
|
|
def play(self, controller, output_display):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Play the current item
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2019-03-24 07:53:19 +00:00
|
|
|
:param controller: Which Controller is running the show.
|
|
|
|
:param output_display: The display where the media is
|
2016-01-01 20:39:26 +00:00
|
|
|
:return:
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2015-04-25 14:32:09 +00:00
|
|
|
vlc = get_vlc()
|
2021-09-12 08:28:58 +00:00
|
|
|
log.debug('vlc play, mediatype: ' + str(controller.media_info.media_type))
|
2019-11-03 21:17:47 +00:00
|
|
|
threading.Thread(target=controller.vlc_media_player.play).start()
|
|
|
|
if not self.media_state_wait(controller, vlc.State.Playing):
|
2011-08-29 19:55:58 +00:00
|
|
|
return False
|
2019-11-03 21:17:47 +00:00
|
|
|
self.volume(controller, controller.media_info.volume)
|
|
|
|
self.set_state(MediaState.Playing, controller)
|
2012-06-09 15:46:01 +00:00
|
|
|
return True
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
def pause(self, controller):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Pause the current item
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The controller which is managing the display
|
2016-01-01 20:39:26 +00:00
|
|
|
:return:
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2015-04-25 14:32:09 +00:00
|
|
|
vlc = get_vlc()
|
2019-11-03 21:17:47 +00:00
|
|
|
if controller.vlc_media.get_state() != vlc.State.Playing:
|
2011-07-18 21:25:10 +00:00
|
|
|
return
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media_player.pause()
|
|
|
|
if self.media_state_wait(controller, vlc.State.Paused):
|
|
|
|
self.set_state(MediaState.Paused, controller)
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
def stop(self, controller):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Stop the current item
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The controller where the media is
|
2016-01-01 20:39:26 +00:00
|
|
|
:return:
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2019-11-03 21:17:47 +00:00
|
|
|
threading.Thread(target=controller.vlc_media_player.stop).start()
|
|
|
|
self.set_state(MediaState.Stopped, controller)
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
def volume(self, controller, vol):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Set the volume
|
2016-01-01 20:39:26 +00:00
|
|
|
|
|
|
|
:param vol: The volume to be sets
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The controller where the media is
|
2016-01-01 20:39:26 +00:00
|
|
|
:return:
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media_player.audio_set_volume(vol)
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
def seek(self, controller, seek_value):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Go to a particular position
|
2016-01-01 20:39:26 +00:00
|
|
|
|
|
|
|
:param seek_value: The position of where a seek goes to
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The controller where the media is
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2019-11-03 21:17:47 +00:00
|
|
|
if controller.vlc_media_player.is_seekable():
|
|
|
|
controller.vlc_media_player.set_time(seek_value)
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
def reset(self, controller):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Reset the player
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The controller where the media is
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_media_player.stop()
|
|
|
|
self.set_state(MediaState.Off, controller)
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
def set_visible(self, controller, status):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Set the visibility
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2019-11-03 21:17:47 +00:00
|
|
|
:param controller: The controller where the media display is
|
2016-01-01 20:39:26 +00:00
|
|
|
:param status: The visibility status
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2019-11-03 21:17:47 +00:00
|
|
|
controller.vlc_widget.setVisible(status)
|
2011-07-10 21:43:07 +00:00
|
|
|
|
2019-03-24 07:53:19 +00:00
|
|
|
def update_ui(self, controller, output_display):
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
|
|
|
Update the UI
|
2016-01-01 20:39:26 +00:00
|
|
|
|
2019-03-24 07:53:19 +00:00
|
|
|
:param controller: Which Controller is running the show.
|
|
|
|
:param output_display: The display where the media is
|
2013-02-02 06:32:29 +00:00
|
|
|
"""
|
2013-03-23 07:28:24 +00:00
|
|
|
if not controller.seek_slider.isSliderDown():
|
|
|
|
controller.seek_slider.blockSignals(True)
|
2021-09-12 08:28:58 +00:00
|
|
|
controller.seek_slider.setSliderPosition(controller.vlc_media_player.get_time())
|
2013-03-23 07:28:24 +00:00
|
|
|
controller.seek_slider.blockSignals(False)
|