modules.core.player
Audio Player using GStreamer Command-Line Tools
A simple audio player that uses GStreamer command-line tools (gst-launch-1.0) for playback control.
Functions
|
Main function to handle command line arguments and play audio. |
|
Simple playback function for command-line compatibility. |
Classes
A GStreamer command-line based audio player with playback control. |
- class modules.core.player.AudioPlayer[source]
Bases:
object
A GStreamer command-line based audio player with playback control.
This class provides audio playback functionality using GStreamer’s command-line tools (gst-launch-1.0) including play, pause, stop, volume control, and looping capabilities. No PyGObject bindings required.
Initialize the AudioPlayer with command-line GStreamer support.
- Raises:
RuntimeError – If gst-launch-1.0 is not available.
- __init__()[source]
Initialize the AudioPlayer with command-line GStreamer support.
- Raises:
RuntimeError – If gst-launch-1.0 is not available.
- signal_handler(signum, frame)[source]
Handle termination signals gracefully.
- Parameters:
signum (int) – Signal number received.
frame – Current stack frame (unused).
- play()[source]
Start or resume playback.
- Returns:
True if playback started successfully, False otherwise.
- Return type:
- pause()[source]
Pause playback.
- Returns:
True if paused successfully, False otherwise.
- Return type:
- resume()[source]
Resume paused playback.
- Returns:
True if resumed successfully, False otherwise.
- Return type:
- get_volume()[source]
Get current volume level.
- Returns:
Current volume between 0.0 and 1.0.
- Return type:
- get_position()[source]
Get current playback position.
- Returns:
Current position in seconds.
- Return type:
- get_duration()[source]
Get total duration of the current audio file.
- Returns:
Total duration in seconds.
- Return type:
- get_repeat_count()[source]
Get number of times the current song has repeated.
- Returns:
Number of repeats completed.
- Return type:
- get_state()[source]
Get current player state information.
- Returns:
- Dictionary containing player state including:
is_playing (bool): Whether audio is currently playing
is_paused (bool): Whether audio is paused
current_file (str): Path to current file
position (float): Current position in seconds
duration (float): Total duration in seconds
volume (float): Current volume level
loop_mode (str): Current loop mode
repeat_count (int): Number of repeats completed
- Return type:
- modules.core.player.play_audio(filepath)[source]
Simple playback function for command-line compatibility.
- modules.core.player.main()[source]
Main function to handle command line arguments and play audio.
Parses command-line arguments and initiates appropriate playback mode (simple, interactive, or daemon).
Examples
- Simple playback:
python player.py /path/to/song.mp3
- Interactive mode with controls:
python player.py –interactive /path/to/song.mp3
- Daemon mode for external control:
python player.py –daemon /path/to/song.mp3
- Using test file:
python player.py ../../testing_files/test.mp3