[gnome-music] More work on the playlist class
- From: Cesar Garcia Tapia <ctapia src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] More work on the playlist class
- Date: Tue, 30 Oct 2012 13:43:20 +0000 (UTC)
commit 4ef37dbd922ba1246941536e6724ed20bd57f0e7
Author: CÃsar GarcÃa Tapia <cesar garcia tapia openshine com>
Date: Tue Oct 30 14:33:43 2012 +0100
More work on the playlist class
src/music-app.vala | 11 +++++++++++
src/music-player.vala | 31 ++++++++++++++++---------------
src/music-playlist.vala | 8 +++++++-
3 files changed, 34 insertions(+), 16 deletions(-)
---
diff --git a/src/music-app.vala b/src/music-app.vala
index 39968bc..68277f8 100644
--- a/src/music-app.vala
+++ b/src/music-app.vala
@@ -193,6 +193,8 @@ private class Music.App {
notebook.append_page (playlistView.actor, null);
player = new Music.Player ();
+ player.need_next.connect (on_player_need_next);
+ player.need_previous.connect (on_player_need_previous);
layout.pack_start (player.actor, false, false);
layout.show ();
@@ -232,6 +234,15 @@ private class Music.App {
player.load (media);
}
+ private void on_player_need_next () {
+ debug ("NEED_NEXT");
+ playlist.load_next();
+ }
+
+ private void on_player_need_previous () {
+
+ }
+
private void on_browse_history_changed () {
if (browse_history.get_length () > 1) {
topbar.set_collection_back_button_visible (true);
diff --git a/src/music-player.vala b/src/music-player.vala
index 4bdba66..b855441 100644
--- a/src/music-player.vala
+++ b/src/music-player.vala
@@ -42,18 +42,10 @@ internal class Music.PlayPauseButton : ToggleButton {
private class Music.Player: GLib.Object {
public Gtk.Widget actor { get { return eventbox; } }
- private Gtk.EventBox eventbox;
-
- private GLib.Settings settings;
- private dynamic Gst.Element playbin;
-
- private Music.AlbumArtCache cache;
- private int ART_SIZE = 42;
-
- public signal string? need_next ();
- public signal string? need_previous ();
+ public signal void need_next ();
+ public signal void need_previous ();
- private uint position_update_timeout;
+ private Gtk.EventBox eventbox;
private PlayPauseButton play_btn;
private Gtk.Button prev_btn;
@@ -69,23 +61,35 @@ private class Music.Player: GLib.Object {
private Gtk.ToggleButton shuffle_btn;
+ private GLib.Settings settings;
+ private dynamic Gst.Element playbin;
+
+ private bool shuffle;
+
+ private Music.AlbumArtCache cache;
+ private int ART_SIZE = 42;
+
+ private uint position_update_timeout;
+
public Player () {
Object ();
cache = AlbumArtCache.get_default ();
settings = new GLib.Settings ("org.gnome.Music");
+ /*
settings.bind ("shuffle",
this,
"shuffle",
SettingsBindFlags.DEFAULT);
+ */
playbin = Gst.ElementFactory.make ("playbin2", null);
var bus = playbin.get_bus ();
bus.add_watch ( (bus, message) => {
switch (message.type) {
case Gst.MessageType.EOS:
- uri = need_next ();
+ need_next ();
break;
case Gst.MessageType.STATE_CHANGED:
if (message.src == playbin) {
@@ -242,9 +246,6 @@ private class Music.Player: GLib.Object {
private void on_play_btn_toggled (Gtk.ToggleButton button) {
if (button.get_active()) {
- if (playbin.uri == null) {
- uri = need_next ();
- }
playbin.set_state (Gst.State.PLAYING);
}
else {
diff --git a/src/music-playlist.vala b/src/music-playlist.vala
index 71bfbc2..54f6a19 100644
--- a/src/music-playlist.vala
+++ b/src/music-playlist.vala
@@ -36,6 +36,13 @@ private class Music.Playlist: Object, Gee.Iterable<Grl.Media> {
}
}
+ public void load_next () {
+ if (current_index + 1 < list.size) {
+ current_index++;
+ song_selected (list[current_index], current_index);
+ }
+ }
+
public void load_album (Grl.Media media) {
if (media is Grl.MediaBox) {
list.clear();
@@ -66,7 +73,6 @@ private class Music.Playlist: Object, Gee.Iterable<Grl.Media> {
OPTIONAL { ?song nmm:musicAlbum ?album } .
OPTIONAL { ?album nmm:albumArtist ?artist }
}";
- debug (query);
foreach (var source in source_list.values) {
source.query (query, keys, options, (source, query_id, media, remaining, error) => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]