From 11acf005e2c19ea0c42085a855e51c463755a669 Mon Sep 17 00:00:00 2001 From: rimach Date: Fri, 2 Dec 2011 16:15:31 +0100 Subject: [PATCH 1/9] add empty line --- openlp/core/ui/media/vlcplayer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 2739ccd8b..24bc56b64 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -205,3 +205,4 @@ class VlcPlayer(MediaPlayer): if not controller.seekSlider.isSliderDown(): controller.seekSlider.setSliderPosition( \ display.vlcMediaPlayer.get_time()) + From 2c225c19a023946a84e8b9135bce45bca6dc7051 Mon Sep 17 00:00:00 2001 From: rimach Date: Fri, 2 Dec 2011 23:00:28 +0100 Subject: [PATCH 2/9] bugfixing --- openlp/core/ui/media/vlcplayer.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 24bc56b64..19f70ba28 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -30,9 +30,8 @@ import sys, os from datetime import datetime try: import vlc - if vlc.get_default_instance(): - vlc_available = True -except: + vlc_available = bool(vlc.get_default_instance()) +except ImportError: vlc_available = False from PyQt4 import QtCore, QtGui @@ -90,10 +89,14 @@ class VlcPlayer(MediaPlayer): def setup(self, display): display.vlcWidget = QtGui.QFrame(display) # creating a basic vlc instance - if display.hasAudio: - display.vlcInstance = vlc.Instance() - else: - display.vlcInstance = vlc.Instance('--no-audio') + command_line_options = u'--no-video-title-show' + if not display.hasAudio: + command_line_options += u' --no-audio --no-video-title-show' + if QtCore.QSettings().value(u'advanced/hide mouse', + QtCore.QVariant(False)).toBool() and \ + display.controller.isLive: + command_line_options += u' --mouse-hide-timeout=0' + display.vlcInstance = vlc.Instance(command_line_options) display.vlcInstance.set_log_verbosity(2) # creating an empty vlc media player display.vlcMediaPlayer = display.vlcInstance.media_player_new() @@ -135,14 +138,14 @@ class VlcPlayer(MediaPlayer): def media_state_wait(self, display, mediaState): """ Wait for the video to change its state - Wait no longer than 5 seconds. + Wait no longer than 60 seconds. (loading an iso file needs a long time) """ start = datetime.now() while not mediaState == display.vlcMedia.get_state(): if display.vlcMedia.get_state() == vlc.State.Error: return False Receiver.send_message(u'openlp_process_events') - if (datetime.now() - start).seconds > 50: + if (datetime.now() - start).seconds > 60: return False return True @@ -157,10 +160,10 @@ class VlcPlayer(MediaPlayer): display.vlcMediaPlayer.play() if self.media_state_wait(display, vlc.State.Playing): if start_time > 0: - self.seek(display, controller.media_info.start_time*1000) + self.seek(display, controller.media_info.start_time * 1000) controller.media_info.length = \ - int(display.vlcMediaPlayer.get_media().get_duration()/1000) - controller.seekSlider.setMaximum(controller.media_info.length*1000) + int(display.vlcMediaPlayer.get_media().get_duration() / 1000) + controller.seekSlider.setMaximum(controller.media_info.length * 1000) self.state = MediaState.Playing display.vlcWidget.raise_() return True @@ -199,7 +202,7 @@ class VlcPlayer(MediaPlayer): controller = display.controller if controller.media_info.end_time > 0: if display.vlcMediaPlayer.get_time() > \ - controller.media_info.end_time*1000: + controller.media_info.end_time * 1000: self.stop(display) self.set_visible(display, False) if not controller.seekSlider.isSliderDown(): From 8412caf006d0a338c438cc573b236a08590b9a40 Mon Sep 17 00:00:00 2001 From: rimach Date: Sat, 3 Dec 2011 00:45:05 +0100 Subject: [PATCH 3/9] new version of vlc.py --- openlp/core/ui/media/vlc.py | 491 ++++++++++++++------------- openlp/core/ui/media/webkitplayer.py | 3 +- 2 files changed, 259 insertions(+), 235 deletions(-) diff --git a/openlp/core/ui/media/vlc.py b/openlp/core/ui/media/vlc.py index 1b6510993..4d3fa2673 100644 --- a/openlp/core/ui/media/vlc.py +++ b/openlp/core/ui/media/vlc.py @@ -47,71 +47,76 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Wed May 18 15:32:47 2011" +build_date = "Tue Sep 13 17:50:18 2011" - # Used on win32 and MacOS in override.py -plugin_path = None +# Internal guard to prevent internal classes to be directly +# instanciated. +_internal_guard = object() -if sys.platform.startswith('linux'): - p = find_library('vlc') - try: - dll = ctypes.CDLL(p) - except OSError: # may fail - dll = ctypes.CDLL('libvlc.so.5') +def find_lib(): + dll = None + plugin_path = None + if sys.platform.startswith('linux'): + p = find_library('vlc') + try: + dll = ctypes.CDLL(p) + except OSError: # may fail + dll = ctypes.CDLL('libvlc.so.5') + elif sys.platform.startswith('win'): + p = find_library('libvlc.dll') + if p is None: + try: # some registry settings + import _winreg as w # leaner than win32api, win32con + for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER: + try: + r = w.OpenKey(r, 'Software\\VideoLAN\\VLC') + plugin_path, _ = w.QueryValueEx(r, 'InstallDir') + w.CloseKey(r) + break + except w.error: + pass + except ImportError: # no PyWin32 + pass + if plugin_path is None: + # try some standard locations. + for p in ('Program Files\\VideoLan\\', 'VideoLan\\', + 'Program Files\\', ''): + p = 'C:\\' + p + 'VLC\\libvlc.dll' + if os.path.exists(p): + plugin_path = os.path.dirname(p) + break + if plugin_path is not None: # try loading + p = os.getcwd() + os.chdir(plugin_path) + # if chdir failed, this will raise an exception + dll = ctypes.CDLL('libvlc.dll') + # restore cwd after dll has been loaded + os.chdir(p) + else: # may fail + dll = ctypes.CDLL('libvlc.dll') + else: + plugin_path = os.path.dirname(p) + dll = ctypes.CDLL(p) + + elif sys.platform.startswith('darwin'): + # FIXME: should find a means to configure path + d = '/Applications/VLC.app/Contents/MacOS/' + p = d + 'lib/libvlc.dylib' + if os.path.exists(p): + dll = ctypes.CDLL(p) + d += 'modules' + if os.path.isdir(d): + plugin_path = d + else: # hope, some PATH is set... + dll = ctypes.CDLL('libvlc.dylib') -elif sys.platform.startswith('win'): - p = find_library('libvlc.dll') - if p is None: - try: # some registry settings - import _winreg as w # leaner than win32api, win32con - for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER: - try: - r = w.OpenKey(r, 'Software\\VideoLAN\\VLC') - plugin_path, _ = w.QueryValueEx(r, 'InstallDir') - w.CloseKey(r) - break - except w.error: - pass - del r, w - except ImportError: # no PyWin32 - pass - if plugin_path is None: - # try some standard locations. - for p in ('Program Files\\VideoLan\\', 'VideoLan\\', - 'Program Files\\', ''): - p = 'C:\\' + p + 'VLC\\libvlc.dll' - if os.path.exists(p): - plugin_path = os.path.dirname(p) - break - if plugin_path is not None: # try loading - p = os.getcwd() - os.chdir(plugin_path) - # if chdir failed, this will raise an exception - dll = ctypes.CDLL('libvlc.dll') - # restore cwd after dll has been loaded - os.chdir(p) - else: # may fail - dll = ctypes.CDLL('libvlc.dll') else: - plugin_path = os.path.dirname(p) - dll = ctypes.CDLL(p) - del p#, u + raise NotImplementedError('%s: %s not supported' % (sys.argv[0], sys.platform)) -elif sys.platform.startswith('darwin'): - # FIXME: should find a means to configure path - d = '/Applications/VLC.app/Contents/MacOS/' - p = d + 'lib/libvlc.dylib' - if os.path.exists(p): - dll = ctypes.CDLL(p) - d += 'modules' - if os.path.isdir(d): - plugin_path = d - else: # hope, some PATH is set... - dll = ctypes.CDLL('libvlc.dylib') - del d, p + return (dll, plugin_path) -else: - raise NotImplementedError('%s: %s not supported' % (sys.argv[0], sys.platform)) +# plugin_path used on win32 and MacOS in override.py +dll, plugin_path = find_lib() class VLCException(Exception): """Exception raised by libvlc methods. @@ -158,12 +163,12 @@ def _Cobject(cls, ctype): o._as_parameter_ = ctype return o -def _Constructor(cls, ptr=None): +def _Constructor(cls, ptr=_internal_guard): """(INTERNAL) New wrapper from ctypes. """ - if ptr is None: - raise VLCException('(INTERNAL) ctypes class.') - if ptr == 0: + if ptr == _internal_guard: + raise VLCException("(INTERNAL) ctypes class. You should get references for this class through methods of the LibVLC API.") + if ptr is None or ptr == 0: return None return _Cobject(cls, ctypes.c_void_p(ptr)) @@ -174,6 +179,8 @@ class _Ctype(object): def from_param(this): # not self """(INTERNAL) ctypes parameter conversion method. """ + if this is None: + return None return this._as_parameter_ class ListPOINTER(object): @@ -204,12 +211,14 @@ def class_result(classname): """Errcheck function. Returns a function that creates the specified class. """ def wrap_errcheck(result, func, arguments): + if result is None: + return None return classname(result) return wrap_errcheck # Generated enum types # -class _Enum(ctypes.c_ulong): +class _Enum(ctypes.c_uint): '''(INTERNAL) Base class ''' _enum_names_ = {} @@ -775,17 +784,15 @@ class EventManager(_Ctype): @note: Only a single notification can be registered for each event type in an EventManager instance. - + ''' _callback_handler = None _callbacks = {} - def __new__(cls, ptr=None): - if ptr is None: - raise VLCException("(INTERNAL) ctypes class.") - if ptr == 0: - return None + def __new__(cls, ptr=_internal_guard): + if ptr == _internal_guard: + raise VLCException("(INTERNAL) ctypes class.\nYou should get a reference to EventManager through the MediaPlayer.event_manager() method.") return _Constructor(cls, ptr) def event_attach(self, eventtype, callback, *args, **kwds): @@ -854,23 +861,22 @@ class Instance(_Ctype): - a string - a list of strings as first parameters - the parameters given as the constructor parameters (must be strings) - + ''' def __new__(cls, *args): - if args: + if len(args) == 1: + # Only 1 arg. It is either a C pointer, or an arg string, + # or a tuple. i = args[0] - if i == 0: - return None if isinstance(i, _Ints): return _Constructor(cls, i) - if len(args) == 1: - if isinstance(i, basestring): - args = i.strip().split() - elif isinstance(i, _Seqs): - args = i - else: - raise VLCException('Instance %r' % (args,)) + elif isinstance(i, basestring): + args = i.strip().split() + elif isinstance(i, _Seqs): + args = i + else: + raise VLCException('Instance %r' % (args,)) if not args and plugin_path is not None: # no parameters passed, for win32 and MacOS, @@ -947,20 +953,14 @@ class Instance(_Ctype): libvlc_audio_output_list_release(head) return r - def module_description_list_get(self, capability ): - """Returns a list of modules matching a capability. - - """ - return module_description_list(libvlc_module_description_list_get(self, capability)) - def audio_filter_list_get(self): - """Returns a list of audio filters that are available. + """Returns a list of available audio filters. """ return module_description_list(libvlc_audio_filter_list_get(self)) def video_filter_list_get(self): - """Returns a list of video filters that are available. + """Returns a list of available video filters. """ return module_description_list(libvlc_video_filter_list_get(self)) @@ -1001,20 +1001,23 @@ class Instance(_Ctype): return libvlc_set_user_agent(self, name, http) def get_log_verbosity(self): - '''Return the VLC messaging verbosity level. - @return: verbosity level for messages. + '''Always returns minus one. + This function is only provided for backward compatibility. + @return: always -1. ''' return libvlc_get_log_verbosity(self) def set_log_verbosity(self, level): - '''Set the VLC messaging verbosity level. - @param level: log level. + '''This function does nothing. + It is only provided for backward compatibility. + @param level: ignored. ''' return libvlc_set_log_verbosity(self, level) def log_open(self): - '''Open a VLC message log instance. - @return: log message instance or NULL on error. + '''This function does nothing useful. + It is only provided for backward compatibility. + @return: an unique pointer or NULL on error. ''' return libvlc_log_open(self) @@ -1321,10 +1324,10 @@ class Instance(_Ctype): class Log(_Ctype): '''Create a new VLC log instance. - + ''' - def __new__(cls, ptr=None): + def __new__(cls, ptr=_internal_guard): '''(INTERNAL) ctypes wrapper constructor. ''' return _Constructor(cls, ptr) @@ -1337,13 +1340,14 @@ class Log(_Ctype): def close(self): - '''Close a VLC message log instance. + '''Frees memory allocated by L{open}(). ''' return libvlc_log_close(self) def count(self): - '''Returns the number of messages in a log instance. - @return: number of log messages, 0 if p_log is NULL. + '''Always returns zero. + This function is only provided for backward compatibility. + @return: always zero. ''' return libvlc_log_count(self) @@ -1351,24 +1355,24 @@ class Log(_Ctype): return libvlc_log_count(self) def clear(self): - '''Clear a log instance. - All messages in the log are removed. The log should be cleared on a - regular basis to avoid clogging. + '''This function does nothing. + It is only provided for backward compatibility. ''' return libvlc_log_clear(self) def get_iterator(self): - '''Allocate and returns a new iterator to messages in log. - @return: log iterator object or NULL on error. + '''This function does nothing useful. + It is only provided for backward compatibility. + @return: an unique pointer or NULL on error or if the parameter was NULL. ''' return libvlc_log_get_iterator(self) class LogIterator(_Ctype): '''Create a new VLC log iterator. - + ''' - def __new__(cls, ptr=None): + def __new__(cls, ptr=_internal_guard): '''(INTERNAL) ctypes wrapper constructor. ''' return _Constructor(cls, ptr) @@ -1385,30 +1389,29 @@ class LogIterator(_Ctype): def free(self): - '''Release a previoulsy allocated iterator. + '''Frees memory allocated by L{log_get_iterator}(). ''' return libvlc_log_iterator_free(self) def has_next(self): - '''Return whether log iterator has more messages. - @return: true if iterator has more message objects, else false. + '''Always returns zero. + This function is only provided for backward compatibility. + @return: always zero. ''' return libvlc_log_iterator_has_next(self) class Media(_Ctype): '''Create a new Media instance. - + Usage: Media(MRL, *options) See vlc.Instance.media_new documentation for details. - + ''' def __new__(cls, *args): if args: i = args[0] - if i == 0: - return None if isinstance(i, _Ints): return _Constructor(cls, i) if isinstance(i, Instance): @@ -1527,7 +1530,7 @@ class Media(_Ctype): def get_stats(self, p_stats): '''Get the current statistics about the media. @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller). - @return: true if the statistics are available, false otherwise. + @return: true if the statistics are available, false otherwise \libvlc_return_bool. ''' return libvlc_media_get_stats(self, p_stats) @@ -1571,7 +1574,7 @@ class Media(_Ctype): def is_parsed(self): '''Get Parsed status for media descriptor object. See libvlc_MediaParsedChanged. - @return: true if media object has been parsed otherwise it returns false. + @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool. ''' return libvlc_media_is_parsed(self) @@ -1610,7 +1613,7 @@ class MediaDiscoverer(_Ctype): '''N/A ''' - def __new__(cls, ptr=None): + def __new__(cls, ptr=_internal_guard): '''(INTERNAL) ctypes wrapper constructor. ''' return _Constructor(cls, ptr) @@ -1640,7 +1643,7 @@ class MediaDiscoverer(_Ctype): def is_running(self): '''Query if media service discover object is running. - @return: true if running, false if not. + @return: true if running, false if not \libvlc_return_bool. ''' return libvlc_media_discoverer_is_running(self) @@ -1648,7 +1651,7 @@ class MediaLibrary(_Ctype): '''N/A ''' - def __new__(cls, ptr=None): + def __new__(cls, ptr=_internal_guard): '''(INTERNAL) ctypes wrapper constructor. ''' return _Constructor(cls, ptr) @@ -1680,18 +1683,16 @@ class MediaLibrary(_Ctype): class MediaList(_Ctype): '''Create a new MediaList instance. - + Usage: MediaList(list_of_MRLs) See vlc.Instance.media_list_new documentation for details. - + ''' def __new__(cls, *args): if args: i = args[0] - if i == 0: - return None if isinstance(i, _Ints): return _Constructor(cls, i) if isinstance(i, Instance): @@ -1702,10 +1703,10 @@ class MediaList(_Ctype): def get_instance(self): return getattr(self, '_instance', None) - + def add_media(self, mrl): """Add media instance to media list. - + The L{lock} should be held upon entering this function. @param p_md: a media instance or a MRL. @return: 0 on success, -1 if the media list is read-only. @@ -1714,12 +1715,6 @@ class MediaList(_Ctype): mrl = (self.get_instance() or get_default_instance()).media_new(mrl) return libvlc_media_list_add_media(self, mrl) - def __len__(self): - return self.count() - - def __getitem__(self, i): - return self.item_at_index(i) - def release(self): '''Release media list created with L{new}(). @@ -1752,7 +1747,7 @@ class MediaList(_Ctype): The L{lock} should be held upon entering this function. @param p_md: a media instance. @param i_pos: position in array where to insert. - @return: 0 on success, -1 if the media list si read-only. + @return: 0 on success, -1 if the media list is read-only. ''' return libvlc_media_list_insert_media(self, p_md, i_pos) @@ -1793,14 +1788,14 @@ class MediaList(_Ctype): '''Find index position of List media instance in media list. Warning: the function will return the first matched position. The L{lock} should be held upon entering this function. - @param p_md: media list instance. - @return: position of media instance. + @param p_md: media instance. + @return: position of media instance or -1 if media not found. ''' return libvlc_media_list_index_of_item(self, p_md) def is_readonly(self): '''This indicates if this media list is read-only from a user point of view. - @return: 0 on readonly, 1 on readwrite. + @return: 1 on readonly, 0 on readwrite \libvlc_return_bool. ''' return libvlc_media_list_is_readonly(self) @@ -1828,23 +1823,19 @@ class MediaListPlayer(_Ctype): It may take as parameter either: - a vlc.Instance - nothing - + ''' - def __new__(cls, *args): - if len(args) == 1: - i = args[0] - if i == 0: - return None - if isinstance(i, _Ints): - return _Constructor(cls, i) - if isinstance(i, _Seqs): - args = i - - if args and isinstance(args[0], Instance): - i = args[0] - else: + def __new__(cls, arg=None): + if arg is None: i = get_default_instance() + elif isinstance(arg, Instance): + i = arg + elif isinstance(arg, _Ints): + return _Constructor(cls, arg) + else: + raise TypeError('MediaListPlayer %r' % (arg,)) + return i.media_list_player_new() def get_instance(self): @@ -1854,10 +1845,20 @@ class MediaListPlayer(_Ctype): def release(self): - '''Release media_list_player. + '''Release a media_list_player after use + Decrement the reference count of a media player object. If the + reference count is 0, then L{release}() will + release the media player object. If the media player object + has been released, then it should not be used again. ''' return libvlc_media_list_player_release(self) + def retain(self): + '''Retain a reference to a media player list object. Use + L{release}() to decrement reference count. + ''' + return libvlc_media_list_player_retain(self) + def event_manager(self): '''Return the event manager of this media_list_player. @return: the event manager. @@ -1888,7 +1889,7 @@ class MediaListPlayer(_Ctype): def is_playing(self): '''Is media list playing? - @return: true for playing and false for not playing. + @return: true for playing and false for not playing \libvlc_return_bool. ''' return libvlc_media_list_player_is_playing(self) @@ -1946,25 +1947,24 @@ class MediaPlayer(_Ctype): '''Create a new MediaPlayer instance. It may take as parameter either: - - a string (media URI). In this case, a vlc.Instance will be created. - - a vlc.Instance - + - a string (media URI), options... In this case, a vlc.Instance will be created. + - a vlc.Instance, a string (media URI), options... + ''' def __new__(cls, *args): - if args: - i = args[0] - if i == 0: - return None - if isinstance(i, _Ints): - return _Constructor(cls, i) - if isinstance(i, Instance): - return i.media_player_new() + if len(args) == 1 and isinstance(args[0], _Ints): + return _Constructor(cls, args[0]) + + if args and isinstance(args[0], Instance): + instance = args[0] + args = args[1:] + else: + instance = get_default_instance() - i = get_default_instance() - o = i.media_player_new() + o = instance.media_player_new() if args: - o.set_media(i.media_new(*args)) # args[0] + o.set_media(instance.media_new(*args)) return o def get_instance(self): @@ -2027,13 +2027,13 @@ class MediaPlayer(_Ctype): Specify where the media player should render its video output. If LibVLC was built without Win32/Win64 API output support, then this has no effects. - + @param drawable: windows handle of the drawable. """ if not isinstance(drawable, ctypes.c_void_p): drawable = ctypes.c_void_p(int(drawable)) libvlc_media_player_set_hwnd(self, drawable) - + def video_get_width(self, num=0): """Get the width of a video in pixels. @@ -2109,7 +2109,7 @@ class MediaPlayer(_Ctype): def is_playing(self): '''is_playing. - @return: 1 if the media player is playing, 0 otherwise. + @return: 1 if the media player is playing, 0 otherwise \libvlc_return_bool. ''' return libvlc_media_player_is_playing(self) @@ -2164,12 +2164,12 @@ class MediaPlayer(_Ctype): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. @@ -2228,7 +2228,7 @@ class MediaPlayer(_Ctype): '''Set decoded audio format. This only works in combination with libvlc_audio_set_callbacks(), and is mutually exclusive with libvlc_audio_set_format_callbacks(). - @param fourcc: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). + @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). @param rate: sample rate (expressed in Hz). @param channels: channels count. @version: LibVLC 1.2.0 or later. @@ -2287,7 +2287,7 @@ class MediaPlayer(_Ctype): def will_play(self): '''Is the player able to play. - @return: boolean. + @return: boolean \libvlc_return_bool. ''' return libvlc_media_player_will_play(self) @@ -2361,13 +2361,13 @@ class MediaPlayer(_Ctype): def is_seekable(self): '''Is this media player seekable? - @return: true if the media player can seek. + @return: true if the media player can seek \libvlc_return_bool. ''' return libvlc_media_player_is_seekable(self) def can_pause(self): '''Can this media player be paused? - @return: true if the media player can pause. + @return: true if the media player can pause \libvlc_return_bool. ''' return libvlc_media_player_can_pause(self) @@ -2404,7 +2404,7 @@ class MediaPlayer(_Ctype): def get_fullscreen(self): '''Get current fullscreen status. - @return: the fullscreen status (boolean). + @return: the fullscreen status (boolean) \libvlc_return_bool. ''' return libvlc_get_fullscreen(self) @@ -2425,7 +2425,7 @@ class MediaPlayer(_Ctype): '''Enable or disable mouse click events handling. By default, those events are handled. This is needed for DVD menus to work, as well as a few video filters such as "puzzle". - @note: See also L{video_set_key_input}(). + See L{video_set_key_input}(). @warning: This function is only implemented for X11 and Win32 at the moment. @param on: true to handle mouse click events, false to ignore them. ''' @@ -2642,7 +2642,7 @@ class MediaPlayer(_Ctype): '''Set the audio output. Change will be applied after stop and play. @param psz_name: name of audio output, use psz_name of See L{AudioOutput}. - @return: true if function succeded. + @return: 0 if function succeded, -1 on error. ''' return libvlc_audio_output_set(self, psz_name) @@ -2673,7 +2673,7 @@ class MediaPlayer(_Ctype): def audio_get_mute(self): '''Get current mute status. - @return: the mute status (boolean). + @return: the mute status (boolean) \libvlc_return_bool. ''' return libvlc_audio_get_mute(self) @@ -2684,14 +2684,14 @@ class MediaPlayer(_Ctype): return libvlc_audio_set_mute(self, status) def audio_get_volume(self): - '''Get current audio level. - @return: the audio level (int). + '''Get current software audio volume. + @return: the software volume in percents (0 = mute, 100 = nominal / 0dB). ''' return libvlc_audio_get_volume(self) def audio_set_volume(self, i_volume): - '''Set current audio level. - @param i_volume: the volume (int). + '''Set current software audio volume. + @param i_volume: the volume in percents (0 = mute, 100 = 0dB). @return: 0 if the volume was set, -1 if it was out of range. ''' return libvlc_audio_set_volume(self, i_volume) @@ -2957,9 +2957,10 @@ def libvlc_event_type_name(event_type): return f(event_type) def libvlc_get_log_verbosity(p_instance): - '''Return the VLC messaging verbosity level. - @param p_instance: libvlc instance. - @return: verbosity level for messages. + '''Always returns minus one. + This function is only provided for backward compatibility. + @param p_instance: ignored. + @return: always -1. ''' f = _Cfunctions.get('libvlc_get_log_verbosity', None) or \ _Cfunction('libvlc_get_log_verbosity', ((1,),), None, @@ -2970,9 +2971,10 @@ def libvlc_get_log_verbosity(p_instance): return f(p_instance) def libvlc_set_log_verbosity(p_instance, level): - '''Set the VLC messaging verbosity level. - @param p_instance: libvlc log instance. - @param level: log level. + '''This function does nothing. + It is only provided for backward compatibility. + @param p_instance: ignored. + @param level: ignored. ''' f = _Cfunctions.get('libvlc_set_log_verbosity', None) or \ _Cfunction('libvlc_set_log_verbosity', ((1,), (1,),), None, @@ -2983,9 +2985,10 @@ def libvlc_set_log_verbosity(p_instance, level): return f(p_instance, level) def libvlc_log_open(p_instance): - '''Open a VLC message log instance. + '''This function does nothing useful. + It is only provided for backward compatibility. @param p_instance: libvlc instance. - @return: log message instance or NULL on error. + @return: an unique pointer or NULL on error. ''' f = _Cfunctions.get('libvlc_log_open', None) or \ _Cfunction('libvlc_log_open', ((1,),), class_result(Log), @@ -2996,7 +2999,7 @@ def libvlc_log_open(p_instance): return f(p_instance) def libvlc_log_close(p_log): - '''Close a VLC message log instance. + '''Frees memory allocated by L{libvlc_log_open}(). @param p_log: libvlc log instance or NULL. ''' f = _Cfunctions.get('libvlc_log_close', None) or \ @@ -3008,9 +3011,10 @@ def libvlc_log_close(p_log): return f(p_log) def libvlc_log_count(p_log): - '''Returns the number of messages in a log instance. - @param p_log: libvlc log instance or NULL. - @return: number of log messages, 0 if p_log is NULL. + '''Always returns zero. + This function is only provided for backward compatibility. + @param p_log: ignored. + @return: always zero. ''' f = _Cfunctions.get('libvlc_log_count', None) or \ _Cfunction('libvlc_log_count', ((1,),), None, @@ -3021,10 +3025,9 @@ def libvlc_log_count(p_log): return f(p_log) def libvlc_log_clear(p_log): - '''Clear a log instance. - All messages in the log are removed. The log should be cleared on a - regular basis to avoid clogging. - @param p_log: libvlc log instance or NULL. + '''This function does nothing. + It is only provided for backward compatibility. + @param p_log: ignored. ''' f = _Cfunctions.get('libvlc_log_clear', None) or \ _Cfunction('libvlc_log_clear', ((1,),), None, @@ -3035,9 +3038,10 @@ def libvlc_log_clear(p_log): return f(p_log) def libvlc_log_get_iterator(p_log): - '''Allocate and returns a new iterator to messages in log. - @param p_log: libvlc log instance. - @return: log iterator object or NULL on error. + '''This function does nothing useful. + It is only provided for backward compatibility. + @param p_log: ignored. + @return: an unique pointer or NULL on error or if the parameter was NULL. ''' f = _Cfunctions.get('libvlc_log_get_iterator', None) or \ _Cfunction('libvlc_log_get_iterator', ((1,),), class_result(LogIterator), @@ -3048,7 +3052,7 @@ def libvlc_log_get_iterator(p_log): return f(p_log) def libvlc_log_iterator_free(p_iter): - '''Release a previoulsy allocated iterator. + '''Frees memory allocated by L{libvlc_log_get_iterator}(). @param p_iter: libvlc log iterator or NULL. ''' f = _Cfunctions.get('libvlc_log_iterator_free', None) or \ @@ -3060,9 +3064,10 @@ def libvlc_log_iterator_free(p_iter): return f(p_iter) def libvlc_log_iterator_has_next(p_iter): - '''Return whether log iterator has more messages. - @param p_iter: libvlc log iterator or NULL. - @return: true if iterator has more message objects, else false. + '''Always returns zero. + This function is only provided for backward compatibility. + @param p_iter: ignored. + @return: always zero. ''' f = _Cfunctions.get('libvlc_log_iterator_has_next', None) or \ _Cfunction('libvlc_log_iterator_has_next', ((1,),), None, @@ -3073,11 +3078,11 @@ def libvlc_log_iterator_has_next(p_iter): return f(p_iter) def libvlc_log_iterator_next(p_iter, p_buffer): - '''Return the next log message. - The message contents must not be freed. + '''Always returns NULL. + This function is only provided for backward compatibility. @param p_iter: libvlc log iterator or NULL. - @param p_buffer: log buffer. - @return: log message object or NULL if none left. + @param p_buffer: ignored. + @return: always NULL. ''' f = _Cfunctions.get('libvlc_log_iterator_next', None) or \ _Cfunction('libvlc_log_iterator_next', ((1,), (1,),), None, @@ -3379,7 +3384,7 @@ def libvlc_media_get_stats(p_md, p_stats): '''Get the current statistics about the media. @param p_md:: media descriptor object. @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller). - @return: true if the statistics are available, false otherwise. + @return: true if the statistics are available, false otherwise \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_get_stats', None) or \ _Cfunction('libvlc_media_get_stats', ((1,), (1,),), None, @@ -3458,7 +3463,7 @@ def libvlc_media_is_parsed(p_md): '''Get Parsed status for media descriptor object. See libvlc_MediaParsedChanged. @param p_md: media descriptor object. - @return: true if media object has been parsed otherwise it returns false. + @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_is_parsed', None) or \ _Cfunction('libvlc_media_is_parsed', ((1,),), None, @@ -3583,7 +3588,7 @@ def libvlc_media_discoverer_event_manager(p_mdis): def libvlc_media_discoverer_is_running(p_mdis): '''Query if media service discover object is running. @param p_mdis: media service discover object. - @return: true if running, false if not. + @return: true if running, false if not \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_discoverer_is_running', None) or \ _Cfunction('libvlc_media_discoverer_is_running', ((1,),), None, @@ -3748,7 +3753,7 @@ def libvlc_media_list_insert_media(p_ml, p_md, i_pos): @param p_ml: a media list instance. @param p_md: a media instance. @param i_pos: position in array where to insert. - @return: 0 on success, -1 if the media list si read-only. + @return: 0 on success, -1 if the media list is read-only. ''' f = _Cfunctions.get('libvlc_media_list_insert_media', None) or \ _Cfunction('libvlc_media_list_insert_media', ((1,), (1,), (1,),), None, @@ -3807,8 +3812,8 @@ def libvlc_media_list_index_of_item(p_ml, p_md): Warning: the function will return the first matched position. The L{libvlc_media_list_lock} should be held upon entering this function. @param p_ml: a media list instance. - @param p_md: media list instance. - @return: position of media instance. + @param p_md: media instance. + @return: position of media instance or -1 if media not found. ''' f = _Cfunctions.get('libvlc_media_list_index_of_item', None) or \ _Cfunction('libvlc_media_list_index_of_item', ((1,), (1,),), None, @@ -3821,7 +3826,7 @@ def libvlc_media_list_index_of_item(p_ml, p_md): def libvlc_media_list_is_readonly(p_ml): '''This indicates if this media list is read-only from a user point of view. @param p_ml: media list instance. - @return: 0 on readonly, 1 on readwrite. + @return: 1 on readonly, 0 on readwrite \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_list_is_readonly', None) or \ _Cfunction('libvlc_media_list_is_readonly', ((1,),), None, @@ -3884,7 +3889,11 @@ def libvlc_media_list_player_new(p_instance): return f(p_instance) def libvlc_media_list_player_release(p_mlp): - '''Release media_list_player. + '''Release a media_list_player after use + Decrement the reference count of a media player object. If the + reference count is 0, then L{libvlc_media_list_player_release}() will + release the media player object. If the media player object + has been released, then it should not be used again. @param p_mlp: media list player instance. ''' f = _Cfunctions.get('libvlc_media_list_player_release', None) or \ @@ -3895,6 +3904,19 @@ def libvlc_media_list_player_release(p_mlp): libvlc_media_list_player_release = f return f(p_mlp) +def libvlc_media_list_player_retain(p_mlp): + '''Retain a reference to a media player list object. Use + L{libvlc_media_list_player_release}() to decrement reference count. + @param p_mlp: media player list object. + ''' + f = _Cfunctions.get('libvlc_media_list_player_retain', None) or \ + _Cfunction('libvlc_media_list_player_retain', ((1,),), None, + None, MediaListPlayer) + if not __debug__: # i.e. python -O or -OO + global libvlc_media_list_player_retain + libvlc_media_list_player_retain = f + return f(p_mlp) + def libvlc_media_list_player_event_manager(p_mlp): '''Return the event manager of this media_list_player. @param p_mlp: media list player instance. @@ -3961,7 +3983,7 @@ def libvlc_media_list_player_pause(p_mlp): def libvlc_media_list_player_is_playing(p_mlp): '''Is media list playing? @param p_mlp: media list player instance. - @return: true for playing and false for not playing. + @return: true for playing and false for not playing \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_list_player_is_playing', None) or \ _Cfunction('libvlc_media_list_player_is_playing', ((1,),), None, @@ -4161,7 +4183,7 @@ def libvlc_media_player_event_manager(p_mi): def libvlc_media_player_is_playing(p_mi): '''is_playing. @param p_mi: the Media Player. - @return: 1 if the media player is playing, 0 otherwise. + @return: 1 if the media player is playing, 0 otherwise \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_player_is_playing', None) or \ _Cfunction('libvlc_media_player_is_playing', ((1,),), None, @@ -4257,12 +4279,12 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{libvlc_media_player_set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param p_mi: the Media Player. @@ -4386,7 +4408,7 @@ def libvlc_audio_set_format(mp, format, rate, channels): This only works in combination with libvlc_audio_set_callbacks(), and is mutually exclusive with libvlc_audio_set_format_callbacks(). @param mp: the media player. - @param fourcc: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). + @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). @param rate: sample rate (expressed in Hz). @param channels: channels count. @version: LibVLC 1.2.0 or later. @@ -4508,7 +4530,7 @@ def libvlc_media_player_get_chapter_count(p_mi): def libvlc_media_player_will_play(p_mi): '''Is the player able to play. @param p_mi: the Media Player. - @return: boolean. + @return: boolean \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_player_will_play', None) or \ _Cfunction('libvlc_media_player_will_play', ((1,),), None, @@ -4666,7 +4688,7 @@ def libvlc_media_player_has_vout(p_mi): def libvlc_media_player_is_seekable(p_mi): '''Is this media player seekable? @param p_mi: the media player. - @return: true if the media player can seek. + @return: true if the media player can seek \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_player_is_seekable', None) or \ _Cfunction('libvlc_media_player_is_seekable', ((1,),), None, @@ -4679,7 +4701,7 @@ def libvlc_media_player_is_seekable(p_mi): def libvlc_media_player_can_pause(p_mi): '''Can this media player be paused? @param p_mi: the media player. - @return: true if the media player can pause. + @return: true if the media player can pause \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_media_player_can_pause', None) or \ _Cfunction('libvlc_media_player_can_pause', ((1,),), None, @@ -4763,7 +4785,7 @@ def libvlc_set_fullscreen(p_mi, b_fullscreen): def libvlc_get_fullscreen(p_mi): '''Get current fullscreen status. @param p_mi: the media player. - @return: the fullscreen status (boolean). + @return: the fullscreen status (boolean) \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_get_fullscreen', None) or \ _Cfunction('libvlc_get_fullscreen', ((1,),), None, @@ -4797,7 +4819,7 @@ def libvlc_video_set_mouse_input(p_mi, on): '''Enable or disable mouse click events handling. By default, those events are handled. This is needed for DVD menus to work, as well as a few video filters such as "puzzle". - @note: See also L{libvlc_video_set_key_input}(). + See L{libvlc_video_set_key_input}(). @warning: This function is only implemented for X11 and Win32 at the moment. @param p_mi: the media player. @param on: true to handle mouse click events, false to ignore them. @@ -5341,7 +5363,7 @@ def libvlc_audio_output_set(p_mi, psz_name): Change will be applied after stop and play. @param p_mi: media player. @param psz_name: name of audio output, use psz_name of See L{AudioOutput}. - @return: true if function succeded. + @return: 0 if function succeded, -1 on error. ''' f = _Cfunctions.get('libvlc_audio_output_set', None) or \ _Cfunction('libvlc_audio_output_set', ((1,), (1,),), None, @@ -5452,7 +5474,7 @@ def libvlc_audio_toggle_mute(p_mi): def libvlc_audio_get_mute(p_mi): '''Get current mute status. @param p_mi: media player. - @return: the mute status (boolean). + @return: the mute status (boolean) \libvlc_return_bool. ''' f = _Cfunctions.get('libvlc_audio_get_mute', None) or \ _Cfunction('libvlc_audio_get_mute', ((1,),), None, @@ -5476,9 +5498,9 @@ def libvlc_audio_set_mute(p_mi, status): return f(p_mi, status) def libvlc_audio_get_volume(p_mi): - '''Get current audio level. + '''Get current software audio volume. @param p_mi: media player. - @return: the audio level (int). + @return: the software volume in percents (0 = mute, 100 = nominal / 0dB). ''' f = _Cfunctions.get('libvlc_audio_get_volume', None) or \ _Cfunction('libvlc_audio_get_volume', ((1,),), None, @@ -5489,9 +5511,9 @@ def libvlc_audio_get_volume(p_mi): return f(p_mi) def libvlc_audio_set_volume(p_mi, i_volume): - '''Set current audio level. + '''Set current software audio volume. @param p_mi: media player. - @param i_volume: the volume (int). + @param i_volume: the volume in percents (0 = mute, 100 = 0dB). @return: 0 if the volume was set, -1 if it was out of range. ''' f = _Cfunctions.get('libvlc_audio_set_volume', None) or \ @@ -5989,9 +6011,10 @@ def libvlc_vlm_get_event_manager(p_instance): return f(p_instance) -# 5 function(s) blacklisted: +# 6 function(s) blacklisted: # libvlc_audio_set_callbacks # libvlc_audio_set_format_callbacks +# libvlc_audio_set_volume_callback # libvlc_set_exit_handler # libvlc_video_set_callbacks # libvlc_video_set_format_callbacks diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 058f30f58..af1f5a876 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -297,11 +297,12 @@ class WebkitPlayer(MediaPlayer): def load(self, display): log.debug(u'load vid in Webkit Controller') controller = display.controller - if display.hasAudio: + if display.hasAudio and not controller.media_info.is_background: volume = controller.media_info.volume vol = float(volume) / float(100) else: vol = 0 + print vol path = controller.media_info.file_info.absoluteFilePath() if controller.media_info.is_background: loop = u'true' From 2df4a1903e5b2775fcbc3c25e959ed815b524685 Mon Sep 17 00:00:00 2001 From: rimach Date: Mon, 5 Dec 2011 19:48:32 +0100 Subject: [PATCH 4/9] bugfixing --- openlp/core/ui/media/mediacontroller.py | 8 ++++++-- openlp/core/ui/media/vlcplayer.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index c4e3e7fa9..c9e6e94a6 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -311,8 +311,12 @@ class MediaController(object): isValid = self.check_file_type(controller, display) display.override[u'theme'] = u'' display.override[u'video'] = True - controller.media_info.start_time = display.serviceItem.start_time - controller.media_info.end_time = display.serviceItem.end_time + if not controller.media_info.is_background: + controller.media_info.start_time = display.serviceItem.start_time + controller.media_info.end_time = display.serviceItem.end_time + else: + controller.media_info.start_time = 0 + controller.media_info.end_time = 0 elif controller.previewDisplay: display = controller.previewDisplay isValid = self.check_file_type(controller, display) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 19f70ba28..ae15f1901 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -31,7 +31,7 @@ from datetime import datetime try: import vlc vlc_available = bool(vlc.get_default_instance()) -except ImportError: +except (ImportError, WindowsError): vlc_available = False from PyQt4 import QtCore, QtGui From bb4f2fd1139a4c94a6b2ce3e24c1295f8d5d7a05 Mon Sep 17 00:00:00 2001 From: rimach Date: Tue, 6 Dec 2011 22:19:37 +0100 Subject: [PATCH 5/9] correct import check --- openlp/core/ui/media/mediacontroller.py | 8 ++------ openlp/core/ui/media/vlcplayer.py | 10 +++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index c9e6e94a6..c4e3e7fa9 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -311,12 +311,8 @@ class MediaController(object): isValid = self.check_file_type(controller, display) display.override[u'theme'] = u'' display.override[u'video'] = True - if not controller.media_info.is_background: - controller.media_info.start_time = display.serviceItem.start_time - controller.media_info.end_time = display.serviceItem.end_time - else: - controller.media_info.start_time = 0 - controller.media_info.end_time = 0 + controller.media_info.start_time = display.serviceItem.start_time + controller.media_info.end_time = display.serviceItem.end_time elif controller.previewDisplay: display = controller.previewDisplay isValid = self.check_file_type(controller, display) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index ae15f1901..836b82c95 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -31,8 +31,16 @@ from datetime import datetime try: import vlc vlc_available = bool(vlc.get_default_instance()) -except (ImportError, WindowsError): +except (ImportError, NameError): vlc_available = False +except OSError, e: + if sys.platform.startswith('win'): + if isinstance(e, WindowsError) and e.winerror == 126: + vlc_available = False + else: + raise + else: + raise from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver From f1bc18c33c48162ad3b5c8bbb356b5a27a6227bb Mon Sep 17 00:00:00 2001 From: rimach Date: Wed, 7 Dec 2011 21:20:23 +0100 Subject: [PATCH 6/9] remove print statement from webkitplayer.py --- openlp/core/ui/media/webkitplayer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index b2324c28e..abb5355d0 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -299,7 +299,6 @@ class WebkitPlayer(MediaPlayer): vol = float(volume) / float(100) else: vol = 0 - print vol path = controller.media_info.file_info.absoluteFilePath() if controller.media_info.is_background: loop = u'true' From 3e6d1e796242ce36b88aef7593c8b17af9c2a8cb Mon Sep 17 00:00:00 2001 From: rimach Date: Wed, 11 Jan 2012 21:51:11 +0100 Subject: [PATCH 7/9] update vlc code --- openlp/core/ui/media/mediacontroller.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 1a4b3a2cd..35635e43d 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -278,10 +278,21 @@ class MediaController(object): def set_controls_visible(self, controller, value): # Generic controls controller.mediabar.setVisible(value) + if controller.isLive and self.curDisplayMediaPlayer: + self.set_transparent_mode(controller, value) # Special controls: Here media type specific Controls will be enabled # (e.g. for DVD control, ...) # TODO + def set_transparent_mode(self, controller, value): + if value: + if self.curDisplayMediaPlayer[controller.display] != self.mediaPlayers[u'webkit']: + controller.display.setAttribute(QtCore.Qt.WA_NoSystemBackground, False) + else: + print "on" + controller.display.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) + controller.display.setAttribute(QtCore.Qt.WA_NoSystemBackground, True) + def resize(self, controller, display, player): """ After Mainwindow changes or Splitter moved all related media widgets @@ -481,6 +492,7 @@ class MediaController(object): Responds to the request to reset a loaded video """ log.debug(u'video_reset') + self.set_controls_visible(controller, False) for display in self.curDisplayMediaPlayer.keys(): if display.controller == controller: display.override = {} @@ -489,7 +501,6 @@ class MediaController(object): display.frame.evaluateJavaScript(u'show_video( \ "setBackBoard", null, null, null,"hidden");') del self.curDisplayMediaPlayer[display] - self.set_controls_visible(controller, False) def video_hide(self, msg): """ From edf4ac75c883f7965d274c62dc33b3ce7b70e2bd Mon Sep 17 00:00:00 2001 From: rimach Date: Thu, 12 Jan 2012 22:45:07 +0100 Subject: [PATCH 8/9] move phonon and vlc to own windows --- openlp/core/ui/media/mediacontroller.py | 17 ++++++--------- openlp/core/ui/media/phononplayer.py | 26 +++++++++++++++++++++-- openlp/core/ui/media/vlcplayer.py | 28 +++++++++++++++++++++---- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 35635e43d..dadd28dc6 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -278,21 +278,16 @@ class MediaController(object): def set_controls_visible(self, controller, value): # Generic controls controller.mediabar.setVisible(value) - if controller.isLive and self.curDisplayMediaPlayer: - self.set_transparent_mode(controller, value) # Special controls: Here media type specific Controls will be enabled # (e.g. for DVD control, ...) # TODO + # if controller.isLive and controller.display: + # if self.curDisplayMediaPlayer and value: + # if self.curDisplayMediaPlayer[controller.display] != self.mediaPlayers[u'webkit']: + # controller.display.setTransparency(False) + # else: + # controller.display.setTransparency(True) - def set_transparent_mode(self, controller, value): - if value: - if self.curDisplayMediaPlayer[controller.display] != self.mediaPlayers[u'webkit']: - controller.display.setAttribute(QtCore.Qt.WA_NoSystemBackground, False) - else: - print "on" - controller.display.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) - controller.display.setAttribute(QtCore.Qt.WA_NoSystemBackground, True) - def resize(self, controller, display, player): """ After Mainwindow changes or Splitter moved all related media widgets diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 5203c5960..7699a979d 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -30,6 +30,8 @@ import mimetypes from datetime import datetime from PyQt4.phonon import Phonon +from PyQt4 import QtCore +import sys from openlp.core.lib import Receiver from openlp.core.lib.mediaplayer import MediaPlayer @@ -63,6 +65,7 @@ class PhononPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'phonon') self.parent = parent + self.canBackground = True self.additional_extensions = ADDITIONAL_EXT mimetypes.init() for mimetype in Phonon.BackendCapabilities.availableMimeTypes(): @@ -93,7 +96,23 @@ class PhononPlayer(MediaPlayer): u' '.join(self.additional_extensions[mimetype]))) def setup(self, display): - display.phononWidget = Phonon.VideoWidget(display) + if display.isLive: + display.phononWidget = Phonon.VideoWidget() + windowFlags = QtCore.Qt.FramelessWindowHint + if QtCore.QSettings().value(u'advanced/x11 bypass wm', + QtCore.QVariant(True)).toBool(): + windowFlags = windowFlags | QtCore.Qt.X11BypassWindowManagerHint + # FIXME: QtCore.Qt.SplashScreen is workaround to make display screen + # stay always on top on Mac OS X. For details see bug 906926. + # It needs more investigation to fix it properly. + if sys.platform == 'darwin': + windowFlags = windowFlags | QtCore.Qt.SplashScreen + windowFlags = windowFlags | QtCore.Qt.Window + display.phononWidget.setWindowFlags(windowFlags) + display.phononWidget.setAttribute(QtCore.Qt.WA_DeleteOnClose) + display.phononWidget.setGeometry(display.geometry())#1280,0,1280,1024) + else: + display.phononWidget = Phonon.VideoWidget(display) display.phononWidget.resize(display.size()) display.mediaObject = Phonon.MediaObject(display) Phonon.createPath(display.mediaObject, display.phononWidget) @@ -153,7 +172,10 @@ class PhononPlayer(MediaPlayer): int(display.mediaObject.totalTime()/1000) controller.seekSlider.setMaximum(controller.media_info.length*1000) self.state = MediaState.Playing - display.phononWidget.raise_() + if not controller.media_info.is_background: + display.phononWidget.raise_() + else: + display.raise_() return True else: return False diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 2adf0a2d1..de9e3c20d 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -91,11 +91,28 @@ class VlcPlayer(MediaPlayer): MediaPlayer.__init__(self, parent, u'vlc') self.parent = parent self.canFolder = True + self.canBackground = True self.audio_extensions_list = AUDIO_EXT self.video_extensions_list = VIDEO_EXT def setup(self, display): - display.vlcWidget = QtGui.QFrame(display) + if display.isLive: + display.vlcWidget = QtGui.QFrame() + windowFlags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool + if QtCore.QSettings().value(u'advanced/x11 bypass wm', + QtCore.QVariant(True)).toBool(): + windowFlags = windowFlags | QtCore.Qt.X11BypassWindowManagerHint + # FIXME: QtCore.Qt.SplashScreen is workaround to make display screen + # stay always on top on Mac OS X. For details see bug 906926. + # It needs more investigation to fix it properly. + if sys.platform == 'darwin': + windowFlags = windowFlags | QtCore.Qt.SplashScreen + windowFlags = windowFlags | QtCore.Qt.Window + display.vlcWidget.setWindowFlags(windowFlags) + display.vlcWidget.setAttribute(QtCore.Qt.WA_DeleteOnClose) + display.vlcWidget.setGeometry(display.geometry()) + else: + display.vlcWidget = QtGui.QFrame(display) # creating a basic vlc instance command_line_options = u'--no-video-title-show' if not display.hasAudio: @@ -108,7 +125,7 @@ class VlcPlayer(MediaPlayer): display.vlcInstance.set_log_verbosity(2) # creating an empty vlc media player display.vlcMediaPlayer = display.vlcInstance.media_player_new() - display.vlcWidget.resize(display.size()) + #display.vlcWidget.resize(display.size()) display.vlcWidget.raise_() display.vlcWidget.hide() # the media player has to be 'connected' to the QFrame @@ -160,7 +177,7 @@ class VlcPlayer(MediaPlayer): def resize(self, display): display.vlcWidget.resize(display.size()) - + def play(self, display): controller = display.controller start_time = 0 @@ -174,7 +191,10 @@ class VlcPlayer(MediaPlayer): int(display.vlcMediaPlayer.get_media().get_duration() / 1000) controller.seekSlider.setMaximum(controller.media_info.length * 1000) self.state = MediaState.Playing - display.vlcWidget.raise_() + if not controller.media_info.is_background: + display.vlcWidget.raise_() + else: + display.raise_() return True else: return False From 88ce7a906d23389f91eb0cff579161a8958c0f56 Mon Sep 17 00:00:00 2001 From: rimach Date: Thu, 19 Jan 2012 20:13:19 +0100 Subject: [PATCH 9/9] reactivate vlc --- openlp/core/ui/maindisplay.py | 10 ++++++++- openlp/core/ui/media/mediacontroller.py | 12 +++++------ openlp/core/ui/media/phononplayer.py | 26 ++--------------------- openlp/core/ui/media/vlcplayer.py | 28 ++++--------------------- 4 files changed, 21 insertions(+), 55 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 8a43ccc36..971a9903f 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -144,7 +144,7 @@ class MainDisplay(Display): windowFlags = windowFlags | QtCore.Qt.SplashScreen self.setWindowFlags(windowFlags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) - self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) + self.setTransparency(True) if self.isLive: QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay) @@ -155,6 +155,14 @@ class MainDisplay(Display): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configChanged) + def setTransparency(self, enabled): + if enabled: + self.setAutoFillBackground(False) + else: + self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False) + self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled) + self.repaint() + def cssChanged(self): """ We may need to rebuild the CSS on the live display. diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index dadd28dc6..9c44f1693 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -278,15 +278,15 @@ class MediaController(object): def set_controls_visible(self, controller, value): # Generic controls controller.mediabar.setVisible(value) + if controller.isLive and controller.display: + if self.curDisplayMediaPlayer and value: + if self.curDisplayMediaPlayer[controller.display] != self.mediaPlayers[u'webkit']: + controller.display.setTransparency(False) + else: + controller.display.setTransparency(True) # Special controls: Here media type specific Controls will be enabled # (e.g. for DVD control, ...) # TODO - # if controller.isLive and controller.display: - # if self.curDisplayMediaPlayer and value: - # if self.curDisplayMediaPlayer[controller.display] != self.mediaPlayers[u'webkit']: - # controller.display.setTransparency(False) - # else: - # controller.display.setTransparency(True) def resize(self, controller, display, player): """ diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 7699a979d..457accbd9 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -30,8 +30,6 @@ import mimetypes from datetime import datetime from PyQt4.phonon import Phonon -from PyQt4 import QtCore -import sys from openlp.core.lib import Receiver from openlp.core.lib.mediaplayer import MediaPlayer @@ -65,7 +63,6 @@ class PhononPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'phonon') self.parent = parent - self.canBackground = True self.additional_extensions = ADDITIONAL_EXT mimetypes.init() for mimetype in Phonon.BackendCapabilities.availableMimeTypes(): @@ -96,23 +93,7 @@ class PhononPlayer(MediaPlayer): u' '.join(self.additional_extensions[mimetype]))) def setup(self, display): - if display.isLive: - display.phononWidget = Phonon.VideoWidget() - windowFlags = QtCore.Qt.FramelessWindowHint - if QtCore.QSettings().value(u'advanced/x11 bypass wm', - QtCore.QVariant(True)).toBool(): - windowFlags = windowFlags | QtCore.Qt.X11BypassWindowManagerHint - # FIXME: QtCore.Qt.SplashScreen is workaround to make display screen - # stay always on top on Mac OS X. For details see bug 906926. - # It needs more investigation to fix it properly. - if sys.platform == 'darwin': - windowFlags = windowFlags | QtCore.Qt.SplashScreen - windowFlags = windowFlags | QtCore.Qt.Window - display.phononWidget.setWindowFlags(windowFlags) - display.phononWidget.setAttribute(QtCore.Qt.WA_DeleteOnClose) - display.phononWidget.setGeometry(display.geometry())#1280,0,1280,1024) - else: - display.phononWidget = Phonon.VideoWidget(display) + display.phononWidget = Phonon.VideoWidget(display) display.phononWidget.resize(display.size()) display.mediaObject = Phonon.MediaObject(display) Phonon.createPath(display.mediaObject, display.phononWidget) @@ -172,10 +153,7 @@ class PhononPlayer(MediaPlayer): int(display.mediaObject.totalTime()/1000) controller.seekSlider.setMaximum(controller.media_info.length*1000) self.state = MediaState.Playing - if not controller.media_info.is_background: - display.phononWidget.raise_() - else: - display.raise_() + display.phononWidget.raise_() return True else: return False diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index de9e3c20d..2adf0a2d1 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -91,28 +91,11 @@ class VlcPlayer(MediaPlayer): MediaPlayer.__init__(self, parent, u'vlc') self.parent = parent self.canFolder = True - self.canBackground = True self.audio_extensions_list = AUDIO_EXT self.video_extensions_list = VIDEO_EXT def setup(self, display): - if display.isLive: - display.vlcWidget = QtGui.QFrame() - windowFlags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool - if QtCore.QSettings().value(u'advanced/x11 bypass wm', - QtCore.QVariant(True)).toBool(): - windowFlags = windowFlags | QtCore.Qt.X11BypassWindowManagerHint - # FIXME: QtCore.Qt.SplashScreen is workaround to make display screen - # stay always on top on Mac OS X. For details see bug 906926. - # It needs more investigation to fix it properly. - if sys.platform == 'darwin': - windowFlags = windowFlags | QtCore.Qt.SplashScreen - windowFlags = windowFlags | QtCore.Qt.Window - display.vlcWidget.setWindowFlags(windowFlags) - display.vlcWidget.setAttribute(QtCore.Qt.WA_DeleteOnClose) - display.vlcWidget.setGeometry(display.geometry()) - else: - display.vlcWidget = QtGui.QFrame(display) + display.vlcWidget = QtGui.QFrame(display) # creating a basic vlc instance command_line_options = u'--no-video-title-show' if not display.hasAudio: @@ -125,7 +108,7 @@ class VlcPlayer(MediaPlayer): display.vlcInstance.set_log_verbosity(2) # creating an empty vlc media player display.vlcMediaPlayer = display.vlcInstance.media_player_new() - #display.vlcWidget.resize(display.size()) + display.vlcWidget.resize(display.size()) display.vlcWidget.raise_() display.vlcWidget.hide() # the media player has to be 'connected' to the QFrame @@ -177,7 +160,7 @@ class VlcPlayer(MediaPlayer): def resize(self, display): display.vlcWidget.resize(display.size()) - + def play(self, display): controller = display.controller start_time = 0 @@ -191,10 +174,7 @@ class VlcPlayer(MediaPlayer): int(display.vlcMediaPlayer.get_media().get_duration() / 1000) controller.seekSlider.setMaximum(controller.media_info.length * 1000) self.state = MediaState.Playing - if not controller.media_info.is_background: - display.vlcWidget.raise_() - else: - display.raise_() + display.vlcWidget.raise_() return True else: return False