[banshee: 13/57] While we prefer MusicTrack allow just AudioItem to be added also, allows less correct servers to sti
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee: 13/57] While we prefer MusicTrack allow just AudioItem to be added also, allows less correct servers to sti
- Date: Mon, 13 Feb 2012 20:28:54 +0000 (UTC)
commit bb3c555243ec955a4ab5f591eb343f0683361fa7
Author: Tobias Arrskog <topfs2 xbmc org>
Date: Tue Jun 14 23:39:34 2011 +0200
While we prefer MusicTrack allow just AudioItem to be added also, allows less correct servers to still show up in GUI
.../Banshee.UPnPClient/UPnPSource.cs | 17 ++++++++++--
.../Banshee.UPnPClient/UPnPTrackInfo.cs | 27 ++++++++++++++++++++
2 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPSource.cs b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPSource.cs
index bb1be5f..8f9e2d8 100644
--- a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPSource.cs
+++ b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPSource.cs
@@ -130,14 +130,25 @@ namespace Banshee.UPnPClient
foreach (var item in contentDirectory.GetChildren<Mono.Upnp.Dcp.MediaServer1.ContentDirectory1.Object>(container))
{
- if (item is MusicTrack)
- AddTrack(item as MusicTrack);
+ if (item is AudioItem)
+ {
+ if (item is MusicTrack)
+ AddMusicTrack(item as MusicTrack);
+ else
+ AddAudioItem(item as AudioItem);
+ }
else if (item is Container)
ParseContainer(contentDirectory, item as Container, depth + 1);
}
}
- private void AddTrack(MusicTrack basetrack)
+ private void AddMusicTrack(MusicTrack basetrack)
+ {
+ UPnPTrackInfo track = new UPnPTrackInfo (basetrack, this);
+ track.Save();
+ }
+
+ private void AddAudioItem(AudioItem basetrack)
{
UPnPTrackInfo track = new UPnPTrackInfo (basetrack, this);
track.Save();
diff --git a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPTrackInfo.cs b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPTrackInfo.cs
index beda097..ed0da49 100644
--- a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPTrackInfo.cs
+++ b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPTrackInfo.cs
@@ -42,6 +42,33 @@ namespace Banshee.UPnPClient
{
static long id = 0;
+ public UPnPTrackInfo (AudioItem track, UPnPSource source) : base()
+ {
+ if (track != null)
+ {
+ TrackTitle = track.Title;
+
+ if (track.Resources.Count > 0)
+ {
+ Resource resource = track.Resources[0];
+
+ BitRate = (int)resource.BitRate.GetValueOrDefault();
+ BitsPerSample = (int)resource.BitsPerSample.GetValueOrDefault();
+ Duration = resource.Duration.GetValueOrDefault();
+ SampleRate = (int)resource.SampleFrequency.GetValueOrDefault();
+ FileSize = (int)resource.Size.GetValueOrDefault();
+
+ Uri = new SafeUri(resource.Uri);
+ }
+ else
+ CanPlay = false;
+ }
+
+ ExternalId = ++id;
+
+ PrimarySource = source;
+ }
+
public UPnPTrackInfo (MusicTrack track, UPnPSource source) : base()
{
if (track != null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]