public static string Conductor(upnpObject aObject) { string result = string.Empty; if (aObject is musicTrack) { musicTrack item = aObject as musicTrack; foreach (artist a in item.Artist) { if (a.Role != null && a.Role.ToLower() == "conductor") { result = a.Artist; } } } else if (aObject is musicVideoClip) { musicVideoClip item = aObject as musicVideoClip; foreach (artist a in item.Artist) { if (a.Role != null && a.Role.ToLower() == "conductor") { result = a.Artist; } } } // always return a non-null string return(NonNullString(result)); }
public static string Album(upnpObject aObject) { string result = string.Empty; if (aObject is musicAlbum) { musicAlbum album = aObject as musicAlbum; result = album.Title; } else if (aObject is musicVideoClip) { musicVideoClip item = aObject as musicVideoClip; if (item.Album.Count > 0) { result = item.Album[0]; } } else if (aObject is musicTrack) { musicTrack item = aObject as musicTrack; if (item.Album.Count > 0) { result = item.Album[0]; } } // always return a non-null string return(NonNullString(result)); }
public static string Description(upnpObject aObject) { string result = string.Empty; if (aObject is audioItem) { audioItem item = aObject as audioItem; result = item.Description; } else if (aObject is videoItem) { videoItem item = aObject as videoItem; result = item.Description; } else if (aObject is album) { album item = aObject as album; result = item.Description; } else if (aObject is playlistContainer) { playlistContainer item = aObject as playlistContainer; result = item.Description; } // always return a non-null string return(NonNullString(result)); }
public upnpObject Item(uint aIndex) { upnpObject item = null; iMutex.WaitOne(); if (iContent != null) { item = iContent[aIndex]; if (item == null) { int startIndex = (int)aIndex - 50; if (startIndex < 0) { startIndex = 0; } int count = 100; if (startIndex + count > iContent.Length) { count = iContent.Length - startIndex; } if ((iStartIndex == -1 && iCount == -1) || (startIndex > iStartIndex + iCount && startIndex + count < iStartIndex)) { Trace.WriteLine(Trace.kKinsky, "item at " + aIndex + " not found downloading range(" + startIndex + "," + count + ")"); Range((uint)startIndex, (uint)count); } } } iMutex.ReleaseMutex(); return(item); }
public bool IsPlayingSender(ModelSender aSender) { bool playingSender = false; if (this.Channel != null && aSender != null) { if (this.TransportState == ModelSourceReceiver.ETransportState.ePlaying || this.TransportState == ModelSourceReceiver.ETransportState.eBuffering || this.TransportState == ModelSourceReceiver.ETransportState.eWaiting) { if (aSender.Metadata.Count > 0 && this.Channel.DidlLite.Count > 0) { upnpObject sender = aSender.Metadata[0]; upnpObject receiver = this.Channel.DidlLite[0]; if (sender.Res.ToString() == receiver.Res.ToString() && DidlLiteAdapter.Title(sender) == DidlLiteAdapter.Title(receiver)) { playingSender = true; } } } } return(playingSender); }
private void UpdateComboBox(DidlLite aDidlLite) { if (comboBox1.InvokeRequired) { comboBox1.BeginInvoke(new UpdateComboBoxCallback(UpdateComboBox), new object[] { aDidlLite }); } else { string selection = string.Empty; if (comboBox1.SelectedIndex > -1) { selection = comboBox1.Items[comboBox1.SelectedIndex].ToString(); } comboBox1.BeginUpdate(); comboBox1.Items.Clear(); for (int i = 0; i < aDidlLite.Count; i++) { upnpObject o = aDidlLite[i]; comboBox1.Items.Add(new ComboItem(o)); if (o.Title == selection) { comboBox1.SelectedIndex = i; } } comboBox1.EndUpdate(); } }
public ItemInfo(upnpObject aItem, upnpObject aParent) { iItem = aItem; iParent = aParent; iParsed = false; iLock = new object(); }
private void EventUpdated(object sender, EventArgsArtwork e) { iMutex.WaitOne(); for (int i = iStartIndex; i < iStartIndex + 2 && i < iPlaylist.Count; ++i) { upnpObject upnpObject = iPlaylist[i].DidlLite[0]; Uri uri = DidlLiteAdapter.ArtworkUri(upnpObject); if (uri.AbsoluteUri == e.Artwork.Uri.AbsoluteUri) { Invalidate(); } } for (int i = iStartIndex; i < iStartIndex + 2 && i < iPresets.Count; ++i) { upnpObject upnpObject = iPresets[i].DidlLite[0]; Uri uri = DidlLiteAdapter.ArtworkUri(upnpObject); if (uri.AbsoluteUri == e.Artwork.Uri.AbsoluteUri) { Invalidate(); } } iMutex.ReleaseMutex(); }
public Icon <ImageType> GetIcon(upnpObject aUpnpObject) { if (aUpnpObject != null) { Uri uri = DidlLiteAdapter.ArtworkUri(aUpnpObject); if (uri != null) { return(new Icon <ImageType>(uri)); } if (aUpnpObject is container) { if (aUpnpObject is musicAlbum) { return(IconAlbum); } else if (aUpnpObject is person) { return(IconArtist); } else if (aUpnpObject is playlistContainer) { return(IconPlaylistContainer); } else if (aUpnpObject.ParentId == MediaProviderLibrary.kLibraryId || aUpnpObject.Id == MediaProviderLibrary.kLibraryId) { return(IconLibrary); } else { return(IconDirectory); } } if (aUpnpObject is item) { if (aUpnpObject is audioBroadcast) { return(IconRadio); } else if (aUpnpObject is videoItem) { return(IconVideo); } else if (aUpnpObject is playlistItem) { return(IconPlaylistItem); } else if (aUpnpObject.Title == "Access denied") { return(IconError); } else { return(IconTrack); } } } return(IconNoArtwork); }
public static string Director(upnpObject aObject) { string result = string.Empty; if (aObject is videoItem) { videoItem item = aObject as videoItem; for (int i = 0; i < item.Director.Count; ++i) { if (i > 0 && i < item.Director.Count - 1) { result += ", "; } result += item.Director[i]; } } else if (aObject is videoBroadcast) { videoBroadcast item = aObject as videoBroadcast; for (int i = 0; i < item.Director.Count; ++i) { if (i > 0 && i < item.Director.Count - 1) { result += ", "; } result += item.Director[i]; } } else if (aObject is movie) { movie item = aObject as movie; for (int i = 0; i < item.Director.Count; ++i) { if (i > 0 && i < item.Director.Count - 1) { result += ", "; } result += item.Director[i]; } } else if (aObject is musicVideoClip) { musicVideoClip item = aObject as musicVideoClip; for (int i = 0; i < item.Director.Count; ++i) { if (i > 0 && i < item.Director.Count - 1) { result += ", "; } result += item.Director[i]; } } // always return a non-null string return(NonNullString(result)); }
public DetailsDialog(upnpObject aUpnpObject, upnpObject aParent, UiOptions aUiOptions) { InitializeComponent(); iUpnpObject = aUpnpObject; iParent = aParent; details.Content = new BrowserItem(aUpnpObject, aParent); details.ItemInfo = new ItemInfo(aUpnpObject, aParent); iUiOptions = aUiOptions; this.Loaded += LoadedHandler; }
public static string Title(upnpObject aObject) { string result = string.Empty; if (aObject != null && !string.IsNullOrEmpty(aObject.Title)) { result = aObject.Title.Trim(); } // always return a non-null string return(NonNullString(result)); }
public static string Uri(upnpObject aObject) { string result = string.Empty; if (aObject != null && aObject.Res.Count > 0) { result = aObject.Res[0].Uri; } // always return a non-null string return(NonNullString(result)); }
public void SetMetatext(upnpObject aObject) { iMutex.WaitOne(); if (aObject != null) { iAlbum = DidlLiteAdapter.Title(aObject); iArtist = string.Empty; } iMutex.ReleaseMutex(); }
public static string Count(upnpObject aObject) { string result = string.Empty; if (aObject is container) { container container = aObject as container; result = container.ChildCount.ToString(); } // always return a non-null string return(NonNullString(result)); }
public DidlLite Items(uint aStartIndex, uint aCount) { DidlLite didl = new DidlLite(); uint endIndex = (aStartIndex + aCount < iNode.ChildCount) ? aStartIndex + aCount : iNode.ChildCount; for (uint i = aStartIndex; i < endIndex; i++) { upnpObject metadata = iMetadataFactory.Create(iNode.Child(i), iNode); didl.Add(metadata); } return(didl); }
private void SetChannel(DidlLite aDidlLite, ServiceReceiver.AsyncActionSetSender aAction) { if (aDidlLite.Count > 0) { upnpObject o = aDidlLite[0]; if (o.Res.Count > 0) { string uri = o.Res[0].Uri; DidlLite didl = new DidlLite(); didl.Add(o); aAction.SetSenderBegin(uri, didl.Xml); } } }
public static string ProtocolInfo(upnpObject aObject) { string result = string.Empty; if (aObject != null && aObject.Res.Count > 0) { if (aObject.Res[0].ProtocolInfo != null) { result = aObject.Res[0].ProtocolInfo; } } // always return a non-null string return(NonNullString(result)); }
public static string Artist(upnpObject aObject) { string result = string.Empty; if (aObject is person) { person person = aObject as person; result = person.Title; } else if (aObject is musicAlbum) { // Artist and ALbum Artist are the same for musicAlbums return(AlbumArtist(aObject)); } else if (aObject is musicTrack) { musicTrack item = aObject as musicTrack; foreach (artist a in item.Artist) { if (a.Role == null || (a.Role != null && a.Role.ToLower() == "performer")) { result = a.Artist; if (a.Role != null) { break; } } } } else if (aObject is musicVideoClip) { musicVideoClip item = aObject as musicVideoClip; foreach (artist a in item.Artist) { if (a.Role == null || (a.Role != null && a.Role.ToLower() == "performer")) { result = a.Artist; if (a.Role != null) { break; } } } } // always return a non-null string return(NonNullString(result)); }
public static string OriginalTrackNumber(upnpObject aObject) { string result = string.Empty; if (aObject is musicTrack) { musicTrack track = aObject as musicTrack; if (track.OriginalTrackNumber > 0) { result = track.OriginalTrackNumber.ToString(); } } // always return a non-null string return(NonNullString(result)); }
public static string Size(upnpObject aObject) { string result = string.Empty; if (aObject != null && aObject.Res.Count > 0) { long size = aObject.Res[0].Size / 1024 / 1024; if (size > 0) { result = size.ToString() + " MB"; } } // always return a non-null string return(NonNullString(result)); }
public static string BitDepth(upnpObject aObject) { string result = string.Empty; if (aObject != null && aObject.Res.Count > 0) { int bitDepth = aObject.Res[0].BitsPerSample; if (bitDepth > 0) { result = bitDepth.ToString() + " bits"; } } // always return a non-null string return(NonNullString(result)); }
public void Insert(int aIndex, upnpObject aObject) { DidlLite didl = new DidlLite(); didl.Add(aObject); didl = new DidlLite(didl.Xml); upnpObject o = didl[0]; o.ParentId = iFilename; o.Id = string.Format("{0}/{1}", iFilename, iNextTrackId++); o.Restricted = false; iTracks.Insert(aIndex, o); }
public static string Bitrate(upnpObject aObject) { string result = string.Empty; if (aObject != null && aObject.Res.Count > 0) { float bitrate = (aObject.Res[0].Bitrate * 8) / 1000.0f; if (bitrate > 0) { string bitrateString = bitrate.ToString() + " kbps"; result = bitrateString; } } // always return a non-null string return(NonNullString(result)); }
public static string MimeType(upnpObject aObject) { string result = string.Empty; string protocolInfo = ProtocolInfo(aObject); if (protocolInfo != string.Empty) { string[] split = protocolInfo.Split(':'); if (split.Length == 4) { result = split[2]; } } // always return a non-null string return(NonNullString(result)); }
public static string SampleRate(upnpObject aObject) { string result = string.Empty; if (aObject != null && aObject.Res.Count > 0) { float sampleRate = aObject.Res[0].SampleFrequency / 1000.0f; if (sampleRate > 0) { string sampleRateString = sampleRate.ToString() + " kHz"; result = sampleRateString; } } // always return a non-null string return(NonNullString(result)); }
public static Uri ArtworkUri(upnpObject aObject) { string result = string.Empty; if (aObject != null) { if (aObject.ArtworkUri.Count > 0) { result = aObject.ArtworkUri[0]; } else if (aObject.Icon != null) { result = aObject.Icon; } else if (aObject.AlbumArtUri.Count > 0) { result = aObject.AlbumArtUri[0]; } else if (aObject is photo) { if (aObject.Res.Count > 0) { if (aObject.Res[0].Uri != null) { result = aObject.Res[0].Uri; } } } } if (result.Length > 0) { try { Uri uri = new Uri(result); return(uri); } catch (UriFormatException) { } } return(null); }
public static string ReleaseYear(upnpObject aObject) { string result = string.Empty; if (aObject is playlistContainer) { playlistContainer container = aObject as playlistContainer; result = container.Date; } else if (aObject is album) { album album = aObject as album; result = album.Date; } else if (aObject is musicTrack) { musicTrack item = aObject as musicTrack; result = item.Date; } else if (aObject is audioBook) { audioBook item = aObject as audioBook; result = item.Date; } if (aObject is musicVideoClip) { musicVideoClip item = aObject as musicVideoClip; result = item.Date; } if (!string.IsNullOrEmpty(result)) { try { DateTime t = DateTime.Parse(result); result = t.Year.ToString().Trim(); } catch (FormatException) { } } // always return a non-null string return(NonNullString(result)); }
public static string Duration(upnpObject aObject) { string result = string.Empty; if (aObject != null && aObject.Res.Count > 0) { if (aObject.Res[0].Duration != null) { try { Time time = new Time(aObject.Res[0].Duration); result = time.ToPrettyString(); } catch (Time.TimeInvalid) { } } } // always return a non-null string return(NonNullString(result)); }
public static string Contributor(upnpObject aObject) { string result = string.Empty; if (aObject is album) { album album = aObject as album; if (album.Contributor.Count > 0) { result = album.Contributor[0]; } } else if (aObject is musicVideoClip) { musicVideoClip item = aObject as musicVideoClip; if (item.Contributor.Count > 0) { result = item.Contributor[0]; } } else if (aObject is musicTrack) { musicTrack item = aObject as musicTrack; if (item.Contributor.Count > 0) { result = item.Contributor[0]; } } else if (aObject is audioBook) { audioBook item = aObject as audioBook; if (item.Contributor.Count > 0) { result = item.Contributor[0]; } } // always return a non-null string return(NonNullString(result)); }