banshee r3073 - in trunk/banshee: . src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.PlaybackController src/Core/Banshee.Services/Banshee.Playlist
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3073 - in trunk/banshee: . src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.PlaybackController src/Core/Banshee.Services/Banshee.Playlist
- Date: Tue, 29 Jan 2008 00:51:33 +0000 (GMT)
Author: abock
Date: Tue Jan 29 00:51:33 2008
New Revision: 3073
URL: http://svn.gnome.org/viewvc/banshee?rev=3073&view=rev
Log:
2008-01-28 Aaron Bockover <abock gnome org>
Okay, 5% to go with the play queue ... it's working
* src/Core/Banshee.Services/Banshee.Playlist/PlayQueueSource.cs: Implement
the actual play queue logic in the proper place this time; remove the
top track when done playing/skipped
* src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs:
Added a Transition event that the controller will raise before performing
any transition methods (Next, Previous)
* src/Core/Banshee.Services/Banshee.PlaybackController/IBasicPlaybackController.cs:
* src/Core/Banshee.Services/Banshee.PlaybackController/ICanonicalPlaybackController.cs:
* src/Core/Banshee.Services/Banshee.PlaybackController/IPlaybackController.cs:
Fix up interface dependency chain
Added:
trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/IBasicPlaybackController.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/ICanonicalPlaybackController.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/IPlaybackController.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlayQueueSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
trunk/banshee/src/Core/Banshee.Services/Makefile.am
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/IBasicPlaybackController.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/IBasicPlaybackController.cs Tue Jan 29 00:51:33 2008
@@ -0,0 +1,37 @@
+//
+// IBasicPlaybackController.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace Banshee.PlaybackController
+{
+ public interface IBasicPlaybackController
+ {
+ void First ();
+ void Next ();
+ void Previous ();
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/ICanonicalPlaybackController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/ICanonicalPlaybackController.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/ICanonicalPlaybackController.cs Tue Jan 29 00:51:33 2008
@@ -26,11 +26,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-
namespace Banshee.PlaybackController
{
- public interface ICanonicalPlaybackController
+ public interface ICanonicalPlaybackController : IPlaybackController
{
void First ();
void Next ();
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/IPlaybackController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/IPlaybackController.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/IPlaybackController.cs Tue Jan 29 00:51:33 2008
@@ -26,20 +26,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-
namespace Banshee.PlaybackController
{
public delegate void PlaybackControllerStoppedHandler ();
- public interface IPlaybackController
+ public interface IPlaybackController : IBasicPlaybackController
{
event PlaybackControllerStoppedHandler Stopped;
- void First ();
- void Next ();
- void Previous ();
-
PlaybackShuffleMode ShuffleMode { get; set; }
PlaybackRepeatMode RepeatMode { get; set; }
bool StopWhenFinished { get; set; }
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs Tue Jan 29 00:51:33 2008
@@ -62,15 +62,15 @@
private PlayerEngineService player_engine;
private ITrackModelSource source;
- public event EventHandler Stopped;
-
private event PlaybackControllerStoppedHandler dbus_stopped;
event PlaybackControllerStoppedHandler IPlaybackController.Stopped {
add { dbus_stopped += value; }
remove { dbus_stopped -= value; }
}
+ public event EventHandler Stopped;
public event EventHandler SourceChanged;
+ public event EventHandler Transition;
public PlaybackControllerService ()
{
@@ -117,8 +117,10 @@
public void First ()
{
- if (Source is IPlaybackController) {
- ((IPlaybackController)Source).First ();
+ OnTransition ();
+
+ if (Source is IBasicPlaybackController) {
+ ((IBasicPlaybackController)Source).First ();
} else {
((ICanonicalPlaybackController)this).First ();
}
@@ -126,8 +128,10 @@
public void Next ()
{
- if (Source is IPlaybackController) {
- ((IPlaybackController)Source).Next ();
+ OnTransition ();
+
+ if (Source is IBasicPlaybackController) {
+ ((IBasicPlaybackController)Source).Next ();
} else {
((ICanonicalPlaybackController)this).Next ();
}
@@ -135,8 +139,10 @@
public void Previous ()
{
- if (Source is IPlaybackController) {
- ((IPlaybackController)Source).Previous ();
+ OnTransition ();
+
+ if (Source is IBasicPlaybackController) {
+ ((IBasicPlaybackController)Source).Previous ();
} else {
((ICanonicalPlaybackController)this).Previous ();
}
@@ -227,6 +233,14 @@
}
}
+ protected virtual void OnTransition ()
+ {
+ EventHandler handler = Transition;
+ if (handler != null) {
+ handler (this, EventArgs.Empty);
+ }
+ }
+
protected virtual void OnSourceChanged ()
{
EventHandler handler = SourceChanged;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlayQueueSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlayQueueSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlayQueueSource.cs Tue Jan 29 00:51:33 2008
@@ -33,20 +33,27 @@
using Hyena.Data.Sqlite;
using Banshee.ServiceStack;
+using Banshee.Sources;
using Banshee.Database;
+using Banshee.Collection;
using Banshee.Collection.Database;
+using Banshee.PlaybackController;
+using Banshee.MediaEngine;
namespace Banshee.Playlist
{
- public class PlayQueueSource : PlaylistSource
+ public class PlayQueueSource : PlaylistSource, IBasicPlaybackController
{
private static string special_playlist_name = typeof (PlayQueueSource).ToString ();
private static PlayQueueSource instance;
public static PlayQueueSource Instance {
- get { return instance; }
+ get { lock (typeof (PlayQueueSource)) { return instance; } }
+ private set { lock (typeof (PlayQueueSource)) { instance = value; } }
}
-
+
+ private LibraryTrackInfo playing_track;
+
public PlayQueueSource () : base (Catalog.GetString ("Play Queue"), null)
{
BindToDatabase ();
@@ -56,8 +63,11 @@
((TrackListDatabaseModel)TrackModel).ForcedSortQuery = "CorePlaylistEntries.EntryID DESC";
- if (instance == null) {
- instance = this;
+ ServiceManager.PlayerEngine.EventChanged += OnPlayerEngineEventChanged;
+ ServiceManager.PlaybackController.Transition += OnCanonicalPlaybackControllerTransition;
+
+ if (Instance == null) {
+ Instance = this;
}
}
@@ -76,6 +86,51 @@
}
}
+ private void OnCanonicalPlaybackControllerTransition (object o, EventArgs args)
+ {
+ if (Count > 0) {
+ ServiceManager.PlaybackController.Source = this;
+ }
+ }
+
+ private void OnPlayerEngineEventChanged (object o, PlayerEngineEventArgs args)
+ {
+ if (args.Event == PlayerEngineEvent.EndOfStream) {
+ RemoveFirstTrack ();
+ }
+ }
+
+ void IBasicPlaybackController.First ()
+ {
+ }
+
+ void IBasicPlaybackController.Next ()
+ {
+ RemoveFirstTrack ();
+
+ if (Count <= 0) {
+ playing_track = null;
+ ServiceManager.PlaybackController.Source = (ITrackModelSource)ServiceManager.SourceManager.DefaultSource;
+ ServiceManager.PlaybackController.Next ();
+ return;
+ }
+
+ playing_track = (LibraryTrackInfo)TrackModel[0];
+ ServiceManager.PlayerEngine.OpenPlay (playing_track);
+ }
+
+ void IBasicPlaybackController.Previous ()
+ {
+ }
+
+ private void RemoveFirstTrack ()
+ {
+ if (playing_track != null) {
+ RemoveTrack (playing_track);
+ playing_track = null;
+ }
+ }
+
public override bool CanRename {
get { return false; }
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp Tue Jan 29 00:51:33 2008
@@ -115,6 +115,7 @@
<File name="Banshee.PlaybackController/PlaybackControllerService.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.PlaybackController/IPlaybackControllerExportable.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.PlaybackController/ICanonicalPlaybackController.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.PlaybackController/IBasicPlaybackController.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am Tue Jan 29 00:51:33 2008
@@ -58,6 +58,7 @@
Banshee.Metadata/MetadataSettings.cs \
Banshee.Networking/NetworkDetect.cs \
Banshee.Networking/NetworkManager.cs \
+ Banshee.PlaybackController/IBasicPlaybackController.cs \
Banshee.PlaybackController/ICanonicalPlaybackController.cs \
Banshee.PlaybackController/IPlaybackController.cs \
Banshee.PlaybackController/IPlaybackControllerExportable.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]