public void Play ()
{
- Player.Play ();
+ First ();
}
public void Play (IEnumerable<IMediaFile> media)
{
Enqueue (media, true);
- Next ();
+ First ();
}
public void Enqueue (IEnumerable<IMediaFile> media)
@@ -152,8 +177,11 @@
void Enqueue (IEnumerable<IMediaFile> media, bool prepend)
{
try {
+ MaybeStartFullApplication (); //if banshee isn't already started the enqueue seems to fail
+
// if we're prepending to the queue we need to queue in the uris in reverse order
- if (prepend) media = media.Reverse ();
+ if (prepend)
+ media = media.Reverse ();
Alex Launi proposed lp:~alexlauni/do-plugins/bansheeplugin for merging into lp:do-plugins
The full version of the banshee plugin complete with collection indexing, and playback control. STD free and ready for action.
=== modified file 'Banshee/ Resources/ Banshee. addin.xml' Resources/ Banshee. addin.xml 2009-03-02 19:58:39 +0000 Resources/ Banshee. addin.xml 2009-03-13 21:55:50 +0000 "Search your music library and control playback." "Official"
--- a/Banshee/
+++ b/Banshee/
@@ -1,16 +1,21 @@
<Addin
id="Banshee"
namespace= "Do"
+<<<<<<< TREE
version="0.9"
name="Banshee (beta)"
description=
+=======
+ version="1.0"
+ name="Banshee Media Player"
+ description="Search your media collection and control playback."
+>>>>>>> MERGE-SOURCE
author="Alex Launi"
category=
>
<Runtime> "Banshee. dll"/> "Banshee. CollectionIndex er.dll" />
<Import assembly=
- <Import assembly=
</Runtime>
<Dependencies>
@@ -18,6 +23,10 @@
</Dependencies>
<!-- Extensions included in this assembly --> MediaItemSource " />
+ <!-- Itemsources -->
+ <Extension path = "/Do/ItemSource">
+ <ItemSource type = "Banshee.
+ </Extension>
<!-- Actions --> PauseAction" /> NextAction" /> PreviousAction" /> EnqueueAction" /> SearchCollectio nAction" />
<Extension path = "/Do/Action">
@@ -25,5 +34,7 @@
<Action type = "Banshee.
<Action type = "Banshee.
<Action type = "Banshee.
+ <Action type = "Banshee.
+ <Action type = "Banshee.
</Extension>
</Addin>
=== modified file 'Banshee/ src/Banshee. cs' src/Banshee. cs 2009-01-23 07:32:12 +0000 src/Banshee. cs 2009-03-13 21:55:50 +0000 mutex.ThreadSta te == ThreadState. Running) mutex.ThreadSta te == ThreadState. Unstarted) mutex.ThreadSta te == ThreadState. Unstarted) mutex.Start ();
--- a/Banshee/
+++ b/Banshee/
@@ -53,10 +53,11 @@
{
if (index_
return;
- if (index_
+ else if (index_
index_
- else
+ else {
index_mutex = MakeIndexerThread ();
+ }
}
public static bool IsPlaying {
=== modified file 'Banshee/ src/BansheeDBus .cs' src/BansheeDBus .cs 2009-01-22 04:17:45 +0000 src/BansheeDBus .cs 2009-03-13 21:55:50 +0000
--- a/Banshee/
+++ b/Banshee/
@@ -20,6 +20,7 @@
using System; Collections. Generic;
using System.Linq;
+using System.Threading;
using System.
using NDesk.DBus; oject.Banshee. PlaybackControl ler")] ject.Banshee" ; p.DBus" ;
@@ -45,6 +46,7 @@
[Interface ("org.bansheepr
interface IBansheeController
{
+ void First ();
void Next (bool restart);
void Previous (bool restart);
int ShuffleMode { get; set; }
@@ -53,12 +55,14 @@
public class BansheeDBus
{
const string BusName = "org.bansheepro
+ const string SessionBusName = "org.freedeskto
const string ErrorMessage = "Banshee encountered an error in {0}; {1}";
# region static Banshee d-bus members
static Dictionary<Type, string> object_paths;
+ static IBus session_bus; PathsDict (); ct<T> (string object_path) NameHasOwner (BusName)) { StartServiceByN ame (BusName); Threading. Thread. Sleep (5000); NameHasOwner (BusName)) Format( "Name {0} has no owner.", BusName)); GetObject< IBus> (SessionBusName, new ObjectPath (object_ paths[typeof (IBus)])); bus.NameOwnerCh anged += HandleNameOwner Changed; Changed( string name, string old_owner, string new_owner) Available { NameHasOwner (BusName); } pplication () nAvailable) return;
static IBansheePlayer player;
static IBansheePlayQueue play_queue;
static IBansheeController controller;
@@ -66,18 +70,39 @@
static BansheeDBus ()
{
BuildObject
- }
-
- static T GetIBansheeObje
- {
- if (!Bus.Session.
- Bus.Session.
- System.
- if (!Bus.Session.
- throw new Exception (string.
- }
+ session_bus = Bus.Session.
+ session_
+ }
+
+ static void HandleNameOwner
+ {
+ // when the owner changes on this path, we release our dbus objects.
+ if (name == BusName) {
+ player = null;
+ controller = null;
+ play_queue = null;
+ }
+ }
+
+ static bool FullApplication
+ get { return Bus.Session.
+ }
+
+ static void MaybeStartFullA
+ {
+ if (FullApplicatio
- return Bus.Session. GetObject< T> (BusName, new ObjectPath (object_path)); StartServiceByN ame (BusName); onAvailable) Format( "Name {0} has no owner.", BusName)); ct<T> (string objectPath) pplication (); GetObject< T> (BusName, new ObjectPath (objectPath));
+ Bus.Session.
+ Thread.Sleep (5000);
+
+ if (!FullApplicati
+ throw new Exception (string.
+ }
+
+ static T GetIBansheeObje
+ {
+ MaybeStartFullA
+ return Bus.Session.
}
static IBansheePlayer Player {
@@ -115,9 +140,9 @@
}
public bool IsPlaying () Available) && Player.CurrentState == "playing";
- {
+ {
try {
- return player != null && Player.CurrentState == "playing";
+ return (player != null || FullApplication
} catch (Exception e) {
LogError ("IsPlaying", e);
}
@@ -135,13 +160,13 @@
public void Play ()
{
- Player.Play ();
+ First ();
}
public void Play (IEnumerable< IMediaFile> media)
{
Enqueue (media, true);
- Next ();
+ First ();
}
public void Enqueue (IEnumerable< IMediaFile> media) IMediaFile> media, bool prepend) pplication (); //if banshee isn't already started the enqueue seems to fail
@@ -152,8 +177,11 @@
void Enqueue (IEnumerable<
{
try {
+ MaybeStartFullA
+
// if we're prepending to the queue we need to queue in the uris in reverse order
- if (prepend) media = media.Reverse ();
+ if (prepend)
+ media = media.Reverse ();
media.ForEach (item => PlayQueue. EnqueueUri (item.Path, prepend));
@@ -161,7 +189,7 @@
LogError ("Enqueue", e);
}
}
-
+
public void Next ()
{
try {
@@ -180,9 +208,19 @@
}
}
+ void First () sDict () op/DBus" ); paths.Add (typeof (IBansheePlayer), "/org/bansheepr oject/Banshee/ PlayerEngine" ); paths.Add (typeof (IBansheeContro ller), "/org/bansheepr oject/Banshee/ PlaybackControl ler"); paths.Add (typeof (IBansheePlayQu eue), "/org/bansheepr oject/Banshee/ SourceManager/ PlayQueue" );
+ {
+ try {
+ Controller.First ();
+ } catch (Exception e) {
+ LogError ("First", e);
+ }
+ }
+
static void BuildObjectPath
{
object_paths = new Dictionary<Type, string> ();
+ object_paths.Add (typeof (IBus), "/org/freedeskt
object_
object_
object_
=== modified file 'Banshee/ src/PauseAction .cs' src/PauseAction .cs 2009-01-22 03:02:27 +0000 src/PauseAction .cs 2009-03-13 21:55:50 +0000
--- a/Banshee/
+++ b/Banshee/
@@ -22,6 +22,7 @@
using Mono.Unix;
+using Do.Platform;
using Do.Universe;
namespace Banshee
=== modified file 'Banshee/ src/PlayAction. cs' src/PlayAction. cs 2009-01-22 01:04:35 +0000 src/PlayAction. cs 2009-03-13 21:55:50 +0000 Cast<MediaItem> ().First ()); OfType< MediaItem> ().First ());
--- a/Banshee/
+++ b/Banshee/
@@ -63,11 +63,16 @@
public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
{
if (items.First () is MediaItem)
- Banshee.Play (items.
+ Banshee.Play (items.
else
Banshee.Play ();
yield break;
}
+
+ protected override bool IsAvailable ()
+ {
+ return !Banshee.IsPlaying;
+ }
}
}
\ No newline at end of file