omxplayer API Docs¶
omxplayer.player¶
-
class
omxplayer.player.OMXPlayer(source, args=None, bus_address_finder=None, Connection=None, dbus_name=None, pause=False)[source]¶ Bases:
objectOMXPlayer controller
This works by speaking to OMXPlayer over DBus sending messages.
Parameters: - source (str) – Path to the file (as ~/Videos/my-video.mp4) or URL you wish to play
- args (list/str) – used to pass option parameters to omxplayer. see: https://github.com/popcornmix/omxplayer#synopsis
Multiple argument example:
>>> OMXPlayer('path.mp4', args=['--no-osd', '--no-keys', '-b']) >>> OMXPlayer('path.mp4', args='--no-osd --no-keys -b') >>> OMXPlayer('path.mp4', dbus_name='org.mpris.MediaPlayer2.omxplayer2')
-
action(code)[source]¶ Executes a keyboard command via a code
Parameters: code (int) – The key code you wish to emulate refer to keys.pyfor the possible keys
-
can_go_next()[source]¶ Returns: whether the player can move to the next item in the playlist Return type: bool
-
can_go_previous()[source]¶ Returns: - whether the player can move to the previous item in the
- playlist
Return type: bool
-
can_raise()[source]¶ Returns: whether the player can raise the display window atop of all other windows Return type: bool
-
exitEvent= None¶ Event called on exit
callback(player, exit_status)
-
get_filename()[source]¶ Returns: source currently playing Return type: str Deprecated since version 0.2.0: Use:
get_source()instead.
-
get_source()[source]¶ Get the source URI of the currently playing media
Returns: source currently playing Return type: str
-
list_audio()[source]¶ Returns: - A list of all known audio streams, each item is in the
- format:
<index>:<language>:<name>:<codec>:<active>
Return type: [str]
-
list_subtitles()[source]¶ Returns: - A list of all known subtitles, each item is in the
- format:
<index>:<language>:<name>:<codec>:<active>
Return type: [str]
-
list_video()[source]¶ Returns: - A list of all known video streams, each item is in the
- format:
<index>:<language>:<name>:<codec>:<active>
Return type: [str]
-
load(source, pause=False)[source]¶ Loads a new source (as a file) from
source(a file path or URL) by killing the currentomxplayerprocess and forking a new one.Parameters: source (string) – Path to the file to play or URL
-
maximum_rate()[source]¶ Returns: maximum playback rate (as proportion of normal rate) Return type: float
-
metadata()[source]¶ Returns: containing track information (‘URI’, ‘length’) Return type: dict Examples
>>> player.metadata() { 'mpris:length': 19691000, 'xesam:url': 'file:///home/name/path/to/media/file.mp4' }
-
minimum_rate()[source]¶ Returns: minimum playback rate (as proportion of normal rate) Return type: float
-
next()[source]¶ Skip to the next chapter
Returns: Whether the player skipped to the next chapter Return type: bool
-
pauseEvent= None¶ Event called on pause
callback(player)
-
playEvent= None¶ Event called on play
callback(player)
-
play_pause()[source]¶ Pause playback if currently playing, otherwise start playing if currently paused.
-
positionEvent= None¶ Event called on setting position
callback(player, absolute_position)
-
previous()[source]¶ Skip to the previous chapter
Returns: Whether the player skipped to the previous chapter Return type: bool
-
rate()[source]¶ Returns: playback rate, 1 is the normal rate, 2 would be double speed. Return type: float
-
seek(relative_position)[source]¶ Seek the video by relative_position seconds
Parameters: relative_position (float) – The position in seconds to seek to.
-
seekEvent= None¶ Event called on seek
callback(player, relative_position)
-
select_audio(index)[source]¶ Select audio stream specified by the index of the stream in
list_audioParameters: index (int) – index of audio stream returned by list_audio
-
select_subtitle(index)[source]¶ Enable a subtitle specified by the index it is listed in
list_subtitlesParameters: index (int) – index of subtitle listing returned by list_subtitles
-
set_alpha(alpha)[source]¶ Set the transparency of the video overlay
Parameters: alpha (float) – The transparency (0..255)
-
set_aspect_mode(mode)[source]¶ Set the aspect mode of the video
Parameters: mode (str) – One of (“letterbox” | “fill” | “stretch”)
-
set_position(position)[source]¶ Set the video to playback position to position seconds from the start of the video
Parameters: position (float) – The position in seconds.
-
set_rate(rate)[source]¶ Set the playback rate of the video as a multiple of the default playback speed
Examples
>>> player.set_rate(2) # Will play twice as fast as normal speed >>> player.set_rate(0.5) # Will play half speed
-
set_video_crop(x1, y1, x2, y2)[source]¶ Parameters: - x1 (int) – Top left x coordinate (px)
- y1 (int) – Top left y coordinate (px)
- x2 (int) – Bottom right x coordinate (px)
- y2 (int) – Bottom right y coordinate (px)
-
set_video_pos(x1, y1, x2, y2)[source]¶ Set the video position on the screen
Parameters: - x1 (int) – Top left x coordinate (px)
- y1 (int) – Top left y coordinate (px)
- x2 (int) – Bottom right x coordinate (px)
- y2 (int) – Bottom right y coordinate (px)
-
show_subtitles()[source]¶ Shows subtitles after
hide_subtitles
-
stopEvent= None¶ Event called on stop
callback(player)
-
supported_uri_schemes()[source]¶ Returns: list of supported URI schemes Return type: str Examples
>>> player.supported_uri_schemes() ["file", "http", "rtsp", "rtmp"]
omxplayer.bus_finder¶
omxplayer.dbus_connection¶
-
class
omxplayer.dbus_connection.DBusConnection(bus_address, dbus_name=None)[source]¶ Bases:
object-
proxy¶ The proxy object by which one interacts with a dbus object, this makes communicating with a similar to that of communicating with a POJO.
-
root_interface¶ org.mpris.MediaPlayer2 interface proxy object
-
player_interface¶ org.mpris.MediaPlayer2.Player interface proxy object
-
omxplayer.keys¶
-
omxplayer.keys.BLANK= 24¶
-
omxplayer.keys.DECREASE_SPEED= 1¶
-
omxplayer.keys.DECREASE_SUBTITLE_DELAY= 13¶
-
omxplayer.keys.DECREASE_VOLUME= 17¶
-
omxplayer.keys.EXIT= 15¶
-
omxplayer.keys.FAST_FORWARD= 4¶
-
omxplayer.keys.HIDE_SUBTITLES= 30¶
-
omxplayer.keys.HIDE_VIDEO= 28¶
-
omxplayer.keys.INCREASE_SPEED= 2¶
-
omxplayer.keys.INCREASE_SUBTITLE_DELAY= 14¶
-
omxplayer.keys.INCREASE_VOLUME= 18¶
-
omxplayer.keys.MOVE_VIDEO= 27¶
-
omxplayer.keys.NEXT_AUDIO= 7¶
-
omxplayer.keys.NEXT_CHAPTER= 9¶
-
omxplayer.keys.NEXT_SUBTITLE= 11¶
-
omxplayer.keys.PAUSE= 16¶
-
omxplayer.keys.PREVIOUS_AUDIO= 6¶
-
omxplayer.keys.PREVIOUS_CHAPTER= 8¶
-
omxplayer.keys.PREVIOUS_SUBTITLE= 10¶
-
omxplayer.keys.REWIND= 3¶
-
omxplayer.keys.SEEK_ABSOLUTE= 26¶
-
omxplayer.keys.SEEK_BACK_LARGE= 21¶
-
omxplayer.keys.SEEK_BACK_SMALL= 19¶
-
omxplayer.keys.SEEK_FORWARD_LARGE= 22¶
-
omxplayer.keys.SEEK_FORWARD_SMALL= 20¶
-
omxplayer.keys.SEEK_RELATIVE= 25¶
-
omxplayer.keys.SET_ALPHA= 32¶
-
omxplayer.keys.SHOW_INFO= 5¶
-
omxplayer.keys.SHOW_SUBTITLES= 31¶
-
omxplayer.keys.STEP= 23¶
-
omxplayer.keys.TOGGLE_SUBTITLE= 12¶
-
omxplayer.keys.UNHIDE_VIDEO= 29¶