public DaapTrackInfo(Track track, DaapSource source) : base() { TrackTitle = track.Title; AlbumTitle = track.Album; ArtistName = track.Artist; DateAdded = track.DateAdded; DateUpdated = track.DateModified; Genre = track.Genre; FileSize = track.Size; TrackCount = track.TrackCount; TrackNumber = track.TrackNumber; DiscNumber = track.DiscNumber; DiscCount = track.DiscCount; Year = track.Year; Duration = track.Duration; MimeType = track.Format; BitRate = (int)track.BitRate; ExternalId = track.Id; PrimarySource = source; Uri = new SafeUri (String.Format ( "{0}{1}/{2}", DaapService.ProxyServer.HttpBaseAddress, source.Database.GetHashCode (), track.Id )); //this.IsLive = false; //this.CanSaveToDatabase = false; }
public TrackArgs(Track track) { this.track = track; }
public Stream StreamTrack(Track track, long offset, out long length) { return StreamTrack (track.Id, track.Format, offset, out length); }
public Stream StreamTrack(Track track, out long length) { return StreamTrack (track, -1, out length); }
public void RemoveTrack(Track track) { tracks.Remove (track); basePlaylist.RemoveTrack (track); foreach (Playlist pl in playlists) { pl.RemoveTrack (track); } if (TrackRemoved != null) TrackRemoved (this, new TrackArgs (track)); }
public void AddTrack(Track track) { if (track.Id == 0) track.SetId (nextTrackId++); tracks.Add (track); basePlaylist.AddTrack (track); if (TrackAdded != null) TrackAdded (this, new TrackArgs (track)); }
protected override void HandleValidRequest(Socket client, string [] split_request, string [] body_request) { if (split_request[1].StartsWith("/")) { split_request[1] = split_request[1].Substring(1); } string [] nodes = split_request[1].Split('/'); string body = String.Empty; HttpStatusCode code = HttpStatusCode.OK; if (nodes.Length == 1 && nodes[0] == String.Empty) { body = GetHtmlHeader("Available Databases"); if (databases.Count == 0) { body += "<blockquote><p><em>No databases found. Connect to a " + "share in Banshee.</em></p></blockquote>"; } else { body += "<ul>"; foreach (DAAP.Database database in (ArrayList)databases.Clone()) { body += String.Format("<li><a href=\"/{0}\">{1} ({2} Tracks)</a></li>", database.GetHashCode(), Escape(database.Name), database.TrackCount); } body += "</ul>"; } } else if (nodes.Length == 1 && nodes[0] != String.Empty) { bool db_found = false; int id = 0; try { id = Convert.ToInt32(nodes[0]); } catch { } foreach (DAAP.Database database in (ArrayList)databases.Clone()) { if (database.GetHashCode() != id) { continue; } body = GetHtmlHeader("Tracks in " + Escape(database.Name)); if (database.TrackCount == 0) { body += "<blockquote><p><em>No songs in this database.</em></p></blockquote>"; } else { body += "<p>Showing all " + database.TrackCount + " songs:</p><ul>"; foreach (DAAP.Track song in database.Tracks) { body += String.Format("<li><a href=\"/{0}/{1}\">{2} - {3}</a> ({4}:{5})</li>", database.GetHashCode(), song.Id, Escape(song.Artist), Escape(song.Title), song.Duration.Minutes, song.Duration.Seconds.ToString("00")); } body += "</ul>"; } db_found = true; break; } if (!db_found) { code = HttpStatusCode.BadRequest; body = GetHtmlHeader("Invalid Request"); body += String.Format("<p>No database with id `{0}'</p>", id); } } else if (nodes.Length == 2) { bool db_found = false; int db_id = 0; int song_id = 0; try { db_id = Convert.ToInt32(nodes[0]); song_id = Convert.ToInt32(nodes[1]); } catch { } foreach (DAAP.Database database in (ArrayList)databases.Clone()) { if (database.GetHashCode() != db_id) { continue; } try { DAAP.Track song = database.LookupTrackById(song_id); if (song != null) { long offset = -1; foreach (string line in body_request) { if (line.ToLower().Contains("range:")) { offset = ParseRangeRequest(line); } } StreamTrack(client, database, song, offset); return; } } catch (Exception e) { Log.Error(e); } code = HttpStatusCode.BadRequest; body = GetHtmlHeader("Invalid Request"); body += String.Format("<p>No song with id `{0}'</p>", song_id); db_found = true; break; } if (!db_found) { code = HttpStatusCode.BadRequest; body = GetHtmlHeader("Invalid Request"); body += String.Format("<p>No database with id `{0}'</p>", db_id); } } else { code = HttpStatusCode.BadRequest; body = GetHtmlHeader("Invalid Request"); body += String.Format("<p>The request '{0}' could not be processed by server.</p>", Escape(split_request[1])); } WriteResponse(client, code, body + GetHtmlFooter()); }
private bool Equals(Track track) { return artist == track.Artist && album == track.Album && title == track.Title && year == track.Year && format == track.Format && duration == track.Duration && size == track.Size && genre == track.Genre && trackNumber == track.TrackNumber && trackCount == track.TrackCount && dateAdded == track.DateAdded && dateModified == track.DateModified && bitrate == track.BitRate; }
protected void StreamTrack(Socket client, DAAP.Database database, DAAP.Track song) { StreamTrack(client, database, song, -1); }
internal void Update(Track track) { if (Equals (track)) return; artist = track.Artist; album = track.Album; title = track.Title; year = track.Year; format = track.Format; duration = track.Duration; size = track.Size; genre = track.Genre; trackNumber = track.TrackNumber; trackCount = track.TrackCount; dateAdded = track.DateAdded; dateModified = track.DateModified; bitrate = track.BitRate; EmitUpdated (); }
internal static void FromPlaylistNode(Database db, ContentNode node, out Track track, out int containerId) { track = null; containerId = 0; foreach (ContentNode field in (ContentNode[]) node.Value) { switch (field.Name) { case "dmap.itemid": track = db.LookupTrackById ((int) field.Value); break; case "dmap.containeritemid": containerId = (int) field.Value; break; default: break; } } }
internal static Track FromNode(ContentNode node) { Track track = new Track (); foreach (ContentNode field in (ContentNode[]) node.Value) { switch (field.Name) { case "dmap.itemid": track.id = (int) field.Value; break; case "daap.songartist": track.artist = (string) field.Value; break; case "dmap.itemname": track.title = (string) field.Value; break; case "daap.songalbum": track.album = (string) field.Value; break; case "daap.songtime": track.duration = TimeSpan.FromMilliseconds ((int) field.Value); break; case "daap.songformat": track.format = (string) field.Value; break; case "daap.songgenre": track.genre = (string) field.Value; break; case "daap.songsize": track.size = (int) field.Value; break; case "daap.songtrackcount": track.trackCount = (short) field.Value; break; case "daap.songtracknumber": track.trackNumber = (short) field.Value; break; case "daap.bitrate": track.bitrate = (short) field.Value; break; case "daap.songdateadded": track.dateAdded = (DateTime) field.Value; break; case "daap.songdatemodified": track.dateModified = (DateTime) field.Value; break; case "daap.songdiscnumber": track.discNumber = (short) field.Value; break; case "daap.songdisccount": track.discCount = (short) field.Value; break; default: break; } } return track; }
public object Clone() { Track track = new Track (); track.artist = artist; track.album = album; track.title = title; track.year = year; track.format = format; track.duration = duration; track.id = id; track.size = size; track.genre = genre; track.trackNumber = trackNumber; track.trackCount = trackCount; track.fileName = fileName; track.dateAdded = dateAdded; track.dateModified = dateModified; track.bitrate = bitrate; return track; }
internal static Track FromNode(ContentNode node) { Track track = new Track(); foreach (ContentNode field in (ContentNode[])node.Value) { switch (field.Name) { case "dmap.itemid": track.id = (int)field.Value; break; case "daap.songartist": track.artist = (string)field.Value; break; case "dmap.itemname": track.title = (string)field.Value; break; case "daap.songalbum": track.album = (string)field.Value; break; case "daap.songtime": track.duration = TimeSpan.FromMilliseconds((int)field.Value); break; case "daap.songformat": track.format = (string)field.Value; break; case "daap.songgenre": track.genre = (string)field.Value; break; case "daap.songsize": track.size = (int)field.Value; break; case "daap.songtrackcount": track.trackCount = (short)field.Value; break; case "daap.songtracknumber": track.trackNumber = (short)field.Value; break; case "daap.bitrate": track.bitrate = (short)field.Value; break; case "daap.songdateadded": track.dateAdded = (DateTime)field.Value; break; case "daap.songdatemodified": track.dateModified = (DateTime)field.Value; break; case "daap.songdiscnumber": track.discNumber = (short)field.Value; break; case "daap.songdisccount": track.discCount = (short)field.Value; break; default: break; } } return(track); }