new version of vlc.py

This commit is contained in:
rimach 2011-12-03 00:45:05 +01:00
parent 2c225c19a0
commit 8412caf006
2 changed files with 259 additions and 235 deletions

View File

@ -47,18 +47,21 @@ import sys
from inspect import getargspec from inspect import getargspec
__version__ = "N/A" __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 # Internal guard to prevent internal classes to be directly
# instanciated.
_internal_guard = object()
def find_lib():
dll = None
plugin_path = None plugin_path = None
if sys.platform.startswith('linux'): if sys.platform.startswith('linux'):
p = find_library('vlc') p = find_library('vlc')
try: try:
dll = ctypes.CDLL(p) dll = ctypes.CDLL(p)
except OSError: # may fail except OSError: # may fail
dll = ctypes.CDLL('libvlc.so.5') dll = ctypes.CDLL('libvlc.so.5')
elif sys.platform.startswith('win'): elif sys.platform.startswith('win'):
p = find_library('libvlc.dll') p = find_library('libvlc.dll')
if p is None: if p is None:
@ -72,7 +75,6 @@ elif sys.platform.startswith('win'):
break break
except w.error: except w.error:
pass pass
del r, w
except ImportError: # no PyWin32 except ImportError: # no PyWin32
pass pass
if plugin_path is None: if plugin_path is None:
@ -95,7 +97,6 @@ elif sys.platform.startswith('win'):
else: else:
plugin_path = os.path.dirname(p) plugin_path = os.path.dirname(p)
dll = ctypes.CDLL(p) dll = ctypes.CDLL(p)
del p#, u
elif sys.platform.startswith('darwin'): elif sys.platform.startswith('darwin'):
# FIXME: should find a means to configure path # FIXME: should find a means to configure path
@ -108,11 +109,15 @@ elif sys.platform.startswith('darwin'):
plugin_path = d plugin_path = d
else: # hope, some PATH is set... else: # hope, some PATH is set...
dll = ctypes.CDLL('libvlc.dylib') dll = ctypes.CDLL('libvlc.dylib')
del d, p
else: else:
raise NotImplementedError('%s: %s not supported' % (sys.argv[0], sys.platform)) raise NotImplementedError('%s: %s not supported' % (sys.argv[0], sys.platform))
return (dll, plugin_path)
# plugin_path used on win32 and MacOS in override.py
dll, plugin_path = find_lib()
class VLCException(Exception): class VLCException(Exception):
"""Exception raised by libvlc methods. """Exception raised by libvlc methods.
""" """
@ -158,12 +163,12 @@ def _Cobject(cls, ctype):
o._as_parameter_ = ctype o._as_parameter_ = ctype
return o return o
def _Constructor(cls, ptr=None): def _Constructor(cls, ptr=_internal_guard):
"""(INTERNAL) New wrapper from ctypes. """(INTERNAL) New wrapper from ctypes.
""" """
if ptr is None: if ptr == _internal_guard:
raise VLCException('(INTERNAL) ctypes class.') raise VLCException("(INTERNAL) ctypes class. You should get references for this class through methods of the LibVLC API.")
if ptr == 0: if ptr is None or ptr == 0:
return None return None
return _Cobject(cls, ctypes.c_void_p(ptr)) return _Cobject(cls, ctypes.c_void_p(ptr))
@ -174,6 +179,8 @@ class _Ctype(object):
def from_param(this): # not self def from_param(this): # not self
"""(INTERNAL) ctypes parameter conversion method. """(INTERNAL) ctypes parameter conversion method.
""" """
if this is None:
return None
return this._as_parameter_ return this._as_parameter_
class ListPOINTER(object): class ListPOINTER(object):
@ -204,12 +211,14 @@ def class_result(classname):
"""Errcheck function. Returns a function that creates the specified class. """Errcheck function. Returns a function that creates the specified class.
""" """
def wrap_errcheck(result, func, arguments): def wrap_errcheck(result, func, arguments):
if result is None:
return None
return classname(result) return classname(result)
return wrap_errcheck return wrap_errcheck
# Generated enum types # # Generated enum types #
class _Enum(ctypes.c_ulong): class _Enum(ctypes.c_uint):
'''(INTERNAL) Base class '''(INTERNAL) Base class
''' '''
_enum_names_ = {} _enum_names_ = {}
@ -781,11 +790,9 @@ class EventManager(_Ctype):
_callback_handler = None _callback_handler = None
_callbacks = {} _callbacks = {}
def __new__(cls, ptr=None): def __new__(cls, ptr=_internal_guard):
if ptr is None: if ptr == _internal_guard:
raise VLCException("(INTERNAL) ctypes class.") raise VLCException("(INTERNAL) ctypes class.\nYou should get a reference to EventManager through the MediaPlayer.event_manager() method.")
if ptr == 0:
return None
return _Constructor(cls, ptr) return _Constructor(cls, ptr)
def event_attach(self, eventtype, callback, *args, **kwds): def event_attach(self, eventtype, callback, *args, **kwds):
@ -858,14 +865,13 @@ class Instance(_Ctype):
''' '''
def __new__(cls, *args): 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] i = args[0]
if i == 0:
return None
if isinstance(i, _Ints): if isinstance(i, _Ints):
return _Constructor(cls, i) return _Constructor(cls, i)
if len(args) == 1: elif isinstance(i, basestring):
if isinstance(i, basestring):
args = i.strip().split() args = i.strip().split()
elif isinstance(i, _Seqs): elif isinstance(i, _Seqs):
args = i args = i
@ -947,20 +953,14 @@ class Instance(_Ctype):
libvlc_audio_output_list_release(head) libvlc_audio_output_list_release(head)
return r 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): 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)) return module_description_list(libvlc_audio_filter_list_get(self))
def video_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)) 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) return libvlc_set_user_agent(self, name, http)
def get_log_verbosity(self): def get_log_verbosity(self):
'''Return the VLC messaging verbosity level. '''Always returns minus one.
@return: verbosity level for messages. This function is only provided for backward compatibility.
@return: always -1.
''' '''
return libvlc_get_log_verbosity(self) return libvlc_get_log_verbosity(self)
def set_log_verbosity(self, level): def set_log_verbosity(self, level):
'''Set the VLC messaging verbosity level. '''This function does nothing.
@param level: log level. It is only provided for backward compatibility.
@param level: ignored.
''' '''
return libvlc_set_log_verbosity(self, level) return libvlc_set_log_verbosity(self, level)
def log_open(self): def log_open(self):
'''Open a VLC message log instance. '''This function does nothing useful.
@return: log message instance or NULL on error. It is only provided for backward compatibility.
@return: an unique pointer or NULL on error.
''' '''
return libvlc_log_open(self) return libvlc_log_open(self)
@ -1324,7 +1327,7 @@ class Log(_Ctype):
''' '''
def __new__(cls, ptr=None): def __new__(cls, ptr=_internal_guard):
'''(INTERNAL) ctypes wrapper constructor. '''(INTERNAL) ctypes wrapper constructor.
''' '''
return _Constructor(cls, ptr) return _Constructor(cls, ptr)
@ -1337,13 +1340,14 @@ class Log(_Ctype):
def close(self): def close(self):
'''Close a VLC message log instance. '''Frees memory allocated by L{open}().
''' '''
return libvlc_log_close(self) return libvlc_log_close(self)
def count(self): def count(self):
'''Returns the number of messages in a log instance. '''Always returns zero.
@return: number of log messages, 0 if p_log is NULL. This function is only provided for backward compatibility.
@return: always zero.
''' '''
return libvlc_log_count(self) return libvlc_log_count(self)
@ -1351,15 +1355,15 @@ class Log(_Ctype):
return libvlc_log_count(self) return libvlc_log_count(self)
def clear(self): def clear(self):
'''Clear a log instance. '''This function does nothing.
All messages in the log are removed. The log should be cleared on a It is only provided for backward compatibility.
regular basis to avoid clogging.
''' '''
return libvlc_log_clear(self) return libvlc_log_clear(self)
def get_iterator(self): def get_iterator(self):
'''Allocate and returns a new iterator to messages in log. '''This function does nothing useful.
@return: log iterator object or NULL on error. 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) return libvlc_log_get_iterator(self)
@ -1368,7 +1372,7 @@ class LogIterator(_Ctype):
''' '''
def __new__(cls, ptr=None): def __new__(cls, ptr=_internal_guard):
'''(INTERNAL) ctypes wrapper constructor. '''(INTERNAL) ctypes wrapper constructor.
''' '''
return _Constructor(cls, ptr) return _Constructor(cls, ptr)
@ -1385,13 +1389,14 @@ class LogIterator(_Ctype):
def free(self): def free(self):
'''Release a previoulsy allocated iterator. '''Frees memory allocated by L{log_get_iterator}().
''' '''
return libvlc_log_iterator_free(self) return libvlc_log_iterator_free(self)
def has_next(self): def has_next(self):
'''Return whether log iterator has more messages. '''Always returns zero.
@return: true if iterator has more message objects, else false. This function is only provided for backward compatibility.
@return: always zero.
''' '''
return libvlc_log_iterator_has_next(self) return libvlc_log_iterator_has_next(self)
@ -1407,8 +1412,6 @@ class Media(_Ctype):
def __new__(cls, *args): def __new__(cls, *args):
if args: if args:
i = args[0] i = args[0]
if i == 0:
return None
if isinstance(i, _Ints): if isinstance(i, _Ints):
return _Constructor(cls, i) return _Constructor(cls, i)
if isinstance(i, Instance): if isinstance(i, Instance):
@ -1527,7 +1530,7 @@ class Media(_Ctype):
def get_stats(self, p_stats): def get_stats(self, p_stats):
'''Get the current statistics about the media. '''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). @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) return libvlc_media_get_stats(self, p_stats)
@ -1571,7 +1574,7 @@ class Media(_Ctype):
def is_parsed(self): def is_parsed(self):
'''Get Parsed status for media descriptor object. '''Get Parsed status for media descriptor object.
See libvlc_MediaParsedChanged. 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) return libvlc_media_is_parsed(self)
@ -1610,7 +1613,7 @@ class MediaDiscoverer(_Ctype):
'''N/A '''N/A
''' '''
def __new__(cls, ptr=None): def __new__(cls, ptr=_internal_guard):
'''(INTERNAL) ctypes wrapper constructor. '''(INTERNAL) ctypes wrapper constructor.
''' '''
return _Constructor(cls, ptr) return _Constructor(cls, ptr)
@ -1640,7 +1643,7 @@ class MediaDiscoverer(_Ctype):
def is_running(self): def is_running(self):
'''Query if media service discover object is running. '''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) return libvlc_media_discoverer_is_running(self)
@ -1648,7 +1651,7 @@ class MediaLibrary(_Ctype):
'''N/A '''N/A
''' '''
def __new__(cls, ptr=None): def __new__(cls, ptr=_internal_guard):
'''(INTERNAL) ctypes wrapper constructor. '''(INTERNAL) ctypes wrapper constructor.
''' '''
return _Constructor(cls, ptr) return _Constructor(cls, ptr)
@ -1690,8 +1693,6 @@ class MediaList(_Ctype):
def __new__(cls, *args): def __new__(cls, *args):
if args: if args:
i = args[0] i = args[0]
if i == 0:
return None
if isinstance(i, _Ints): if isinstance(i, _Ints):
return _Constructor(cls, i) return _Constructor(cls, i)
if isinstance(i, Instance): if isinstance(i, Instance):
@ -1714,12 +1715,6 @@ class MediaList(_Ctype):
mrl = (self.get_instance() or get_default_instance()).media_new(mrl) mrl = (self.get_instance() or get_default_instance()).media_new(mrl)
return libvlc_media_list_add_media(self, 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): def release(self):
'''Release media list created with L{new}(). '''Release media list created with L{new}().
@ -1752,7 +1747,7 @@ class MediaList(_Ctype):
The L{lock} should be held upon entering this function. The L{lock} should be held upon entering this function.
@param p_md: a media instance. @param p_md: a media instance.
@param i_pos: position in array where to insert. @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) 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. '''Find index position of List media instance in media list.
Warning: the function will return the first matched position. Warning: the function will return the first matched position.
The L{lock} should be held upon entering this function. The L{lock} should be held upon entering this function.
@param p_md: media list instance. @param p_md: media instance.
@return: position of media instance. @return: position of media instance or -1 if media not found.
''' '''
return libvlc_media_list_index_of_item(self, p_md) return libvlc_media_list_index_of_item(self, p_md)
def is_readonly(self): def is_readonly(self):
'''This indicates if this media list is read-only from a user point of view. '''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) return libvlc_media_list_is_readonly(self)
@ -1831,20 +1826,16 @@ class MediaListPlayer(_Ctype):
''' '''
def __new__(cls, *args): def __new__(cls, arg=None):
if len(args) == 1: if arg is None:
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:
i = get_default_instance() 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() return i.media_list_player_new()
def get_instance(self): def get_instance(self):
@ -1854,10 +1845,20 @@ class MediaListPlayer(_Ctype):
def release(self): 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) 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): def event_manager(self):
'''Return the event manager of this media_list_player. '''Return the event manager of this media_list_player.
@return: the event manager. @return: the event manager.
@ -1888,7 +1889,7 @@ class MediaListPlayer(_Ctype):
def is_playing(self): def is_playing(self):
'''Is media list playing? '''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) return libvlc_media_list_player_is_playing(self)
@ -1946,25 +1947,24 @@ class MediaPlayer(_Ctype):
'''Create a new MediaPlayer instance. '''Create a new MediaPlayer instance.
It may take as parameter either: It may take as parameter either:
- a string (media URI). In this case, a vlc.Instance will be created. - a string (media URI), options... In this case, a vlc.Instance will be created.
- a vlc.Instance - a vlc.Instance, a string (media URI), options...
''' '''
def __new__(cls, *args): def __new__(cls, *args):
if args: if len(args) == 1 and isinstance(args[0], _Ints):
i = args[0] return _Constructor(cls, args[0])
if i == 0:
return None
if isinstance(i, _Ints):
return _Constructor(cls, i)
if isinstance(i, Instance):
return i.media_player_new()
i = get_default_instance() if args and isinstance(args[0], Instance):
o = i.media_player_new() instance = args[0]
args = args[1:]
else:
instance = get_default_instance()
o = instance.media_player_new()
if args: if args:
o.set_media(i.media_new(*args)) # args[0] o.set_media(instance.media_new(*args))
return o return o
def get_instance(self): def get_instance(self):
@ -2109,7 +2109,7 @@ class MediaPlayer(_Ctype):
def is_playing(self): def is_playing(self):
'''is_playing. '''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) return libvlc_media_player_is_playing(self)
@ -2228,7 +2228,7 @@ class MediaPlayer(_Ctype):
'''Set decoded audio format. '''Set decoded audio format.
This only works in combination with libvlc_audio_set_callbacks(), This only works in combination with libvlc_audio_set_callbacks(),
and is mutually exclusive with libvlc_audio_set_format_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 rate: sample rate (expressed in Hz).
@param channels: channels count. @param channels: channels count.
@version: LibVLC 1.2.0 or later. @version: LibVLC 1.2.0 or later.
@ -2287,7 +2287,7 @@ class MediaPlayer(_Ctype):
def will_play(self): def will_play(self):
'''Is the player able to play. '''Is the player able to play.
@return: boolean. @return: boolean \libvlc_return_bool.
''' '''
return libvlc_media_player_will_play(self) return libvlc_media_player_will_play(self)
@ -2361,13 +2361,13 @@ class MediaPlayer(_Ctype):
def is_seekable(self): def is_seekable(self):
'''Is this media player seekable? '''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) return libvlc_media_player_is_seekable(self)
def can_pause(self): def can_pause(self):
'''Can this media player be paused? '''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) return libvlc_media_player_can_pause(self)
@ -2404,7 +2404,7 @@ class MediaPlayer(_Ctype):
def get_fullscreen(self): def get_fullscreen(self):
'''Get current fullscreen status. '''Get current fullscreen status.
@return: the fullscreen status (boolean). @return: the fullscreen status (boolean) \libvlc_return_bool.
''' '''
return libvlc_get_fullscreen(self) return libvlc_get_fullscreen(self)
@ -2425,7 +2425,7 @@ class MediaPlayer(_Ctype):
'''Enable or disable mouse click events handling. By default, those events are '''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 handled. This is needed for DVD menus to work, as well as a few video
filters such as "puzzle". 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. @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. @param on: true to handle mouse click events, false to ignore them.
''' '''
@ -2642,7 +2642,7 @@ class MediaPlayer(_Ctype):
'''Set the audio output. '''Set the audio output.
Change will be applied after stop and play. Change will be applied after stop and play.
@param psz_name: name of audio output, use psz_name of See L{AudioOutput}. @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) return libvlc_audio_output_set(self, psz_name)
@ -2673,7 +2673,7 @@ class MediaPlayer(_Ctype):
def audio_get_mute(self): def audio_get_mute(self):
'''Get current mute status. '''Get current mute status.
@return: the mute status (boolean). @return: the mute status (boolean) \libvlc_return_bool.
''' '''
return libvlc_audio_get_mute(self) return libvlc_audio_get_mute(self)
@ -2684,14 +2684,14 @@ class MediaPlayer(_Ctype):
return libvlc_audio_set_mute(self, status) return libvlc_audio_set_mute(self, status)
def audio_get_volume(self): def audio_get_volume(self):
'''Get current audio level. '''Get current software audio volume.
@return: the audio level (int). @return: the software volume in percents (0 = mute, 100 = nominal / 0dB).
''' '''
return libvlc_audio_get_volume(self) return libvlc_audio_get_volume(self)
def audio_set_volume(self, i_volume): def audio_set_volume(self, i_volume):
'''Set current audio level. '''Set current software audio volume.
@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. @return: 0 if the volume was set, -1 if it was out of range.
''' '''
return libvlc_audio_set_volume(self, i_volume) return libvlc_audio_set_volume(self, i_volume)
@ -2957,9 +2957,10 @@ def libvlc_event_type_name(event_type):
return f(event_type) return f(event_type)
def libvlc_get_log_verbosity(p_instance): def libvlc_get_log_verbosity(p_instance):
'''Return the VLC messaging verbosity level. '''Always returns minus one.
@param p_instance: libvlc instance. This function is only provided for backward compatibility.
@return: verbosity level for messages. @param p_instance: ignored.
@return: always -1.
''' '''
f = _Cfunctions.get('libvlc_get_log_verbosity', None) or \ f = _Cfunctions.get('libvlc_get_log_verbosity', None) or \
_Cfunction('libvlc_get_log_verbosity', ((1,),), None, _Cfunction('libvlc_get_log_verbosity', ((1,),), None,
@ -2970,9 +2971,10 @@ def libvlc_get_log_verbosity(p_instance):
return f(p_instance) return f(p_instance)
def libvlc_set_log_verbosity(p_instance, level): def libvlc_set_log_verbosity(p_instance, level):
'''Set the VLC messaging verbosity level. '''This function does nothing.
@param p_instance: libvlc log instance. It is only provided for backward compatibility.
@param level: log level. @param p_instance: ignored.
@param level: ignored.
''' '''
f = _Cfunctions.get('libvlc_set_log_verbosity', None) or \ f = _Cfunctions.get('libvlc_set_log_verbosity', None) or \
_Cfunction('libvlc_set_log_verbosity', ((1,), (1,),), None, _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) return f(p_instance, level)
def libvlc_log_open(p_instance): 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. @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 \ f = _Cfunctions.get('libvlc_log_open', None) or \
_Cfunction('libvlc_log_open', ((1,),), class_result(Log), _Cfunction('libvlc_log_open', ((1,),), class_result(Log),
@ -2996,7 +2999,7 @@ def libvlc_log_open(p_instance):
return f(p_instance) return f(p_instance)
def libvlc_log_close(p_log): 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. @param p_log: libvlc log instance or NULL.
''' '''
f = _Cfunctions.get('libvlc_log_close', None) or \ f = _Cfunctions.get('libvlc_log_close', None) or \
@ -3008,9 +3011,10 @@ def libvlc_log_close(p_log):
return f(p_log) return f(p_log)
def libvlc_log_count(p_log): def libvlc_log_count(p_log):
'''Returns the number of messages in a log instance. '''Always returns zero.
@param p_log: libvlc log instance or NULL. This function is only provided for backward compatibility.
@return: number of log messages, 0 if p_log is NULL. @param p_log: ignored.
@return: always zero.
''' '''
f = _Cfunctions.get('libvlc_log_count', None) or \ f = _Cfunctions.get('libvlc_log_count', None) or \
_Cfunction('libvlc_log_count', ((1,),), None, _Cfunction('libvlc_log_count', ((1,),), None,
@ -3021,10 +3025,9 @@ def libvlc_log_count(p_log):
return f(p_log) return f(p_log)
def libvlc_log_clear(p_log): def libvlc_log_clear(p_log):
'''Clear a log instance. '''This function does nothing.
All messages in the log are removed. The log should be cleared on a It is only provided for backward compatibility.
regular basis to avoid clogging. @param p_log: ignored.
@param p_log: libvlc log instance or NULL.
''' '''
f = _Cfunctions.get('libvlc_log_clear', None) or \ f = _Cfunctions.get('libvlc_log_clear', None) or \
_Cfunction('libvlc_log_clear', ((1,),), None, _Cfunction('libvlc_log_clear', ((1,),), None,
@ -3035,9 +3038,10 @@ def libvlc_log_clear(p_log):
return f(p_log) return f(p_log)
def libvlc_log_get_iterator(p_log): def libvlc_log_get_iterator(p_log):
'''Allocate and returns a new iterator to messages in log. '''This function does nothing useful.
@param p_log: libvlc log instance. It is only provided for backward compatibility.
@return: log iterator object or NULL on error. @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 \ f = _Cfunctions.get('libvlc_log_get_iterator', None) or \
_Cfunction('libvlc_log_get_iterator', ((1,),), class_result(LogIterator), _Cfunction('libvlc_log_get_iterator', ((1,),), class_result(LogIterator),
@ -3048,7 +3052,7 @@ def libvlc_log_get_iterator(p_log):
return f(p_log) return f(p_log)
def libvlc_log_iterator_free(p_iter): 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. @param p_iter: libvlc log iterator or NULL.
''' '''
f = _Cfunctions.get('libvlc_log_iterator_free', None) or \ f = _Cfunctions.get('libvlc_log_iterator_free', None) or \
@ -3060,9 +3064,10 @@ def libvlc_log_iterator_free(p_iter):
return f(p_iter) return f(p_iter)
def libvlc_log_iterator_has_next(p_iter): def libvlc_log_iterator_has_next(p_iter):
'''Return whether log iterator has more messages. '''Always returns zero.
@param p_iter: libvlc log iterator or NULL. This function is only provided for backward compatibility.
@return: true if iterator has more message objects, else false. @param p_iter: ignored.
@return: always zero.
''' '''
f = _Cfunctions.get('libvlc_log_iterator_has_next', None) or \ f = _Cfunctions.get('libvlc_log_iterator_has_next', None) or \
_Cfunction('libvlc_log_iterator_has_next', ((1,),), None, _Cfunction('libvlc_log_iterator_has_next', ((1,),), None,
@ -3073,11 +3078,11 @@ def libvlc_log_iterator_has_next(p_iter):
return f(p_iter) return f(p_iter)
def libvlc_log_iterator_next(p_iter, p_buffer): def libvlc_log_iterator_next(p_iter, p_buffer):
'''Return the next log message. '''Always returns NULL.
The message contents must not be freed. This function is only provided for backward compatibility.
@param p_iter: libvlc log iterator or NULL. @param p_iter: libvlc log iterator or NULL.
@param p_buffer: log buffer. @param p_buffer: ignored.
@return: log message object or NULL if none left. @return: always NULL.
''' '''
f = _Cfunctions.get('libvlc_log_iterator_next', None) or \ f = _Cfunctions.get('libvlc_log_iterator_next', None) or \
_Cfunction('libvlc_log_iterator_next', ((1,), (1,),), None, _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. '''Get the current statistics about the media.
@param p_md:: media descriptor object. @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). @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 \ f = _Cfunctions.get('libvlc_media_get_stats', None) or \
_Cfunction('libvlc_media_get_stats', ((1,), (1,),), None, _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. '''Get Parsed status for media descriptor object.
See libvlc_MediaParsedChanged. See libvlc_MediaParsedChanged.
@param p_md: media descriptor object. @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 \ f = _Cfunctions.get('libvlc_media_is_parsed', None) or \
_Cfunction('libvlc_media_is_parsed', ((1,),), None, _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): def libvlc_media_discoverer_is_running(p_mdis):
'''Query if media service discover object is running. '''Query if media service discover object is running.
@param p_mdis: media service discover object. @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 \ f = _Cfunctions.get('libvlc_media_discoverer_is_running', None) or \
_Cfunction('libvlc_media_discoverer_is_running', ((1,),), None, _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_ml: a media list instance.
@param p_md: a media instance. @param p_md: a media instance.
@param i_pos: position in array where to insert. @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 \ f = _Cfunctions.get('libvlc_media_list_insert_media', None) or \
_Cfunction('libvlc_media_list_insert_media', ((1,), (1,), (1,),), None, _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. Warning: the function will return the first matched position.
The L{libvlc_media_list_lock} should be held upon entering this function. The L{libvlc_media_list_lock} should be held upon entering this function.
@param p_ml: a media list instance. @param p_ml: a media list instance.
@param p_md: media list instance. @param p_md: media instance.
@return: position of media instance. @return: position of media instance or -1 if media not found.
''' '''
f = _Cfunctions.get('libvlc_media_list_index_of_item', None) or \ f = _Cfunctions.get('libvlc_media_list_index_of_item', None) or \
_Cfunction('libvlc_media_list_index_of_item', ((1,), (1,),), None, _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): def libvlc_media_list_is_readonly(p_ml):
'''This indicates if this media list is read-only from a user point of view. '''This indicates if this media list is read-only from a user point of view.
@param p_ml: media list instance. @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 \ f = _Cfunctions.get('libvlc_media_list_is_readonly', None) or \
_Cfunction('libvlc_media_list_is_readonly', ((1,),), None, _Cfunction('libvlc_media_list_is_readonly', ((1,),), None,
@ -3884,7 +3889,11 @@ def libvlc_media_list_player_new(p_instance):
return f(p_instance) return f(p_instance)
def libvlc_media_list_player_release(p_mlp): 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. @param p_mlp: media list player instance.
''' '''
f = _Cfunctions.get('libvlc_media_list_player_release', None) or \ 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 libvlc_media_list_player_release = f
return f(p_mlp) 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): def libvlc_media_list_player_event_manager(p_mlp):
'''Return the event manager of this media_list_player. '''Return the event manager of this media_list_player.
@param p_mlp: media list player instance. @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): def libvlc_media_list_player_is_playing(p_mlp):
'''Is media list playing? '''Is media list playing?
@param p_mlp: media list player instance. @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 \ f = _Cfunctions.get('libvlc_media_list_player_is_playing', None) or \
_Cfunction('libvlc_media_list_player_is_playing', ((1,),), None, _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): def libvlc_media_player_is_playing(p_mi):
'''is_playing. '''is_playing.
@param p_mi: the Media Player. @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 \ f = _Cfunctions.get('libvlc_media_player_is_playing', None) or \
_Cfunction('libvlc_media_player_is_playing', ((1,),), None, _Cfunction('libvlc_media_player_is_playing', ((1,),), None,
@ -4386,7 +4408,7 @@ def libvlc_audio_set_format(mp, format, rate, channels):
This only works in combination with libvlc_audio_set_callbacks(), This only works in combination with libvlc_audio_set_callbacks(),
and is mutually exclusive with libvlc_audio_set_format_callbacks(). and is mutually exclusive with libvlc_audio_set_format_callbacks().
@param mp: the media player. @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 rate: sample rate (expressed in Hz).
@param channels: channels count. @param channels: channels count.
@version: LibVLC 1.2.0 or later. @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): def libvlc_media_player_will_play(p_mi):
'''Is the player able to play. '''Is the player able to play.
@param p_mi: the Media Player. @param p_mi: the Media Player.
@return: boolean. @return: boolean \libvlc_return_bool.
''' '''
f = _Cfunctions.get('libvlc_media_player_will_play', None) or \ f = _Cfunctions.get('libvlc_media_player_will_play', None) or \
_Cfunction('libvlc_media_player_will_play', ((1,),), None, _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): def libvlc_media_player_is_seekable(p_mi):
'''Is this media player seekable? '''Is this media player seekable?
@param p_mi: the media player. @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 \ f = _Cfunctions.get('libvlc_media_player_is_seekable', None) or \
_Cfunction('libvlc_media_player_is_seekable', ((1,),), None, _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): def libvlc_media_player_can_pause(p_mi):
'''Can this media player be paused? '''Can this media player be paused?
@param p_mi: the media player. @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 \ f = _Cfunctions.get('libvlc_media_player_can_pause', None) or \
_Cfunction('libvlc_media_player_can_pause', ((1,),), None, _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): def libvlc_get_fullscreen(p_mi):
'''Get current fullscreen status. '''Get current fullscreen status.
@param p_mi: the media player. @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 \ f = _Cfunctions.get('libvlc_get_fullscreen', None) or \
_Cfunction('libvlc_get_fullscreen', ((1,),), None, _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 '''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 handled. This is needed for DVD menus to work, as well as a few video
filters such as "puzzle". 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. @warning: This function is only implemented for X11 and Win32 at the moment.
@param p_mi: the media player. @param p_mi: the media player.
@param on: true to handle mouse click events, false to ignore them. @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. Change will be applied after stop and play.
@param p_mi: media player. @param p_mi: media player.
@param psz_name: name of audio output, use psz_name of See L{AudioOutput}. @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 \ f = _Cfunctions.get('libvlc_audio_output_set', None) or \
_Cfunction('libvlc_audio_output_set', ((1,), (1,),), None, _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): def libvlc_audio_get_mute(p_mi):
'''Get current mute status. '''Get current mute status.
@param p_mi: media player. @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 \ f = _Cfunctions.get('libvlc_audio_get_mute', None) or \
_Cfunction('libvlc_audio_get_mute', ((1,),), None, _Cfunction('libvlc_audio_get_mute', ((1,),), None,
@ -5476,9 +5498,9 @@ def libvlc_audio_set_mute(p_mi, status):
return f(p_mi, status) return f(p_mi, status)
def libvlc_audio_get_volume(p_mi): def libvlc_audio_get_volume(p_mi):
'''Get current audio level. '''Get current software audio volume.
@param p_mi: media player. @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 \ f = _Cfunctions.get('libvlc_audio_get_volume', None) or \
_Cfunction('libvlc_audio_get_volume', ((1,),), None, _Cfunction('libvlc_audio_get_volume', ((1,),), None,
@ -5489,9 +5511,9 @@ def libvlc_audio_get_volume(p_mi):
return f(p_mi) return f(p_mi)
def libvlc_audio_set_volume(p_mi, i_volume): def libvlc_audio_set_volume(p_mi, i_volume):
'''Set current audio level. '''Set current software audio volume.
@param p_mi: media player. @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. @return: 0 if the volume was set, -1 if it was out of range.
''' '''
f = _Cfunctions.get('libvlc_audio_set_volume', None) or \ 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) return f(p_instance)
# 5 function(s) blacklisted: # 6 function(s) blacklisted:
# libvlc_audio_set_callbacks # libvlc_audio_set_callbacks
# libvlc_audio_set_format_callbacks # libvlc_audio_set_format_callbacks
# libvlc_audio_set_volume_callback
# libvlc_set_exit_handler # libvlc_set_exit_handler
# libvlc_video_set_callbacks # libvlc_video_set_callbacks
# libvlc_video_set_format_callbacks # libvlc_video_set_format_callbacks

View File

@ -297,11 +297,12 @@ class WebkitPlayer(MediaPlayer):
def load(self, display): def load(self, display):
log.debug(u'load vid in Webkit Controller') log.debug(u'load vid in Webkit Controller')
controller = display.controller controller = display.controller
if display.hasAudio: if display.hasAudio and not controller.media_info.is_background:
volume = controller.media_info.volume volume = controller.media_info.volume
vol = float(volume) / float(100) vol = float(volume) / float(100)
else: else:
vol = 0 vol = 0
print vol
path = controller.media_info.file_info.absoluteFilePath() path = controller.media_info.file_info.absoluteFilePath()
if controller.media_info.is_background: if controller.media_info.is_background:
loop = u'true' loop = u'true'