← Back to team overview

unity-dev team mailing list archive

[Ayatana-dev] New Sound Menu support within libunity

 

Hi folks,

I have just merged sound menu functionality into libunity. The idea behind this is to greatly simply sound menu registration and use for media applications. In the past the developer would need to raise an MPRIS compliant dbus server object and manage the communication back and forth.
Now using the libunity, its as simple as

(in Vala)

this.menu_player = new MusicPlayer ("rhythmbox.desktop");

In lp:libunity in the tests Vala folder you will find complete examples of how to use the MusicPlayer. We are in the process of generating API docs but until then you can look over the public consumer API below.

Conor


namespace Unity {

  public class TrackMetadata : GLib.Object
  {
   public string artist { get; set; }
   public string title { get; set; }
   public string album { get; set; }
   public File art_location { get; set; }
  }

  public class Playlist : GLib.Object
  {
    public Playlist (string id)
    {
      GLib.Object (id: id);
    }
    public string id {get; construct;}
    public string name {get; set;}
    public Icon icon {get; set;}
    public DateTime creation_date { get; set; }
    public DateTime modification_date { get; set; }
    public DateTime last_play_date { get; set; }
  }

  public enum PlaybackState{
    PLAYING,
    PAUSED
  }

  public class MusicPlayer : GLib.Object
  {
    private MPRISGateway mpris_gateway;
    private ArrayList<Playlist> internal_playlists;
    public GLib.AppInfo app_info {get; construct;}
    public string desktop_file_name {get; construct;}

    public MusicPlayer (string desktop)
    {
    .
    .
    .

    public bool add_playlist(Playlist p)
    {
    .
    .
    .

    public bool remove_playlist(Playlist p)
    {
    .
    .
    .

    public Playlist[] get_playlists()
    {
    .
    .
    .

    public void edit_playlist_name (string id, string name)
    {
    .
    .
    .

    public bool is_blacklisted {get; set;}
    public string title {get; set;}
    public bool can_go_next {get; set;}
    public bool can_go_previous {get; set;}
    public bool can_play {get; set;}
    public bool can_pause {get; set;}
    public TrackMetadata current_track {get; set;}
    public PlaybackState playback_state {set; get;}
    public Dbusmenu.Menuitem? track_menu { get; set; }
    public Dbusmenu.Menuitem? player_menu { get; set; }
    public Playlist current_playlist {get; set;}
    /*
     * Public API
     * Signals
     */
    public signal void raise ();
    public signal void play_pause ();
    public signal void previous ();
    public signal void next ();
    public signal void activate_playlist (ObjectPath playlist_id);
  }
}

--
Sound Architect
Desktop Experience Team
Product Strategy
Canonical