This file documents the mapping of the C++ Alsaplayer interface API functions, classes and types in the Python interface. Though I think sources and examples are the best ways to found technical information ;)

Module: alsaplayer

This module provides:
* One function get_playlist which return general playlist object.
* One constant PLAYLIST_FORMAT_M3U.
* Three exceptions PlaylistBadError, PlaylistDubiousError, Error.
* And constructor PyPlayItem. Constructor takes string argument.

Class: PyPlaylist

The PyPlaylist class is the Python binding for C++ Playlist class. You can't create instance of this class directly but the PyPlaylist object gets passed to you when the interface script is called. To retrive passed object, please use code like this:

import alsaplayer
playlist = alsaplayer.get_playlist ()
	

This table lists how Playlist methods were mapped to PyPlaylist ones.

Playlist methods PyPlaylist methods Notes
Stop() stop()  
PlayFile(PlayItem) play_file(PyPlayItem) Can raise exception
CanPlay(std::string) can_play(string)  
GetCorePlayer() get_coreplayer() Returns PyCorePlayer
Length() get_length()  
Play(unsigned, int) play(int, int)  
Next(int) next(int)  
Prev(int) prev(int)  
GetCurrent() get_current()  
Insert(std::vector<std::string>) insert(list of strings)  
AddAndPlay(std::vector<std::string>) add_and_play(list of strings)  
Remove(unsigned, unsigned) remove(int, int)  
Shuffle(int) shuffle(int)  
Clear(int) clear(int)  
Paused() is_paused()  
Pause() pause()  
UnPause() unpause()  
Crossfading() is_crossfading()  
Crossfade() crossfade()  
UnCrossfade() uncrossfade()  
LoopingSong() is_looping_song()  
LoopSong() loop_song()  
UnLoopSong() unloop_song()  
LoopingPlaylist() is_looping_playlist()  
LoopPlaylist() loop_playlist()  
UnLoopPlaylist() unloop_playlist()  
Save(std::string, enum plist_format) save(string, alsaplayer.PLAYLIST_FORMAT_*) Can raise exceptions
Load(std::string, unsigned, bool) load(string, int, int) Can raise exceptions
Register(PlaylistInterface) register(instance) (*)
UnRegister(PlaylistInterface) unregister(instance) (*)

(*)
register/unregister methods accept instance with optional callback methods: set_current(int), lock(), unlock(), insert(list, int), remove(int, int), clear (), updated (). This methods will be used as playlist callbacks.
Also there is one new method get_registered (). This method returns tuple of registered instances.

Class: PyCorePlayer

The PyCorePlayer class is the Python binding for C++ CorePlayer class. This table lists how CorePlayer methods were mapped to PyCorePlayer ones.

CorePlayer methods PyCorePlayer methods Notes
GetPosition() get_position()  
SetSpeed(float) set_speed(float) Can raise exception
GetSpeed() get_speed()  
GetVolume() get_volume()  
SetVolume(int) set_volume(int)  
GetPan() get_pan()  
SetPan(int) set_pan(int)  
GetCurrentTime(int) get_current_time(int)  
GetStreamInfo(stream_info) get_stream_info() Returns PyStreamInfo
GetFrames() get_frames()  
GetSampleRate() get_samplerate()  
GetChannels() get_channels()  
GetFrameSize() get_frame_size()  
Start(int) start(int) Can raise exception
Stop() stop()  
Load(char *) load(string) Can raise exception
Unload() unload()  
Seek(int) seek(int) Can raise exception
CanSeek() can_seek()  
IsActive() is_active()  
IsPlaying() is_playing()  

Class: PyPlayItem

The PyPlayItem class is the Python binding for C++ PlayItem class. This class has no methods but it has few read only attrubutes (the first three are string type and last two are int): filename, title, artist, playtime, parsed.

Class: PyStreamInfo

The PyStreamInfo class is the Python binding for C stream_info structure. This class has no methods too, and it has four read only attrubutes: stream_type, title, artist, playtime, status.

Feedback

If you think something is missing from this document, or you see any kind of errors, please mail me at codedj@echo.ru or evgeny@omsktelecom.ru.

-- Evgeny Chukreev.