From b107385084414ea4d5f67a69c5d437f1a9b4888e Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Sun, 14 Mar 2010 19:10:42 +0100 Subject: [PATCH] Started music player controls --- README | 26 +++++++++++++------------- src/app.vala | 2 +- src/app_main.vala | 1 + src/audio.vala | 15 +++++++++++++++ src/zavai.vala | 17 +++++++++-------- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/README b/README index 6f23596..8bfda5c 100644 --- a/README +++ b/README @@ -187,12 +187,24 @@ TODO list / wish list operator, power and so on) - log and refuse incoming calls and messages - alarm - - play sound at alarm trigger + + play sound at alarm trigger - leave expired alarm on screen until acknowledged (alarm status icon that also brings to alarm menu) - remember alarm names (on request, maybe with an add feature) and how often they are triggered, and show them most frequent first - show active alarms and allow to delete them + - fisheye list music player + (-> learn/test gstreamer libs) + - player page with seek/skip controls + - playlist editor + - chosen song start playing if nothing is being played + - chosen song moves to playlist editor: play, add to playlist, add dir to playlist + (show a standard list multiselectable with all the songs in the dir and + only the selected song selected; allow to select others, select all, add + selected to playlist) + - playlist as reorderable standard list, allow to delete tracks, reorder tracks + - save playlist to file to reload later + - pause with headset button - audio notes - record audio notes, logging start and stop so it gets an associated GPX - shortcut icon in main screen @@ -214,18 +226,6 @@ TODO list / wish list (-> learn/test libalsamixer something) /usr/share/vala/vapi/alsa.vapi - space buttons from sliders, to avoid shutting down instead of lowering the volume - - fisheye list music player - (-> learn/test gstreamer libs) - - player page with seek/skip controls - - playlist editor - - chosen song start playing if nothing is being played - - chosen song moves to playlist editor: play, add to playlist, add dir to playlist - (show a standard list multiselectable with all the songs in the dir and - only the selected song selected; allow to select others, select all, add - selected to playlist) - - playlist as reorderable standard list, allow to delete tracks, reorder tracks - - save playlist to file to reload later - - pause with headset button - battery without devkit: do the parsing via lua - contacts: show as a fancy focus+context list (see prefuse) - vcard on e-vcard.{h,c} diff --git a/src/app.vala b/src/app.vala index 9b4b4a1..5281f56 100644 --- a/src/app.vala +++ b/src/app.vala @@ -1,7 +1,7 @@ /* * app - zavai main window * - * Copyright (C) 2009 Enrico Zini + * Copyright (C) 2009-2010 Enrico Zini * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/app_main.vala b/src/app_main.vala index 34b87a1..f839c09 100644 --- a/src/app_main.vala +++ b/src/app_main.vala @@ -144,6 +144,7 @@ public class Status : Applet pack_start(status_icons, false, false, 0); pack_start(clock, false, false, 0); pack_start(gsm_status, false, false, 0); + pack_start(music.player, false, false, 0); pack_end(menu, false, false, 0); zavai.gsm.gsm.status_changed += (msg) => { gsm_status.set_text(msg); }; diff --git a/src/audio.vala b/src/audio.vala index 52beeb6..1c39420 100644 --- a/src/audio.vala +++ b/src/audio.vala @@ -116,6 +116,7 @@ public class Player: zavai.Resource, Object protected Player master; protected bool loop; protected string uri; + public signal void state_changed(Gst.State new_state); public Player() { @@ -149,26 +150,40 @@ stderr.printf("Playing %s\n", uri); this.loop = loop; } + public Gst.State get_state() + { + Gst.State state; + Gst.State pending; + + player.get_state(out state, out pending, (Gst.ClockType)Gst.CLOCK_TIME_NONE); + + return state; + } + public void pause() { player.set_state(Gst.State.PAUSED); + state_changed(Gst.State.PAUSED); } public void resume() { player.set_state(Gst.State.PLAYING); + state_changed(Gst.State.PLAYING); } public void restart() { player.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, 0); player.set_state(Gst.State.PLAYING); + state_changed(Gst.State.PLAYING); } public void stop() { playing = false; player.set_state(Gst.State.NULL); + state_changed(Gst.State.NULL); // Resume slave after we are done if (slave != null && slave.playing) diff --git a/src/zavai.vala b/src/zavai.vala index 1e0a646..50a2c39 100644 --- a/src/zavai.vala +++ b/src/zavai.vala @@ -113,6 +113,7 @@ static int main (string[] args) { */ // User interface + zavai.ui.music.init(); zavai.ui.main.init(); zavai.ui.gps.init(); zavai.ui.gsm.init(); @@ -177,14 +178,14 @@ static int main (string[] args) { { zavai.audio.musicplayer.play("file://" + args[2]); - Timeout.add(3 * 1000, () => { - zavai.audio.soundplayer.play("file:///backup/ciapino/src/openmoocow/data/moo.wav", true); - Timeout.add(4 * 1000, () => { - zavai.audio.soundplayer.stop(); - return false; - }); - return false; - }); + // Timeout.add(3 * 1000, () => { + // zavai.audio.soundplayer.play("file:///backup/ciapino/src/openmoocow/data/moo.wav", true); + // Timeout.add(4 * 1000, () => { + // zavai.audio.soundplayer.stop(); + // return false; + // }); + // return false; + // }); } Gtk.main(); -- 2.39.5