summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Bockover <abock@src.gnome.org>2005-08-30 09:13:48 +0000
committerAaron Bockover <abock@src.gnome.org>2005-08-30 09:13:48 +0000
commitba022687dac8af886970ad399d568bf9b4b20369 (patch)
treeed63ec126d27372c9a32da23c550cf75c91ae280
parentadde8dff07e0bb9aa2be6de905a827db16b37be4 (diff)
Command line playback control options, iPod syncing, no CD Burning in UI anymoreBANSHEE_0_9_1
-rw-r--r--ChangeLog1
-rw-r--r--libbanshee/cd-info.c9
-rw-r--r--mediaengines/helix/HelixPlayer.cs2
-rw-r--r--src/DBusIPC.cs25
-rw-r--r--src/DebugLog.cs6
-rw-r--r--src/IpodCore.cs137
-rw-r--r--src/Main.cs24
-rw-r--r--src/PlayerInterface.cs40
8 files changed, 229 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index b61b5aa04..72377c733 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
2005-08-29 Aaron Bockover <aaron@aaronbock.net>
+ * mediaengines/helix/HelixPlayer.cs: Fixed PCM set to 0 bug (314816)
* libbanshee/cd-info.c: More internals complete/working, cdparanoia
fix in patched gstreamer
* src/DBusIPC.cs: Virtual D-Bus methods for TogglePlaying(), Next(),
diff --git a/libbanshee/cd-info.c b/libbanshee/cd-info.c
index e892f4dc8..80c9ffed4 100644
--- a/libbanshee/cd-info.c
+++ b/libbanshee/cd-info.c
@@ -118,7 +118,7 @@ cd_disk_info_load(CdDiskInfo *disk)
sector_format = gst_format_get_by_nick("sector");
source_pad = gst_element_get_pad(source, "src");
- gst_element_set_state(source, GST_STATE_PAUSED);
+ gst_element_set_state(source, GST_STATE_PLAYING);
gst_pad_query(source_pad, GST_QUERY_TOTAL, &track_format,
&(disk->n_tracks));
@@ -129,6 +129,9 @@ cd_disk_info_load(CdDiskInfo *disk)
gst_pad_convert(source_pad, sector_format, disk->total_sectors,
&time_format, &(disk->total_time));
+ g_printf("TOTAL_SECTORS: %lld\n", disk->total_sectors);
+ g_printf("TOTAL_TIME: %lld\n", disk->total_time / GST_SECOND);
+
if(disk->n_tracks <= 0) {
gst_element_set_state(source, GST_STATE_NULL);
gst_object_unref(GST_OBJECT(source));
@@ -150,6 +153,10 @@ cd_disk_info_load(CdDiskInfo *disk)
if(i > 0) {
disk->tracks[i - 1] = cd_track_info_new(i - 1, start_sector,
end_sector);
+
+ g_printf("START,END SECTOR: %lld, %lld\n",
+ disk->tracks[i - 1]->start_sector,
+ disk->tracks[i - 1]->end_sector);
}
start_sector = end_sector;
diff --git a/mediaengines/helix/HelixPlayer.cs b/mediaengines/helix/HelixPlayer.cs
index 636999de3..6b521dc5b 100644
--- a/mediaengines/helix/HelixPlayer.cs
+++ b/mediaengines/helix/HelixPlayer.cs
@@ -129,8 +129,6 @@ namespace Banshee
public void TestInitialize()
{
HxPlayer testplayer = new HxPlayer();
- ushort testvol = testplayer.Volume;
- testplayer.Volume = testvol;
}
public void Dispose()
diff --git a/src/DBusIPC.cs b/src/DBusIPC.cs
index aaa9174f6..814738c2b 100644
--- a/src/DBusIPC.cs
+++ b/src/DBusIPC.cs
@@ -66,6 +66,7 @@ namespace Banshee
public class BansheeCore
{
private Gtk.Window mainWindow;
+ private PlayerUI PlayerUI;
public static BansheeCore FindInstance()
{
@@ -75,9 +76,10 @@ namespace Banshee
"/org/gnome/Banshee/Core");
}
- public BansheeCore(Gtk.Window mainWindow)
+ public BansheeCore(Gtk.Window mainWindow, PlayerUI ui)
{
this.mainWindow = mainWindow;
+ this.PlayerUI = ui;
}
[Method]
@@ -86,6 +88,27 @@ namespace Banshee
if(mainWindow != null)
mainWindow.Present();
}
+
+ [Method]
+ public virtual void TogglePlaying()
+ {
+ if(PlayerUI != null)
+ PlayerUI.TogglePlaying();
+ }
+
+ [Method]
+ public virtual void Next()
+ {
+ if(PlayerUI != null)
+ PlayerUI.Next();
+ }
+
+ [Method]
+ public virtual void Previous()
+ {
+ if(PlayerUI != null)
+ PlayerUI.Previous();
+ }
}
}
diff --git a/src/DebugLog.cs b/src/DebugLog.cs
index 6f888a452..5f02b7bda 100644
--- a/src/DebugLog.cs
+++ b/src/DebugLog.cs
@@ -38,7 +38,7 @@ namespace Banshee
public static void Add(string message, params object[] args)
{
- try {
+ /*try {
StackFrame sf = new StackFrame(1, true);
//string methodName = sf.GetMethod().ToString();
string fileName = sf.GetFileName().ToString();
@@ -49,10 +49,10 @@ namespace Banshee
Path.GetFileName(fileName)).PadRight(18),
String.Format("[{0}]", lineNumber++).PadRight(6),
String.Format(message, args));
- } catch(Exception) {
+ } catch(Exception) {*/
Console.WriteLine("{0}: {1}", callNumber++,
String.Format(message, args));
- }
+ //}
}
}
}
diff --git a/src/IpodCore.cs b/src/IpodCore.cs
index 9bde4c49c..6cbb10835 100644
--- a/src/IpodCore.cs
+++ b/src/IpodCore.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
+using Mono.Posix;
using IPod;
namespace Banshee
@@ -49,8 +50,9 @@ namespace Banshee
devices = new Hashtable();
- foreach(Device device in Device.ListDevices())
+ foreach(Device device in Device.ListDevices()) {
devices[device.VolumeId] = device;
+ }
}
public void Dispose()
@@ -95,4 +97,137 @@ namespace Banshee
}
}
}
+
+ public class IpodSyncTransaction : LibraryTransaction
+ {
+ public override string Name {
+ get {
+ return "iPod Sync Transaction";
+ }
+ }
+
+ private Device device;
+ private bool iPodUpdating = false;
+
+ public IpodSyncTransaction(Device device)
+ {
+ this.device = device;
+ showCount = false;
+ }
+
+ private bool TrackCompare(LibraryTrackInfo libTrack, Song song)
+ {
+ return song.Title.ToLower() == libTrack.Title.ToLower() &&
+ song.Album.ToLower() == libTrack.Album.ToLower() &&
+ song.Artist.ToLower() == libTrack.Artist.ToLower() &&
+ song.Length / 1000 == libTrack.Duration;
+ }
+
+ private bool ExistsOnIpod(LibraryTrackInfo libTrack)
+ {
+ foreach(Song song in device.SongDatabase.Songs) {
+ if(TrackCompare(libTrack, song))
+ return true;
+ }
+
+ return false;
+ }
+
+ private bool ExistsInLibrary(Song song)
+ {
+ foreach(LibraryTrackInfo libTrack in Core.Library.Tracks.Values) {
+ if(TrackCompare(libTrack, song))
+ return true;
+ }
+
+ return false;
+ }
+
+ public override void Run()
+ {
+ statusMessage = String.Format(Catalog.GetString(
+ "Preparing to sync '{0}'"), device.Name);
+
+ currentCount = 0;
+ totalCount = 0;
+
+ bool doUpdate = false;
+
+ foreach(Song song in device.SongDatabase.Songs) {
+ if(ExistsInLibrary(song))
+ continue;
+
+ device.SongDatabase.RemoveSong(song);
+ doUpdate = true;
+ }
+
+ foreach(LibraryTrackInfo libTrack in Core.Library.Tracks.Values) {
+ if(ExistsOnIpod(libTrack))
+ continue;
+
+ Song song = device.SongDatabase.CreateSong();
+ song.Album = libTrack.Album;
+ song.Artist = libTrack.Artist;
+ song.Title = libTrack.Title;
+ song.Genre = libTrack.Genre;
+ song.Length = (int)(libTrack.Duration * 1000);
+ song.TrackNumber = (int)libTrack.TrackNumber;
+ song.TotalTracks = (int)libTrack.TrackCount;
+ song.Filename = libTrack.Uri;
+ song.Year = (int)libTrack.Year;
+
+ if(song.Artist == null)
+ song.Artist = String.Empty;
+
+ if(song.Album == null)
+ song.Album = String.Empty;
+
+ if(song.Title == null)
+ song.Title = String.Empty;
+
+ if(song.Genre == null)
+ song.Genre = String.Empty;
+
+ doUpdate = true;
+ }
+
+ if(!doUpdate)
+ return;
+
+ device.SongDatabase.SaveStarted += OnSaveStarted;
+ device.SongDatabase.SaveProgressChanged += OnSaveProgressChanged;
+ device.SongDatabase.SaveEnded += OnSaveEnded;
+
+ device.SongDatabase.Save();
+
+ iPodUpdating = true;
+ Console.WriteLine("SAVE BLOCKING");
+ while(iPodUpdating);
+
+ Console.WriteLine("SAVE DONE");
+ }
+
+ private void OnSaveStarted(object o, EventArgs args)
+ {
+ iPodUpdating = true;
+ Console.WriteLine("SAVE STARTED");
+ }
+
+ private void OnSaveEnded(object o, EventArgs args)
+ {
+ iPodUpdating = false;
+ }
+
+ private void OnSaveProgressChanged(SongDatabase db, Song song,
+ double currentPercent, int completed, int total)
+ {
+ currentCount = completed;
+ totalCount = total;
+ statusMessage = String.Format(Catalog.GetString(
+ "Copying {0} - {1}"), song.Artist, song.Title);
+
+ if(total >= completed - 1)
+ iPodUpdating = false;
+ }
+ }
}
diff --git a/src/Main.cs b/src/Main.cs
index 922f11271..3f324d858 100644
--- a/src/Main.cs
+++ b/src/Main.cs
@@ -42,9 +42,29 @@ namespace Banshee
} catch { }
if(dbusCore != null) {
- dbusCore.PresentWindow();
+ bool present = true;
+
+ if(args.Length > 0) {
+ switch(args[0]) {
+ case "--play-pause":
+ dbusCore.TogglePlaying();
+ present = false;
+ break;
+ case "--next":
+ dbusCore.Next();
+ present = false;
+ break;
+ case "--previous":
+ dbusCore.Previous();
+ present = false;
+ break;
+ }
+ }
+
+ if(present)
+ dbusCore.PresentWindow();
return;
- }
+ }
System.Reflection.AssemblyName asm =
System.Reflection.Assembly.GetEntryAssembly().GetName();
diff --git a/src/PlayerInterface.cs b/src/PlayerInterface.cs
index 0cbddc84f..e05c38f55 100644
--- a/src/PlayerInterface.cs
+++ b/src/PlayerInterface.cs
@@ -279,6 +279,11 @@ namespace Banshee
ipodDiskUsageBar = new ProgressBar();
box.PackStart(ipodDiskUsageBar, false, false, 0);
+ Button ipodSyncButton = new Button(
+ new Gtk.Image("gtk-copy", IconSize.Menu));
+ ipodSyncButton.Clicked += OnIpodSyncClicked;
+ box.PackStart(ipodSyncButton, false, false, 0);
+
Button ipodPropertiesButton = new Button(
new Gtk.Image("gtk-properties", IconSize.Menu));
ipodPropertiesButton.Clicked += OnIpodPropertiesClicked;
@@ -327,11 +332,14 @@ namespace Banshee
SetTip(gxml["ScaleTime"], Catalog.GetString("Current Position in Song"));
SetTip(volumeButton, Catalog.GetString("Adjust Volume"));
SetTip(ipodDiskUsageBar, Catalog.GetString("iPod Disk Usage"));
+ SetTip(ipodEjectButton, Catalog.GetString("Eject iPod"));
+ SetTip(ipodSyncButton, Catalog.GetString("Synchronize Music Library to iPod"));
+ SetTip(ipodPropertiesButton, Catalog.GetString("View iPod Properties"));
playlistMenuMap = new Hashtable();
Core.Instance.DBusServer.RegisterObject(
- new BansheeCore(Window), "/org/gnome/Banshee/Core");
+ new BansheeCore(Window, this), "/org/gnome/Banshee/Core");
}
private void SetTip(Widget widget, string tip)
@@ -514,8 +522,8 @@ namespace Banshee
LabelInfo.Markup = "<span size=\"small\">" + text + "</span>";
}
- private void TogglePlaying()
- {
+ public void TogglePlaying()
+ {
if(Core.Instance.Player.Playing) {
ImagePlayPause.SetFromStock("media-play",
IconSize.LargeToolbar);
@@ -642,18 +650,28 @@ namespace Banshee
playlistView.PlaySelected();
}
- private void OnButtonPreviousClicked(object o, EventArgs args)
+ public void Previous()
{
playlistModel.Regress();
playlistView.UpdateView();
}
- private void OnButtonNextClicked(object o, EventArgs args)
+ public void Next()
{
playlistModel.Advance();
playlistView.UpdateView();
}
+ private void OnButtonPreviousClicked(object o, EventArgs args)
+ {
+ Previous();
+ }
+
+ private void OnButtonNextClicked(object o, EventArgs args)
+ {
+ Next();
+ }
+
private void OnVolumeScaleChanged(int volume)
{
Core.Instance.Player.Volume = (ushort)volume;
@@ -920,6 +938,18 @@ namespace Banshee
ShowSourceProperties(sourceView.SelectedSource);
}
+ private void OnIpodSyncClicked(object o, EventArgs args)
+ {
+ if(sourceView.SelectedSource.Type != SourceType.Ipod)
+ return;
+
+ IpodSource ipodSource = sourceView.SelectedSource as IpodSource;
+ IPod.Device device = ipodSource.Device;
+
+ IpodSyncTransaction sync = new IpodSyncTransaction(device);
+ sync.Register();
+ }
+
private void OnIpodEjectClicked(object o, EventArgs args)
{
EjectSource(sourceView.SelectedSource);