incise.org: corn dbus api

Corn's service name is org.mpris.corn. There are two interfaces. org.freedesktop.MediaPlayer is the implementation of the MPRIS specification. org.corn.CornPlayer contains a few extra things that I thought were missing in MPRIS (and will probably be in MPRIS 2.0).

The following is a reference of all D-BUS methods available in Corn.

Interface: org.freedesktop.MediaPlayer
  Path: /
    Method: Identity      Returns: string: program/version
    Method: MprisVersion  Returns: struct { uint16 major, uint16 minor }
    Method: Quit

  Path: /Player
    Method: Next
    Method: Prev
    Method: Pause
    Method: Stop
    Method: Play

    Method: VolumeSet     Args: (int32: 0 through 100 inclusive)
    Method: PositionSet   Args: (int32: 0 through track-length-in-ms inclusive)
    Method: Repeat        Args: (boolean: repeat current track or not)

    Method: VolumeGet     Returns: (int32: 0 through 100 inclusive)
    Method: PositionGet   Returns: (int32: 0 through track-length-in-ms inclusive)
    Method: GetMetadata   Returns: (dict(key:string, val:variant): current song's metadata)

    Method: GetCaps       Returns: (int32: bitmask of capabilities)
      Possible contents of GetCaps return value:
        NONE                 = 0
        CAN_GO_NEXT          = 1 << 0
        CAN_GO_PREV          = 1 << 1
        CAN_PAUSE            = 1 << 2
        CAN_PLAY             = 1 << 3
        CAN_SEEK             = 1 << 4
        CAN_PROVIDE_METADATA = 1 << 5
        CAN_HAS_TRACKLIST    = 1 << 6

    Signal: TrackChange   Args: (dict(key:string, val:variant): song's metadata)
      Tells you when a new track has begun playing.

    Signal: StatusChange  Args: (struct { int32[4] }: same structure as GetStatus returns)
      Tells you when any part of the information that a GetStatus call returns has changed.

    Signal: CapsChange    Args: (int32: capabilities, same as returned by GetCaps)
      Tells you when player's capabilities, as given by GetCaps, have changed.

  Path: /TrackList
    Method: DelTrack         Args: (int32: track to delete)
    Method: AddTrack         Args: (string: uri of song, boolean: playnow)
                             Returns: (int32: 0 if succeeded, non-zero if failed)

    Method: GetLength        Returns: (int32: number of tracks)
    Method: GetCurrentTrack  Returns: (int32: track number of current song)

    Method: GetMetadata      Args: (int32: track to get metadata for)
                             Returns: (dict(key:string, val:variant): metadata for requested track)

    Method: GetStatus        Returns: (struct { int32 playstate, int32 random, int32 repeat, int32 loop })
      All four ints are effectively booleans, except playstate, which is:
        playing = 0
        paused = 1
        stopped = 2

    Method: SetLoop          Args: (boolean: loop at end of playlist or not)
    Method: SetRandom        Args: (boolean: play randomly or not)

    Signal: TrackListChange  Args: (int32: new number of items in playlist)
      Tells you that something in the playlist has been added or removed, or
      moved around.  Unfortunately it doesn't give you much detail on what
      actually happened.

Interface: org.corn.Player
  Path: /Corn
    Method: Clear
    Method: PlayTrack  Args: (int32: track)
    Method: Move       Args: (int32: from, int32: to)  # move track at $from to $to

Examples using dbus-send

$ dbus-send --session --type=method_call --print-reply --dest=org.mpris.corn / org.freedesktop.MediaPlayer.Identity
method return sender=:1.684 -> dest=:1.785 reply_serial=2
   string "corn 0.0.0"
$ dbus-send --session --type=method_call --dest=org.mpris.corn /Player org.freedesktop.MediaPlayer.Next

comments


Nick Welch <nick@incise.org> · github · twitter