pilot_drive.services.media package

Submodules

pilot_drive.services.media.abstract_media_source module

Abstract media managers & their data types

class pilot_drive.services.media.abstract_media_source.BaseMediaSource(push_to_queue_callback: Callable, logger: MasterLogger)

Bases: ABC

The base class for a media manager

abstract main() None

The main method to be implemented by media managers

abstract property playing: bool

Get whether the current track is playing

Returns:

a boolean of True if playing and False if not playing

abstract property position: int

Get the track position

Returns:

track position in milliseconds

push_media_to_queue() None

Pushes media info to the queue utilizing the callback provided in initializer

abstract property track: TrackProps

Get the track metadata

Returns:

a dict of Title, Artist, Album, and Duration with corresponding values.

class pilot_drive.services.media.abstract_media_source.TrackProps

Bases: TypedDict

A typed dict used to store Track metadata

album: str | None
artist: str | None
duration: int | None
title: str | None

pilot_drive.services.media.bluetooth_media module

The Bluetooth media manager

class pilot_drive.services.media.bluetooth_media.BluetoothMedia(push_to_queue_callback: Callable, bluetooth: Bluetooth, logger: MasterLogger)

Bases: BaseMediaSource

The Bluetooth media manager for Media. Utilizes the bluetooth service to relay metadata on

currently playing media.

property active_av_devices: List[BluetoothDevice]

Get a list of connected devices that have media capabilities

Returns:

A list of connected & media capable BluetoothDevice instances

main() None
Main loop of the bluetooth media manager. Creates a dasbus event loop and sets up initial

callbacks, along with initial queue pushes.

property playing: bool

Get whether the current track is playing

Returns:

a boolean of True if playing and False if not playing

property position: int

Get the track position

Returns:

track position in milliseconds

property track: TrackProps | Dict[str, None]

Get the track metadata

Returns:

a dict of Title, Artist, Album, and Duration with corresponding values.

pilot_drive.services.media.constants module

Media service constants

class pilot_drive.services.media.constants.MediaSources(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: StrEnum

Enum of all possible media types

BLUETOOTH = 'bluetooth'
FILES = 'files'
RADIO = 'radio'
class pilot_drive.services.media.constants.TrackAttributes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: StrEnum

Enum used for the track attributes.

Bluez docs: https://github.com/bluez/bluez/blob/master/doc/media-api.txt#L288-#L320

ALBUM = 'Album'
ARTIST = 'Artist'
DURATION = 'Duration'
GENRE = 'Genre'
NUMBER_OF_TRACKS = 'NumberOfTracks'
TITLE = 'Title'
TRACK_NUMBER = 'TrackNumber'
class pilot_drive.services.media.constants.TrackControl(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: StrEnum

Enum used to handle values passed from the frontend regarding track control

NEXT = 'next'
PAUSE = 'pause'
PLAY = 'play'
PREV = 'prev'
class pilot_drive.services.media.constants.TrackStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: StrEnum

Enum used for the track status states

Status state docs: https://github.com/bluez/bluez/blob/master/doc/media-api.txt#L271-#L275

ERROR = 'error'
FORWARD_SEEK = 'forward-seek'
PAUSED = 'paused'
PLAYING = 'playing'
REVERSE_SEEK = 'reverse-seek'
STOPPED = 'stopped'

pilot_drive.services.media.media module

The module that manages the media of PILOT Drive, ie. A/V metadata

class pilot_drive.services.media.media.Media(master_event_queue: MasterEventQueue, service_type: EventType, logger: MasterLogger)

Bases: AbstractService

The service that manages the Media information of PILOT Drive.

main() None
The main method of the Media service, dictates which media manager to use based on media

type (currently only supports Bluetooth)

refresh() None

Currently a do-nothing method as there are no events stored within the object to serve

track_control(action: TrackControl) None

Handle track control events such as pause, play, skip, and previous.

Parameters:

action – TrackControl enum member indicating the intended action

Module contents

The service that manages the media of PILOT Drive, ie. A/V metadata