PyAIMP documentation¶
Welcome! This documentation is about PyAIMP, a Python AIMP remote API wrapper with some extras.
PyAIMP comes as a simple Python module that covers the main features of the AIMP remote API features with the help of pywin32 (the only dependency).
Prerequisites¶
Python 3.5+
AIMP
Installation¶
The usual way:
$ pip install pyaimp
The McGyver way, after cloning/downloading this repo:
$ python setup.py install
Usage¶
Create a pyaimp.Client
instance and you are ready to use any of its public methods.
Example displaying the current playback state:
import pyaimp
try:
client = pyaimp.Client()
state = client.get_playback_state()
if state == pyaimp.PlayBackState.Stopped:
print('AIMP actually doesn\'t play anything')
elif state == pyaimp.PlayBackState.Paused:
print('AIMP is taking a break')
elif state == pyaimp.PlayBackState.Playing:
print('Rock \'n Roll baby')
except RuntimeError as re: # AIMP instance not found
print(re)
except Exception as e:
print(e)
Continue reading to know about what you can do.
Note
AIMP events aren’t supported.
The album image retrieving isn’t supported, too. I tried, but it’s way too hard/tricky to implement.
API docs¶
- class pyaimp.Client¶
Main class of the
pyaimp
module which is the wrapper around the AIMP remote API.When a new instance of this class is created, it will search for the current AIMP window handle using
pyaimp.Client.detect_aimp()
. If none are found, aRuntimeError
exception will be raised.Note
Consider all methods in this class to be blocking and non-thread safe.
- Raises
RuntimeError – The AIMP window cannot be found.
- add_dirs_to_playlist(dir)¶
CLI
/DIR
command: Add folder(s) to the playlist.Whether playing of added the files starts depends on the player settings.
- add_files_to_playlist(file)¶
CLI
/FILE
command: Add file(s) to the playlist.Whether playing of added the files starts depends on the player settings.
- add_to_active_playlist(obj)¶
CLI
/INSERT
command: Add objects to the active playlist.Whether playing of added the files starts depends on the player settings.
- add_to_active_playlist_custom(obj)¶
CLI
/QUEUE
command: Add objects to the active playlist and put them in custom playback queue.
- add_to_bookmarks(obj)¶
CLI
/BOOKMARK
command: Add files and/or folders to your bookmarks.
- add_to_playlist_and_play(obj)¶
CLI
/ADD_PLAY
command: Add objects to a playlist and start playing.
- detect_aimp()¶
Detect the AIMP window handler and the full path to its executable, which are required in order to be able to remote control AIMP.
This method is automatically called for you when creating a new instance of this class.
This method may be useful for you when AIMP is closed, then restarted for any reason. You’ll need to call it to retrieve the newly created AIMP window handler or you won’t be able to use the same instance anymore.
There isn’t anything returned because it defines internal attributes.
- Raises
RuntimeError – The AIMP window cannot be found.
- Return type
- get_current_track_info()¶
Return a dictionary of information about the current active track.
Dictionary keys are:
bit_rate
(int
): Audio bit ratechannels
(int
): Number of audio channelsduration
(int
): Duration of the track, in milliseconds.0
if unknown or none (i.e a stream)file_size
(int
): Size of the file, in bytes.0
if unknown or none (i.e a stream)file_mark
(int
): Unknowntrack_number
(int
): Track number (as stored in the audio tags).0
if unknownsample_rate
(int
): Audio sample ratealbum
(str
): Album name or an empty string if noneartist
(str
): Artist name or an empty string if unknownyear
(int
): Track year or an empty string if unknownfilename
(str
): Path to the track or URL to the streamgenre
(str
): Track genre or an empty string if unknowntitle
(str
): Track title or an empty string if unknown
- Return type
- get_playback_state()¶
Return the current playback state. The returned value is equal to one of the
pyaimp.PlayBackState
enumeration.- Return type
pyaimp.PlayBackState.Stopped or pyaimp.PlayBackState.Paused or pyaimp.PlayBackState.Playing
- get_player_position()¶
Return the current player position as the number of elapsed milliseconds since the beginning of the track.
- Return type
- get_version()¶
Return the AIMP version as a tuple containing the major version and the build number, e.g
('4.12', 1878)
.- Return type
- is_visualization_fullscreen()¶
Return whether the visualization is fullscreen or not.
- Return type
- pause()¶
Different behaviors may be encountered when using this method:
If the player is playing, this will pause playback.
If the player is paused, this will resume playback.
- Return type
- play()¶
Different behaviors may be encountered when using this method:
If the player is stopped, this will start playback.
If the player is paused, this will resume playback.
If the player is playing, this will start playback from beginning.
- Return type
- play_pause()¶
Different behaviors may be encountered when using this method:
If the player is stopped, this will start playback.
If the player is paused, this will resume playback.
If the player is playing, this will start pauses playback.
- Return type
- quit()¶
Shutdown and exit AIMP.
You’ll obviously not be able to do anything after using this method until AIMP is opened again and
pyaimp.Client.detect_aimp()
is manually called.- Return type
- set_muted(muted)¶
Set the muted state of the player.
- set_player_position(position)¶
Set the current player position.
- set_recording(recording)¶
Set the radio recording state of the player.
- set_shuffled(shuffled)¶
Set the shuffle state of the player.
- set_track_repeated(repeat)¶
Set the repeat state of the player.
- set_visualization_fullscreen(visualization_fullscreen)¶
Set the visualization to be fullscreen or not.
- set_volume(volume)¶
Set the current volume.
- class pyaimp.PlayBackState(value)¶
Enumeration (extending
enum.Enum
) of all possible AIMP playback states.May be used in conjonction with
pyaimp.Client.get_playback_state()
result.- Paused = 1¶
The current track playback is currently suspended.
- Playing = 2¶
A track is being played.
- Stopped = 0¶
There’s currently no track being played.