public void addCurrent(String path) { Media media = new Media(); TagLib.File tagfile = TagLib.File.Create(path); TagLib.Properties p = tagfile.Properties; TagLib.MediaTypes mt = p.MediaTypes; media.artist = tagfile.Tag.FirstArtist; media.album = tagfile.Tag.Album; media.name = tagfile.Tag.Title; media.path = path; media.genre = tagfile.Tag.FirstGenre; media.copyright = tagfile.Tag.Copyright; if (mt == TagLib.MediaTypes.Audio) { media.type = eMediaType.SOUND; } else if (mt == TagLib.MediaTypes.Photo) { media.type = eMediaType.PICTURE; } else if (mt == TagLib.MediaTypes.Video) { media.type = eMediaType.VIDEO; } listCurrent.Add(media); }
public void addPicture(String path) { Media media = new Media(); var stuff = from entry in listPicture where (entry.path == path) select entry; foreach (Media med in stuff) { return; } TagLib.File tagfile = TagLib.File.Create(path); TagLib.Properties p = tagfile.Properties; TagLib.MediaTypes mt = p.MediaTypes; media.artist = tagfile.Tag.FirstArtist; media.album = tagfile.Tag.Album; media.name = tagfile.Tag.Title; media.path = path; media.genre = tagfile.Tag.FirstGenre; media.copyright = tagfile.Tag.Copyright; ListPicture.Add(media); }
public static CodecType TranslateCodecType(TagLib.MediaTypes types) { switch (types) { case TagLib.MediaTypes.Audio: return(CodecType.Audio); case TagLib.MediaTypes.Video: return(CodecType.Video); case TagLib.MediaTypes.Audio | TagLib.MediaTypes.Video: return(CodecType.AudioVideo); default: return(CodecType.Undefined); } }
public void loadPath(String path, int _nb, ObservableCollection <Media> _listinCurr) { if (File.Exists(path)) { pause = true; TextPlay = "|>"; listinCurr = _listinCurr; try { TagLib.File tagfile = TagLib.File.Create(path); String artist = tagfile.Tag.FirstArtist; TagLib.Properties p = tagfile.Properties; TagLib.MediaTypes mt = p.MediaTypes; if (mt == TagLib.MediaTypes.Audio) { mediatype = eMediaType.SOUND; db.addSound(path); myMedElem.Source = new Uri(path); nb = _nb; } else if (mt == TagLib.MediaTypes.Photo) { mediatype = eMediaType.PICTURE; db.addPicture(path); myMedElem.Source = new Uri(path); pause = false; TextPlay = "||"; myMedElem.Play(); nb = _nb; } else if ((p.MediaTypes & TagLib.MediaTypes.Video) != TagLib.MediaTypes.None) { mediatype = eMediaType.VIDEO; db.addVideo(path); myMedElem.Source = new Uri(path); nb = _nb; } } catch (TagLib.UnsupportedFormatException e) { } } }
private void ReadProperties(TagLib.Properties properties) { if (properties == null) return; _audioBitrate = properties.AudioBitrate; _audioChannels = properties.AudioChannels; _audioSampleRate = properties.AudioSampleRate; _bitsPerSample = properties.BitsPerSample; Codecs = properties.Codecs.ToString(); _description = properties.Description; _duration = properties.Duration; _mediaTypes = properties.MediaTypes; _photoHeight = properties.PhotoHeight; _photoQuality = properties.PhotoQuality; _photoWidth = properties.PhotoWidth; _videoHeight = properties.VideoHeight; _videoWidth = properties.VideoWidth; }
/// <summary> /// Construct and retrieve Metadata from a directory/file path /// </summary> /// <param name="item">The <see cref="LimeItem"/> element to construct Metadata for.</param> /// <param name="coverOnly">Try to load only a cover, not the system icon</param> public LimeMetadata(LimeItem item, bool coverOnly) : this() { LimeLib.LifeTrace(this); // Disable modification detection _Modified = null; LimeMsg.Debug("LimeMetadata: {0}", item.Name); string path = item.Path; if (!coverOnly) { // Add Name Add("Name", item.Name, true, false); if (item.Link != null) { // Link path = item.Link; Add("LinkLabel"); } // Handle tasks if (item.Task) { Add("Task", item.Name, true); } // Display path Add("Path", item, "Path", readOnly: item.Task); } // Retrieve Tags if (!item.Task && !item.Directory && !LimeLib.IsPIDL(path) && !LimeLib.IsSSPD(path)) { LimeMsg.Debug("LimeMetadata: TagLib: {0}", item.Name); try { TagLibFile = TagLib.File.Create(path, TagLib.ReadStyle.Average | TagLib.ReadStyle.PictureLazy); } catch { LimeMsg.Debug("LimeMetadata: {0}: Failed TagLib.File.Create({1})", item.Name, path); } } // Extract Tags if (TagLibFile != null) { LimeMsg.Debug("LimeMetadata: TagLib done: {0}", item.Name); // Retrieve Type if (TagLibFile.Properties != null && TagLibFile.Properties.Codecs != null) { TagLib.MediaTypes[] prioTypes = new TagLib.MediaTypes[] { TagLib.MediaTypes.Video, TagLib.MediaTypes.Audio, TagLib.MediaTypes.Photo, TagLib.MediaTypes.Text }; var codecs = TagLibFile.Properties.Codecs; foreach (var codec in codecs) { if (codec != null) { TagLib.MediaTypes mask = codec.MediaTypes | (TagLib.MediaTypes)Type; foreach (var typ in prioTypes) { if ((mask & typ) != 0) { Type = (MediaType)typ; break; } } } } } else if (TagLibFile is TagLib.Image.NoMetadata.File) { Type = MediaType.Image; } } // Handle Links if (!coverOnly && item.Link != null) { using (var link = new ShellShortcut(item.Path)) { Add("LinkWorkdir", link.WorkingDirectory); //Add("LinkKey", link.Hotkey); Add("LinkWindowStyle", (ShellLinkWindowStyle)link.WindowStyle); if (Type == MediaType.None) { Add("LinkArguments", link.Arguments); } Add("LinkComment", link.Description); } Add("TagLabel"); // Target Path if (LimeLib.IsPIDL(item.Link)) { // Retrieve name of the PIDL try { var dInfo = new DirectoryInfoEx(new ShellDll.PIDL(LimeLib.GetPIDL(item.Link), true)); Add("LinkTarget", dInfo.Label, true); } catch { } } else { Add("LinkTarget", item.Link, LimeLib.IsSSPD(item.Link)); } } if (TagLibFile != null) { LimeMsg.Debug("LimeMetadata: TagLib done 2: {0}", item.Name); // Build the Properties BuildProperties(); // Build the Pictures image BuildCover(coverOnly); } else if (!coverOnly) { // Build the Pictures image from the file icon using (var bmp = item.Bitmap(256)) { Pictures = LimeLib.ImageSourceFrom(bmp); } } if (!coverOnly) { // Finalize BuildToolTip(); } // re-enable modification detection _Modified = false; LimeMsg.Debug("LimeMetadata End: {0}", item.Name); }