Exemple #1
0
class CoreState(ValidatedImmutableObject):
    """
    State of all Core controller.
    Internally used for save/load state.

    :param history: State of the history controller
    :type history: :class:`HistorState`
    :param mixer: State of the mixer controller
    :type mixer: :class:`MixerState`
    :param playback: State of the playback controller
    :type playback: :class:`PlaybackState`
    :param tracklist: State of the tracklist controller
    :type tracklist: :class:`TracklistState`
    """

    # State of the history controller.
    history = fields.Field(type=HistoryState)

    # State of the mixer controller.
    mixer = fields.Field(type=MixerState)

    # State of the playback controller.
    playback = fields.Field(type=PlaybackState)

    # State of the tracklist controller.
    tracklist = fields.Field(type=TracklistState)
Exemple #2
0
class HistoryTrack(ValidatedImmutableObject):
    """
    A history track. Wraps a :class:`Ref` and its timestamp.

    :param timestamp: the timestamp
    :type timestamp: int
    :param track: the track reference
    :type track: :class:`Ref`
    """

    # The timestamp. Read-only.
    timestamp = fields.Integer()

    # The track reference. Read-only.
    track = fields.Field(type=Ref)
Exemple #3
0
class PlaybackState(ValidatedImmutableObject):
    """
    State of the playback controller.
    Internally used for save/load state.

    :param tlid: current track tlid
    :type tlid: int
    :param time_position: play position
    :type time_position: int
    :param state: playback state
    :type state: :class:`validation.PLAYBACK_STATES`
    """

    # The tlid of current playing track. Read-only.
    tlid = fields.Integer(min=1)

    # The playback position. Read-only.
    time_position = fields.Integer(min=0)

    # The playback state. Read-only.
    state = fields.Field(choices=validation.PLAYBACK_STATES)
Exemple #4
0
class TlTrack(ValidatedImmutableObject):
    """
    A tracklist track. Wraps a regular track and it's tracklist ID.

    The use of :class:`TlTrack` allows the same track to appear multiple times
    in the tracklist.

    This class also accepts it's parameters as positional arguments. Both
    arguments must be provided, and they must appear in the order they are
    listed here.

    This class also supports iteration, so your extract its values like this::

        (tlid, track) = tl_track

    :param tlid: tracklist ID
    :type tlid: int
    :param track: the track
    :type track: :class:`Track`
    """

    #: The tracklist ID. Read-only.
    tlid = fields.Integer(min=0)

    #: The track. Read-only.
    track = fields.Field(type=Track)

    def __init__(self, *args, **kwargs):
        if len(args) == 2 and len(kwargs) == 0:
            kwargs['tlid'] = args[0]
            kwargs['track'] = args[1]
            args = []
        super(TlTrack, self).__init__(*args, **kwargs)

    def __iter__(self):
        return iter([self.tlid, self.track])
Exemple #5
0
class Track(ValidatedImmutableObject):
    """
    :param uri: track URI
    :type uri: string
    :param name: track name
    :type name: string
    :param artists: track artists
    :type artists: list of :class:`Artist`
    :param album: track album
    :type album: :class:`Album`
    :param composers: track composers
    :type composers: string
    :param performers: track performers
    :type performers: string
    :param genre: track genre
    :type genre: string
    :param track_no: track number in album
    :type track_no: integer or :class:`None` if unknown
    :param disc_no: disc number in album
    :type disc_no: integer or :class:`None` if unknown
    :param date: track release date (YYYY or YYYY-MM-DD)
    :type date: string
    :param length: track length in milliseconds
    :type length: integer or :class:`None` if there is no duration
    :param bitrate: bitrate in kbit/s
    :type bitrate: integer
    :param comment: track comment
    :type comment: string
    :param musicbrainz_id: MusicBrainz ID
    :type musicbrainz_id: string
    :param last_modified: Represents last modification time
    :type last_modified: integer or :class:`None` if unknown
    """

    #: The track URI. Read-only.
    uri = fields.URI()

    #: The track name. Read-only.
    name = fields.String()

    #: A set of track artists. Read-only.
    artists = fields.Collection(type=Artist, container=frozenset)

    #: The track :class:`Album`. Read-only.
    album = fields.Field(type=Album)

    #: A set of track composers. Read-only.
    composers = fields.Collection(type=Artist, container=frozenset)

    #: A set of track performers`. Read-only.
    performers = fields.Collection(type=Artist, container=frozenset)

    #: The track genre. Read-only.
    genre = fields.String()

    #: The track number in the album. Read-only.
    track_no = fields.Integer(min=0)

    #: The disc number in the album. Read-only.
    disc_no = fields.Integer(min=0)

    #: The track release date. Read-only.
    date = fields.Date()

    #: The track length in milliseconds. Read-only.
    length = fields.Integer(min=0)

    #: The track's bitrate in kbit/s. Read-only.
    bitrate = fields.Integer(min=0)

    #: The track comment. Read-only.
    comment = fields.String()

    #: The MusicBrainz ID of the track. Read-only.
    musicbrainz_id = fields.Identifier()

    #: Integer representing when the track was last modified. Exact meaning
    #: depends on source of track. For local files this is the modification
    #: time in milliseconds since Unix epoch. For other backends it could be an
    #: equivalent timestamp or simply a version counter.
    last_modified = fields.Integer(min=0)