Module vlc :: Class Media
[hide private]
[frames] | no frames]

Class Media

source code

object --+    
         |    
    _Ctype --+
             |
            Media

Create a new Media instance.

Usage: Media(MRL, *options)

See vlc.Instance.media_new documentation for details.

Instance Methods [hide private]
 
get_instance(self) source code
 
add_options(self, *options)
Add a list of options to the media.
source code
 
tracks_get(self)
Get media descriptor's elementary streams description Note, you need to call parse() or play the media at least once before calling this function.
source code
 
add_option(self, psz_options)
Add an option to the media.
source code
 
add_option_flag(self, psz_options, i_flags)
Add an option to the media with configurable flags.
source code
 
retain(self)
Retain a reference to a media descriptor object (Media).
source code
 
release(self)
Decrement the reference count of a media descriptor object.
source code
 
get_mrl(self)
Get the media resource locator (mrl) from a media descriptor object.
source code
 
duplicate(self)
Duplicate a media descriptor object.
source code
 
get_meta(self, e_meta)
Read the meta of the media.
source code
 
set_meta(self, e_meta, psz_value)
Set the meta of the media (this function will not save the meta, call save_meta in order to save the meta).
source code
 
save_meta(self)
Save the meta previously set.
source code
 
get_state(self)
Get current state of media descriptor object.
source code
 
get_stats(self, p_stats)
Get the current statistics about the media.
source code
 
subitems(self)
Get subitems of media descriptor object.
source code
 
event_manager(self)
Decorator.
source code
 
get_duration(self)
Get duration (in ms) of media descriptor object item.
source code
 
parse_with_options(self, parse_flag, timeout)
Parse the media asynchronously with options.
source code
 
parse_stop(self)
Stop the parsing of the media When the media parsing is stopped, the libvlc_MediaParsedChanged event will be sent with the libvlc_media_parsed_status_timeout status.
source code
 
get_parsed_status(self)
Get Parsed status for media descriptor object.
source code
 
set_user_data(self, p_new_user_data)
Sets media descriptor's user_data.
source code
 
get_user_data(self)
Get media descriptor's user_data.
source code
 
get_type(self)
Get the media type of the media descriptor object.
source code
 
slaves_add(self, i_type, i_priority, psz_uri)
Add a slave to the current media.
source code
 
slaves_clear(self)
Clear all slaves previously added by slaves_add() or internally.
source code
 
slaves_get(self, ppp_slaves)
Get a media descriptor's slave list The list will contain slaves parsed by VLC or previously added by slaves_add().
source code
 
parse(self)
Parse a media.
source code
 
parse_async(self)
Parse a media.
source code
 
is_parsed(self)
Return true is the media descriptor object is parsed \deprecated This can return true in case of failure.
source code
 
get_tracks_info(self)
Get media descriptor's elementary streams description Note, you need to call parse() or play the media at least once before calling this function.
source code
 
player_new_from_media(self)
Create a Media Player object from a Media.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, *args) source code

Inherited from _Ctype: from_param

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(cls, *args)
Static Method

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

add_options(self, *options)

source code 

Add a list of options to the media.

Options must be written without the double-dash. Warning: most audio and video options, such as text renderer, have no effects on an individual media. These options must be set at the vlc.Instance or vlc.MediaPlayer instanciation.

Parameters:
  • options - optional media option=value strings

tracks_get(self)

source code 

Get media descriptor's elementary streams description Note, you need to call parse() or play the media at least once before calling this function. Not doing this will result in an empty array. The result must be freed with tracks_release.

Version: LibVLC 2.1.0 and later.

add_option(self, psz_options)

source code 

Add an option to the media. This option will be used to determine how the media_player will read the media. This allows to use VLC's advanced reading/streaming options on a per-media basis.

Parameters:
  • psz_options - the options (as a string).

Note: The options are listed in 'vlc --long-help' from the command line, e.g. "-sout-all". Keep in mind that available options and their semantics vary across LibVLC versions and builds.

Warning: Not all options affects Media objects: Specifically, due to architectural issues most audio and video options, such as text renderer options, have no effects on an individual media. These options must be set through new() instead.

add_option_flag(self, psz_options, i_flags)

source code 

Add an option to the media with configurable flags. This option will be used to determine how the media_player will read the media. This allows to use VLC's advanced reading/streaming options on a per-media basis. The options are detailed in vlc --long-help, for instance "--sout-all". Note that all options are not usable on medias: specifically, due to architectural issues, video-related options such as text renderer options cannot be set on a single media. They must be set on the whole libvlc instance instead.

Parameters:
  • psz_options - the options (as a string).
  • i_flags - the flags for this option.

retain(self)

source code 

Retain a reference to a media descriptor object (Media). Use release() to decrement the reference count of a media descriptor object.

release(self)

source code 

Decrement the reference count of a media descriptor object. If the reference count is 0, then release() will release the media descriptor object. It will send out an libvlc_MediaFreed event to all listeners. If the media descriptor object has been released it should not be used again.

get_mrl(self)

source code 

Get the media resource locator (mrl) from a media descriptor object.

Returns:
string with mrl of media descriptor object.

get_meta(self, e_meta)

source code 

Read the meta of the media. If the media has not yet been parsed this will return None. See parse See parse_with_options See libvlc_MediaMetaChanged.

Parameters:
  • e_meta - the meta to read.
Returns:
the media's meta.

set_meta(self, e_meta, psz_value)

source code 

Set the meta of the media (this function will not save the meta, call save_meta in order to save the meta).

Parameters:
  • e_meta - the meta to write.
  • psz_value - the media's meta.

save_meta(self)

source code 

Save the meta previously set.

Returns:
true if the write operation was successful.

get_state(self)

source code 

Get current state of media descriptor object. Possible media states are libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Playing, libvlc_Paused, libvlc_Stopped, libvlc_Ended, libvlc_Error. See State.

Returns:
state of media descriptor object.

get_stats(self, p_stats)

source code 

Get the current statistics about the media.

Parameters:
  • p_stats - : structure that contain the statistics about the media (this structure must be allocated by the caller).
Returns:
true if the statistics are available, false otherwise \libvlc_return_bool.

subitems(self)

source code 

Get subitems of media descriptor object. This will increment the reference count of supplied media descriptor object. Use list_release() to decrement the reference counting.

Returns:
list of media descriptor subitems or None.

event_manager(self)

source code 

Decorator. Caches a parameterless method's return value each time it is called.

If called later with the same arguments, the cached value is returned (not reevaluated). Adapted from https://wiki.python.org/moin/PythonDecoratorLibrary

Decorators:
  • @memoize_parameterless

get_duration(self)

source code 

Get duration (in ms) of media descriptor object item.

Returns:
duration of media item or -1 on error.

parse_with_options(self, parse_flag, timeout)

source code 

Parse the media asynchronously with options. This fetches (local or network) art, meta data and/or tracks information. This method is the extended version of parse_with_options(). To track when this is over you can listen to libvlc_MediaParsedChanged event. However if this functions returns an error, you will not receive any events. It uses a flag to specify parse options (see MediaParseFlag). All these flags can be combined. By default, media is parsed if it's a local file.

Parameters:
  • parse_flag - parse options:
  • timeout - maximum time allowed to preparse the media. If -1, the default "preparse-timeout" option will be used as a timeout. If 0, it will wait indefinitely. If > 0, the timeout will be used (in milliseconds).
Returns:
-1 in case of error, 0 otherwise.

Note: Parsing can be aborted with parse_stop(). See libvlc_MediaParsedChanged See get_meta See tracks_get See get_parsed_status See MediaParseFlag.

Version: LibVLC 3.0.0 or later.

parse_stop(self)

source code 

Stop the parsing of the media When the media parsing is stopped, the libvlc_MediaParsedChanged event will be sent with the libvlc_media_parsed_status_timeout status. See parse_with_options.

Version: LibVLC 3.0.0 or later.

get_parsed_status(self)

source code 

Get Parsed status for media descriptor object. See libvlc_MediaParsedChanged See MediaParsedStatus.

Returns:
a value of the MediaParsedStatus enum.

Version: LibVLC 3.0.0 or later.

set_user_data(self, p_new_user_data)

source code 

Sets media descriptor's user_data. user_data is specialized data accessed by the host application, VLC.framework uses it as a pointer to an native object that references a Media pointer.

Parameters:
  • p_new_user_data - pointer to user data.

get_user_data(self)

source code 

Get media descriptor's user_data. user_data is specialized data accessed by the host application, VLC.framework uses it as a pointer to an native object that references a Media pointer.

get_type(self)

source code 

Get the media type of the media descriptor object.

Returns:
media type.

Version: LibVLC 3.0.0 and later. See MediaType.

slaves_add(self, i_type, i_priority, psz_uri)

source code 

Add a slave to the current media. A slave is an external input source that may contains an additional subtitle track (like a .srt) or an additional audio track (like a .ac3).

Parameters:
  • i_type - subtitle or audio.
  • i_priority - from 0 (low priority) to 4 (high priority).
  • psz_uri - Uri of the slave (should contain a valid scheme).
Returns:
0 on success, -1 on error.

Note: This function must be called before the media is parsed (via parse_with_options()) or before the media is played (via player_play()).

Version: LibVLC 3.0.0 and later.

slaves_clear(self)

source code 

Clear all slaves previously added by slaves_add() or internally.

Version: LibVLC 3.0.0 and later.

slaves_get(self, ppp_slaves)

source code 

Get a media descriptor's slave list The list will contain slaves parsed by VLC or previously added by slaves_add(). The typical use case of this function is to save a list of slave in a database for a later use.

Parameters:
  • ppp_slaves - address to store an allocated array of slaves (must be freed with slaves_release()) [OUT].
Returns:
the number of slaves (zero on error).

Version: LibVLC 3.0.0 and later. See slaves_add.

parse(self)

source code 
Parse a media.
This fetches (local) art, meta data and tracks information.
The method is synchronous.
\deprecated This function could block indefinitely.
            Use L{parse_with_options}() instead
See L{parse_with_options}
See L{get_meta}
See L{get_tracks_info}.

parse_async(self)

source code 
Parse a media.
This fetches (local) art, meta data and tracks information.
The method is the asynchronous of L{parse}().
To track when this is over you can listen to libvlc_MediaParsedChanged
event. However if the media was already parsed you will not receive this
event.
\deprecated You can't be sure to receive the libvlc_MediaParsedChanged
            event (you can wait indefinitely for this event).
            Use L{parse_with_options}() instead
See L{parse}
See libvlc_MediaParsedChanged
See L{get_meta}
See L{get_tracks_info}.

is_parsed(self)

source code 
Return true is the media descriptor object is parsed
\deprecated This can return true in case of failure.
            Use L{get_parsed_status}() instead
See libvlc_MediaParsedChanged.
@return: true if media object has been parsed otherwise it returns false \libvlc_return_bool.

get_tracks_info(self)

source code 

Get media descriptor's elementary streams description Note, you need to call parse() or play the media at least once before calling this function. Not doing this will result in an empty array. \deprecated Use tracks_get() instead.

Parameters:
  • tracks - address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT].
Returns:
the number of Elementary Streams.

player_new_from_media(self)

source code 

Create a Media Player object from a Media.

Returns:
a new media player object, or None on error.