API Reference

Top-level package

aionowplaying.select_interface(system: str = None) Type[BaseInterface][source]
class aionowplaying.BaseInterface(name: str)[source]

Bases: object

async start()[source]

Call this method to start nowplaying backend. Wrap with asyncio.ensure_future() if you want to run in background.

async stop()[source]
async on_fullscreen(fullscreen: bool)[source]

This will be called when nowplaying backend want to set player fullscreen state. This will only be called if you set PlayerProperties.CanSetFullscreen to True. :param fullscreen: True if fullscreen, False otherwise. :type fullscreen: bool

async on_raise()[source]

This will be called when nowplaying backend want to raise player window. This will only be called if you set PlayerProperties.CanRaise to True.

async on_quit()[source]

This will be called when nowplaying backend want to quit player. This will only be called if you set PlayerProperties.CanQuit to True.

async on_loop_status(status: LoopStatus)[source]

This will be called when nowplaying backend want to set loop status. This will only be called if you set PlaybackProperties.CanControl to True. :param status: Loop status. :type status: LoopStatus

async on_rate(rate: float)[source]

This will be called when nowplaying backend want to set playback rate. The rate is a float value between PlaybackProperties.MinimumRate and PlaybackProperties.MaximumRate. :param rate: Playback rate. :type rate: float

async on_shuffle(shuffle: bool)[source]

This will be called when nowplaying backend want to set shuffle status. This will only be called if you set PlaybackProperties.CanControl to True. :param shuffle: True if shuffle, False otherwise. :type shuffle: bool

async on_volume(volume: float)[source]

This will be called when nowplaying backend want to set playback volume. This will only be called if you set PlaybackProperties.CanControl to True. :param volume: Volume value between 0.0 and 1.0 (both inclusive). :type volume: float

async on_next()[source]

This will be called when nowplaying backend want to play next track. This will only be called if you set PlaybackProperties.CanGoNext to True.

async on_previous()[source]

This will be called when nowplaying backend want to play previous track. This will only be called if you set PlaybackProperties.CanGoPrevious to True.

async on_pause()[source]

This will be called when nowplaying backend want to pause playback. This will only be called if you set PlaybackProperties.CanPause to True.

async on_play_pause()[source]

This will be called when nowplaying backend want to play or pause playback. This will only be called if you set PlaybackProperties.CanPause to True.

async on_play()[source]

This will be called when nowplaying backend want to play playback. This will only be called if you set PlaybackProperties.CanPlay to True.

async on_stop()[source]
async on_seek(offset: int)[source]
async on_open_uri(uri: str)[source]
async on_set_position(track_id: str, position: int)[source]
async seeked(position: int)[source]
set_property(name: PropertyName, value: Any)[source]
set_playback_property(name: PlaybackPropertyName, value: Any)[source]
set_tracklist_property(name: TrackListPropertyName, value: Any)[source]
get_property(name: PropertyName) Any[source]
get_playback_property(name: PlaybackPropertyName) Any[source]
get_tracklist_property(name: TrackListPropertyName) Any[source]
class aionowplaying.PropertyName(value)[source]

Bases: str, Enum

CanQuit = 'CanQuit'
CanSetFullscreen = 'CanSetFullscreen'
CanRaise = 'CanRaise'
HasTrackList = 'HasTrackList'
Identity = 'Identity'
DesktopEntry = 'DesktopEntry'
SupportedUriSchemes = 'SupportedUriSchemes'
SupportedMimeTypes = 'SupportedMimeTypes'
Fullscreen = 'Fullscreen'
class aionowplaying.LoopStatus(value)[source]

Bases: str, Enum

None_ = 'None'
Track = 'Track'
Playlist = 'Playlist'
class aionowplaying.PlaybackPropertyName(value)[source]

Bases: str, Enum

PlaybackStatus = 'PlaybackStatus'
LoopStatus = 'LoopStatus'
Rate = 'Rate'
Shuffle = 'Shuffle'
Metadata = 'Metadata'
Volume = 'Volume'
Position = 'Position'
Duration = 'Duration'
MinimumRate = 'MinimumRate'
MaximumRate = 'MaximumRate'
CanGoNext = 'CanGoNext'
CanGoPrevious = 'CanGoPrevious'
CanPlay = 'CanPlay'
CanPause = 'CanPause'
CanSeek = 'CanSeek'
CanControl = 'CanControl'
class aionowplaying.PlaybackProperties(*, PlaybackStatus: PlaybackStatus = PlaybackStatus.Stopped, LoopStatus: None = LoopStatus.None_, Rate: float = 1.0, Shuffle: bool = False, Metadata: MetadataBean = MetadataBean(id_='', media_type=<MediaType.Music: 'Music'>, duration=0, cover='', album='', albumArtist=[], artist=[], lyrics='', comments=[], composer=[], genre=[], lyricist=[], title='Unknown', trackNumber=0, url=''), Volume: float = 1.0, Position: int = 0, Duration: int = 0, MinimumRate: float = 1.0, MaximumRate: float = 1.0, CanGoNext: bool = False, CanGoPrevious: bool = False, CanPlay: bool = False, CanPause: bool = False, CanSeek: bool = False, CanControl: bool = False)[source]

Bases: BaseModel

class MetadataBean(*, id_: str = '', media_type: MediaType = MediaType.Music, duration: int = 0, cover: str = '', album: str = '', albumArtist: List[str] = [], artist: List[str] = [], lyrics: str = '', comments: List[str] = [], composer: List[str] = [], genre: List[str] = [], lyricist: List[str] = [], title: str = 'Unknown', trackNumber: int = 0, url: str = '')[source]

Bases: BaseModel

id_: str
media_type: MediaType
duration: int
cover: str
album: str
albumArtist: List[str]
artist: List[str]
lyrics: str
comments: List[str]
composer: List[str]
genre: List[str]
lyricist: List[str]
title: str
trackNumber: int
url: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

PlaybackStatus: PlaybackStatus
LoopStatus: LoopStatus
Rate: float
Shuffle: bool
Metadata: MetadataBean
Volume: float
Position: int
Duration: int
MinimumRate: float
MaximumRate: float
CanGoNext: bool
CanGoPrevious: bool
CanPlay: bool
CanPause: bool
CanSeek: bool
CanControl: bool
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class aionowplaying.PlaybackStatus(value)[source]

Bases: str, Enum

Playing = 'Playing'
Paused = 'Paused'
Stopped = 'Stopped'
aionowplaying.NowPlayingInterface

alias of Mpris2Interface

Interface selector

aionowplaying.interface.select_interface(system: str = None) Type[BaseInterface][source]

Base interface and data models

class aionowplaying.interface.base.TrackListPropertyName(value)[source]

Bases: str, Enum

Tracks = 'Tracks'
CanEditTracks = 'CanEditTracks'
class aionowplaying.interface.base.PropertyName(value)[source]

Bases: str, Enum

CanQuit = 'CanQuit'
CanSetFullscreen = 'CanSetFullscreen'
CanRaise = 'CanRaise'
HasTrackList = 'HasTrackList'
Identity = 'Identity'
DesktopEntry = 'DesktopEntry'
SupportedUriSchemes = 'SupportedUriSchemes'
SupportedMimeTypes = 'SupportedMimeTypes'
Fullscreen = 'Fullscreen'
class aionowplaying.interface.base.PlaybackPropertyName(value)[source]

Bases: str, Enum

PlaybackStatus = 'PlaybackStatus'
LoopStatus = 'LoopStatus'
Rate = 'Rate'
Shuffle = 'Shuffle'
Metadata = 'Metadata'
Volume = 'Volume'
Position = 'Position'
Duration = 'Duration'
MinimumRate = 'MinimumRate'
MaximumRate = 'MaximumRate'
CanGoNext = 'CanGoNext'
CanGoPrevious = 'CanGoPrevious'
CanPlay = 'CanPlay'
CanPause = 'CanPause'
CanSeek = 'CanSeek'
CanControl = 'CanControl'
class aionowplaying.interface.base.PlaybackStatus(value)[source]

Bases: str, Enum

Playing = 'Playing'
Paused = 'Paused'
Stopped = 'Stopped'
class aionowplaying.interface.base.LoopStatus(value)[source]

Bases: str, Enum

None_ = 'None'
Track = 'Track'
Playlist = 'Playlist'
class aionowplaying.interface.base.MediaType(value)[source]

Bases: str, Enum

Music = 'Music'
Video = 'Video'
Image = 'Image'
class aionowplaying.interface.base.TrackListProperties(*, Tracks: List[str] = [], CanEditTracks: bool = False)[source]

Bases: BaseModel

Tracks: List[str]
CanEditTracks: bool
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class aionowplaying.interface.base.PlayerProperties(*, Fullscreen: bool = False, CanQuit: bool = False, CanSetFullscreen: bool = False, CanRaise: bool = False, HasTrackList: bool = False, Identity: str = '', DesktopEntry: str = '', SupportedUriSchemes: List[str] = [], SupportedMimeTypes: List[str] = [])[source]

Bases: BaseModel

Fullscreen: bool
CanQuit: bool
CanSetFullscreen: bool
CanRaise: bool
HasTrackList: bool
Identity: str
DesktopEntry: str
SupportedUriSchemes: List[str]
SupportedMimeTypes: List[str]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class aionowplaying.interface.base.PlaybackProperties(*, PlaybackStatus: PlaybackStatus = PlaybackStatus.Stopped, LoopStatus: None = LoopStatus.None_, Rate: float = 1.0, Shuffle: bool = False, Metadata: MetadataBean = MetadataBean(id_='', media_type=<MediaType.Music: 'Music'>, duration=0, cover='', album='', albumArtist=[], artist=[], lyrics='', comments=[], composer=[], genre=[], lyricist=[], title='Unknown', trackNumber=0, url=''), Volume: float = 1.0, Position: int = 0, Duration: int = 0, MinimumRate: float = 1.0, MaximumRate: float = 1.0, CanGoNext: bool = False, CanGoPrevious: bool = False, CanPlay: bool = False, CanPause: bool = False, CanSeek: bool = False, CanControl: bool = False)[source]

Bases: BaseModel

class MetadataBean(*, id_: str = '', media_type: MediaType = MediaType.Music, duration: int = 0, cover: str = '', album: str = '', albumArtist: List[str] = [], artist: List[str] = [], lyrics: str = '', comments: List[str] = [], composer: List[str] = [], genre: List[str] = [], lyricist: List[str] = [], title: str = 'Unknown', trackNumber: int = 0, url: str = '')[source]

Bases: BaseModel

id_: str
media_type: MediaType
duration: int
cover: str
album: str
albumArtist: List[str]
artist: List[str]
lyrics: str
comments: List[str]
composer: List[str]
genre: List[str]
lyricist: List[str]
title: str
trackNumber: int
url: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

PlaybackStatus: PlaybackStatus
LoopStatus: LoopStatus
Rate: float
Shuffle: bool
Metadata: MetadataBean
Volume: float
Position: int
Duration: int
MinimumRate: float
MaximumRate: float
CanGoNext: bool
CanGoPrevious: bool
CanPlay: bool
CanPause: bool
CanSeek: bool
CanControl: bool
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class aionowplaying.interface.base.BaseInterface(name: str)[source]

Bases: object

async start()[source]

Call this method to start nowplaying backend. Wrap with asyncio.ensure_future() if you want to run in background.

async stop()[source]
async on_fullscreen(fullscreen: bool)[source]

This will be called when nowplaying backend want to set player fullscreen state. This will only be called if you set PlayerProperties.CanSetFullscreen to True. :param fullscreen: True if fullscreen, False otherwise. :type fullscreen: bool

async on_raise()[source]

This will be called when nowplaying backend want to raise player window. This will only be called if you set PlayerProperties.CanRaise to True.

async on_quit()[source]

This will be called when nowplaying backend want to quit player. This will only be called if you set PlayerProperties.CanQuit to True.

async on_loop_status(status: LoopStatus)[source]

This will be called when nowplaying backend want to set loop status. This will only be called if you set PlaybackProperties.CanControl to True. :param status: Loop status. :type status: LoopStatus

async on_rate(rate: float)[source]

This will be called when nowplaying backend want to set playback rate. The rate is a float value between PlaybackProperties.MinimumRate and PlaybackProperties.MaximumRate. :param rate: Playback rate. :type rate: float

async on_shuffle(shuffle: bool)[source]

This will be called when nowplaying backend want to set shuffle status. This will only be called if you set PlaybackProperties.CanControl to True. :param shuffle: True if shuffle, False otherwise. :type shuffle: bool

async on_volume(volume: float)[source]

This will be called when nowplaying backend want to set playback volume. This will only be called if you set PlaybackProperties.CanControl to True. :param volume: Volume value between 0.0 and 1.0 (both inclusive). :type volume: float

async on_next()[source]

This will be called when nowplaying backend want to play next track. This will only be called if you set PlaybackProperties.CanGoNext to True.

async on_previous()[source]

This will be called when nowplaying backend want to play previous track. This will only be called if you set PlaybackProperties.CanGoPrevious to True.

async on_pause()[source]

This will be called when nowplaying backend want to pause playback. This will only be called if you set PlaybackProperties.CanPause to True.

async on_play_pause()[source]

This will be called when nowplaying backend want to play or pause playback. This will only be called if you set PlaybackProperties.CanPause to True.

async on_play()[source]

This will be called when nowplaying backend want to play playback. This will only be called if you set PlaybackProperties.CanPlay to True.

async on_stop()[source]
async on_seek(offset: int)[source]
async on_open_uri(uri: str)[source]
async on_set_position(track_id: str, position: int)[source]
async seeked(position: int)[source]
set_property(name: PropertyName, value: Any)[source]
set_playback_property(name: PlaybackPropertyName, value: Any)[source]
set_tracklist_property(name: TrackListPropertyName, value: Any)[source]
get_property(name: PropertyName) Any[source]
get_playback_property(name: PlaybackPropertyName) Any[source]
get_tracklist_property(name: TrackListPropertyName) Any[source]

Linux (MPRIS2) backend

class aionowplaying.interface.mpris2.DBusBeanMapper[source]

Bases: object

static metadata(metadata: MetadataBean) dict[source]
class aionowplaying.interface.mpris2.MprisPlayerServiceInterface(*args: Any, **kwargs: Any)[source]

Bases: ServiceInterface

set_property(name: str, value: Any)[source]
playback_status() s
loop_status(value: s)
rate(value: d)
shuffle(value: b)
metadata() a{sv}
volume(value: d)
position() x
minimum_rate() d
maximum_rate() d
can_go_next() b
can_go_previous() b
can_play() b
can_pause() b
can_seek() b
can_control() b
seeked(position: int) x
next()
previous()
pause()
play_pause()
stop()
play()
seek(offset: x)
open_uri(uri: s)
set_position(track_id: o, position: x)
get_property(key)[source]
class aionowplaying.interface.mpris2.MprisServiceInterface(*args: Any, **kwargs: Any)[source]

Bases: ServiceInterface

fullscreen(value: b)
can_quit() b
can_set_fullscreen() b
has_track_list() b
can_raise() b
identity() s
desktop_entry() s
supported_uri_schemes() as
supported_mime_types() as
raise_()
quit()
set_property(name: str, value: Any)[source]
get_property(key)[source]
class aionowplaying.interface.mpris2.MprisTracklistServiceInterface(*args: Any, **kwargs: Any)[source]

Bases: ServiceInterface

set_property(name: str, value: Any)[source]
can_edit_tracks() b
tracks() ao
get_property(key)[source]
class aionowplaying.interface.mpris2.Mpris2Interface(name: str)[source]

Bases: BaseInterface

set_property(name: PropertyName, value: Any)[source]
set_playback_property(name: PlaybackPropertyName, value: Any)[source]
set_tracklist_property(name: TrackListPropertyName, value: Any)[source]
get_property(name: PropertyName) Any[source]
get_playback_property(name: PlaybackPropertyName) Any[source]
get_tracklist_property(name: TrackListPropertyName) Any[source]
async seeked(position: int)[source]
async start()[source]

Call this method to start nowplaying backend. Wrap with asyncio.ensure_future() if you want to run in background.

async stop()[source]

macOS backend

aionowplaying.interface.macos.create_handler(_, handler)[source]
aionowplaying.interface.macos.create_event_handler(handler)[source]
class aionowplaying.interface.macos.MacOSInterface(name: str)[source]

Bases: BaseInterface

get_playback_property(name: PlaybackPropertyName) Any[source]
set_property(name, value: Any)[source]
set_playback_property(name: PlaybackPropertyName, value: Any)[source]
set_tracklist_property(name, value: Any)[source]
get_property(name)[source]
get_tracklist_property(name)[source]
async start()[source]

Call this method to start nowplaying backend. Wrap with asyncio.ensure_future() if you want to run in background.

Windows backend

aionowplaying.interface.windows.TimeSpan(x_microsec)[source]
class aionowplaying.interface.windows.WindowsInterface(name)[source]

Bases: BaseInterface

shuffle_change_requested(_, args: winrt.windows.media.ShuffleEnabledChangeRequestedEventArgs)[source]
property_changed(_, args: winrt.windows.media.SystemMediaTransportControlsPropertyChangedEventArgs)[source]
playback_rate_change_requested(_, args: winrt.windows.media.PlaybackRateChangeRequestedEventArgs)[source]
playback_position_change_requested(_, args: winrt.windows.media.PlaybackPositionChangeRequestedEventArgs)[source]
button_pressed(_, args: winrt.windows.media.SystemMediaTransportControlsButtonPressedEventArgs)[source]
auto_repeat_mode_change_requested(_, args: winrt.windows.media.AutoRepeatModeChangeRequestedEventArgs)[source]
set_property(name: PropertyName, value: Any)[source]
set_playback_property(name: PlaybackPropertyName, value: Any)[source]
set_tracklist_property(name: TrackListPropertyName, value: Any)[source]
get_property(name: PropertyName) Any[source]
get_playback_property(name: PlaybackPropertyName) Any[source]
get_tracklist_property(name: TrackListPropertyName) Any[source]
async start()[source]

Call this method to start nowplaying backend. Wrap with asyncio.ensure_future() if you want to run in background.

async stop()[source]