[banshee/moblin] some API corrections, emit a set of events ...
- From: Michael Meeks <michael src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee/moblin] some API corrections, emit a set of events ...
- Date: Mon, 17 Aug 2009 17:47:56 +0000 (UTC)
commit b9188bc3a9d684f961db406d1ee89103bac5e7c4
Author: Michael Meeks <michael meeks novell com>
Date: Mon Aug 17 18:47:28 2009 +0100
some API corrections, emit a set of events ...
.../Banshee.MoblinBackend/BognorInterface.cs | 19 ++++++--
.../Banshee.MoblinBackend/MoblinBognor.cs | 47 +++++++++++++++++---
2 files changed, 54 insertions(+), 12 deletions(-)
---
diff --git a/src/Backends/Banshee.Moblin/Banshee.MoblinBackend/BognorInterface.cs b/src/Backends/Banshee.Moblin/Banshee.MoblinBackend/BognorInterface.cs
index be2846d..fefd29a 100644
--- a/src/Backends/Banshee.Moblin/Banshee.MoblinBackend/BognorInterface.cs
+++ b/src/Backends/Banshee.Moblin/Banshee.MoblinBackend/BognorInterface.cs
@@ -21,12 +21,21 @@ namespace org.moblin.BognorRegis
public const string QueueManagerIface = "org.moblin.BognorRegis.QueueManager";
}
+ public enum QueueType : int {
+ Audio = 0,
+ Visual = 1
+ }
+
+
// signal signatures
+ // play queue list synchronisaton
public delegate void UriAddedHandler (string uri, int position);
public delegate void UriRemovedHandler (string uri, int position);
- public delegate void PlayingChangedHandler (int type, double position);
- public delegate void PositionChangedHandler (int type, double position);
- public delegate void NowPlayingChangedHandler (string uri, int type);
+ // are we playing, and if so what next ?
+ public delegate void NowPlayingChangedHandler (string uri, QueueType type);
+ public delegate void PlayingChangedHandler (QueueType type, bool playing);
+ // where in the track are we playing ?
+ public delegate void PositionChangedHandler (QueueType type, double position);
[Interface (Name.QueueIface)]
public interface IQueue
@@ -38,8 +47,8 @@ namespace org.moblin.BognorRegis
bool GetPlaying ();
// seeking ?
- double GetPosition (int type); // FIXME: type as enumeration ...
- void SetPosition (int type, double position);
+ double GetPosition (QueueType type); // FIXME: type as enumeration ...
+ void SetPosition (QueueType type, double position);
void PlayUri (string uri, string mimeType);
void AddUri (string uri, string mimeType);
diff --git a/src/Backends/Banshee.Moblin/Banshee.MoblinBackend/MoblinBognor.cs b/src/Backends/Banshee.Moblin/Banshee.MoblinBackend/MoblinBognor.cs
index e482fdc..08c4158 100644
--- a/src/Backends/Banshee.Moblin/Banshee.MoblinBackend/MoblinBognor.cs
+++ b/src/Backends/Banshee.Moblin/Banshee.MoblinBackend/MoblinBognor.cs
@@ -96,6 +96,9 @@ namespace Banshee.MoblinBackend.BognorRegis
serviceName = name;
mgr = _mgr;
ServiceManager.DBusServiceManager.RegisterObject (this);
+
+ ServiceManager.PlayerEngine.ConnectEvent
+ (OnPlayerEvent, PlayerEvent.StateChange | PlayerEvent.Iterate);
}
IDBusExportable IDBusExportable.Parent {
@@ -108,6 +111,7 @@ namespace Banshee.MoblinBackend.BognorRegis
public void Dispose ()
{
+ ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
ServiceManager.DBusServiceManager.UnregisterObject (this);
}
@@ -118,22 +122,26 @@ namespace Banshee.MoblinBackend.BognorRegis
}
public void Stop ()
{
- // FIXME: no stop, hmm !
+ // FIXME: '.Close' is conventional 'stop'
+ // but is this what we really want ?
ServiceManager.PlayerEngine.Pause();
}
- public string GetName () { return "local_queue"; }
+ public string GetName ()
+ {
+ return Queue.Name;
+ }
public bool GetPlaying ()
{
return ServiceManager.PlayerEngine.IsPlaying();
}
/* seeking */
- public double GetPosition (int type)
+ public double GetPosition (QueueType type)
{
return ((double) ServiceManager.PlayerEngine.Position /
ServiceManager.PlayerEngine.Length);
}
- public void SetPosition (int type, double position)
+ public void SetPosition (QueueType type, double position)
{
ServiceManager.PlayerEngine.Position =
(uint) (ServiceManager.PlayerEngine.Length * position);
@@ -150,7 +158,8 @@ namespace Banshee.MoblinBackend.BognorRegis
}
public void InsertUri (string uri, string mimeType, int pos)
{
-// 'int pos' is hardish - cf. PlayQueueSource.cs ...
+ // 'int pos' is hardish - cf. PlayQueueSource.cs ...
+ // cf. PlaylistSource.ReorderSelectedTracks (eg.)
}
public void Remove (int index)
{
@@ -170,12 +179,36 @@ namespace Banshee.MoblinBackend.BognorRegis
}
// public string,string GetNowPlaying (); - mangling ?
- // signals
+ private void OnPlayerEvent (PlayerEventArgs args)
+ {
+ switch (args.Event) {
+ case PlayerEvent.Iterate:
+ UriPositionChanged (QueueType.Audio, GetPosition (QueueType.Audio));
+ break;
+ // FIXME: can we emit 'PlayingChanged' more cleanly ?
+ case PlayerEvent.StateChange:
+ if ((args as PlayerEventStateChangeArgs).Current != PlayerState.Playing) {
+ PlayingChanged (QueueType.Audio, false);
+ break;
+ }
+ TrackInfo t = ServiceManager.PlayerEngine.CurrentTrack;
+ UriNowPlayingChanged (t != null ? t.Uri.AbsoluteUri: "", QueueType.Audio);
+ PlayingChanged (QueueType.Audio, true);
+ break;
+ default:
+ break;
+ }
+ }
+
+ // It looks like we need a full shadow track list
+ // locally to get this right (which sucks).
public event UriAddedHandler UriAdded;
public event UriRemovedHandler UriRemoved;
+
+ public event PlayingChangedHandler PlayingChanged;
public event NowPlayingChangedHandler UriNowPlayingChanged;
public event PositionChangedHandler UriPositionChanged;
- public event PlayingChangedHandler PlayingChanged;
+
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]