private void GetMp3IdInfo() { ID3Info id3 = new ID3Info(ddtbMp3File.ItemText, true); tbTrack3v1.Text = id3.ID3v1Info.TrackNumber.ToString(); tbTitle3v1.Text = id3.ID3v1Info.Title; tbArtist3v1.Text = id3.ID3v1Info.Artist; tbAlbum3v1.Text = id3.ID3v1Info.Album; tbYear3v1.Text = id3.ID3v1Info.Year; tbComment3v1.Text = id3.ID3v1Info.Comment; string genre = id3.ID3v1Info.Genre.ToString(); genre = string.IsNullOrEmpty(genre) ? "150" : genre; cbGenre3v1.GenreIndex = int.Parse(genre); tbTrack3v2.Text = id3.ID3v2Info.GetTextFrame("TRCK"); tbTitle3v2.Text = id3.ID3v2Info.GetTextFrame("TIT2"); tbArtist3v2.Text = id3.ID3v2Info.GetTextFrame("TPE1"); tbAlbum3v2.Text = id3.ID3v2Info.GetTextFrame("TALB"); tbYear3v2.Text = id3.ID3v2Info.GetTextFrame("TYER"); tbComment3v2.Text = id3.ID3v2Info.GetTextFrame("WCOM"); cbGenre3v2.Genre = id3.ID3v2Info.GetTextFrame("TCON"); }
private void SaveMp3IdInfo() { ID3Info id3 = new ID3Info(ddtbMp3File.ItemText, true); try { id3.ID3v1Info.TrackNumber = BCHUtilities.IsNumeric(tbTrack3v1.Text) ? byte.Parse(tbTrack3v1.Text) : byte.Parse("1"); id3.ID3v1Info.Title = tbTitle3v1.Text; id3.ID3v1Info.Artist = tbArtist3v1.Text; id3.ID3v1Info.Album = tbAlbum3v1.Text; id3.ID3v1Info.Year = tbYear3v1.Text; id3.ID3v1Info.Comment = tbComment3v1.Text; id3.ID3v1Info.Genre = Convert.ToByte(cbGenre3v1.GenreIndex); id3.ID3v2Info.SetTextFrame("TRCK", tbTrack3v2.Text); id3.ID3v2Info.SetTextFrame("TIT2", tbTitle3v2.Text); id3.ID3v2Info.SetTextFrame("TPE1", tbArtist3v2.Text); id3.ID3v2Info.SetTextFrame("TALB", tbAlbum3v2.Text); id3.ID3v2Info.SetTextFrame("TYER", tbYear3v2.Text); id3.ID3v2Info.SetTextFrame("WCOM", tbComment3v2.Text); id3.ID3v2Info.SetTextFrame("TCON", cbGenre3v2.Genre); id3.ID3v2Info.HaveTag = true; id3.ID3v1Info.HaveTag = true; id3.Save(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 获得歌曲文件信息 /// </summary> /// <param name="filePath">源歌曲文件路径</param> /// <param name="flag">标志位,根据设置而定</param> public MusicInfo(string filePath, int flag) { try { // 尝试获取ID3标签 ID3Info id3 = new ID3Info(filePath, true); Title = id3.ID3v1Info.Title != null ? id3.ID3v1Info.Title : id3.ID3v2Info.GetTextFrame("TIT2"); Singer = id3.ID3v1Info.Artist != null ? id3.ID3v1Info.Artist : id3.ID3v2Info.GetTextFrame("TPE1"); if (Title.Equals("")) { // 尝试手工分割文件名 string fileName = Path.GetFileNameWithoutExtension(filePath); Title = fileName; Singer = fileName; } } catch (Exception ex) { // 尝试手工分割文件名 string fileName = Path.GetFileNameWithoutExtension(filePath); Title = fileName; Singer = fileName; } MusicPath = filePath; }
// Adding new file(s) to datagrid public void AddNewFiles(string[] FilePaths) { ID3Info ID3File; int i = 0; try { // add file after file to datagrid foreach (string path in FilePaths) { var file = TagLib.File.Create(FilePaths[i]); var fileInfo = new FileInfo(FilePaths[i]); ID3File = new ID3Info(FilePaths[i], true); ID3File.FileSize = fileInfo.Length / 1000; ID3File.ID3Size = file.InvariantStartPosition / 1000; collection.Add(ID3File); _Data = ID3File; dataGrid.ItemsSource = collection; i++; } } catch (Exception ex) { MessageBox.Show(FilePaths[i] + "\nCan't load file. " + ex.Message, "Loading File"); return; } }
/// <summary> /// 获取歌曲封面图片 /// </summary> /// <param name="path">歌曲文件路径</param> /// <returns>图片文件</returns> public static BitmapImage GetAlbumCover(string path) { if (path != null) { try { ID3Info info = new ID3Info(path, true); var pictureFrames = info.ID3v2Info.AttachedPictureFrames.Items; BitmapImage bitmapImage = new BitmapImage(); if (pictureFrames.Any()) { AttachedPictureFrame ap = info.ID3v2Info.AttachedPictureFrames.Items[0]; bitmapImage.BeginInit(); bitmapImage.StreamSource = ap.Data; bitmapImage.EndInit(); } else { bitmapImage = new BitmapImage(new Uri(@"/Player4;component/Image/DefaultImage.png", UriKind.RelativeOrAbsolute)); } return(bitmapImage); } catch (Exception e) { MessageBox.Show(e.Message); return(null); } } return(null); }
private void LoadPicture() { string file = player.CurrentSongAddress.LocalPath; string Name = file.Substring(file.LastIndexOf("\\") + 1, file.LastIndexOf(".") - file.LastIndexOf("\\") - 1); if (!File.Exists(String.Format("Covers\\" + Name + ".jpg"))) { ID3Info song = new ID3Info(file, true); foreach (AttachedPictureFrame AP in song.ID3v2Info.AttachedPictureFrames.Items) { try { if (AP.Data != null && (AP.PictureType == AttachedPictureFrame.PictureTypes.Cover_Front || AP.PictureType == AttachedPictureFrame.PictureTypes.Media)) { System.Drawing.Image image = System.Drawing.Image.FromStream(AP.Data); if (!Directory.Exists("Covers\\")) { Directory.CreateDirectory("Covers\\"); } image.Save(String.Format("Covers\\" + Name + ".jpg")); } } catch (ArgumentException) { continue; } } } Dispatcher.BeginInvoke(DispatcherPriority.Background, new LongTimeDelegate(GetCover)); }
public listMusicItem(string path, string bg, string outpath) { this.path = path; updatePaths(bg, outpath); // get ze id3 dataz! // http://www.codeproject.com/KB/cs/Do_Anything_With_ID3.aspx ID3Info f = new ID3Info(path, true); ID3v2 id3 = f.ID3v2Info; this.title = id3.GetTextFrame("TIT2"); this.artist = id3.GetTextFrame("TPE1"); this.album = id3.GetTextFrame("TALB"); Console.WriteLine("------ File ID3 data :: " + Path.GetFileName(path)); Console.WriteLine("Title: " + title); Console.WriteLine("Artist: " + artist); Console.WriteLine("Album: " + album); // try to get any images if possible images = new Image[id3.AttachedPictureFrames.Count]; for (int i = 0; i < id3.AttachedPictureFrames.Count; i++) { AttachedPictureFrame ap = id3.AttachedPictureFrames.Items[i]; // Empty catch!? :o SHOCK! HORROR! no seriously, who cares what goes wrong here... try { images[i] = Image.FromStream(ap.Data); } catch { } } Console.WriteLine("Images Found: " + images.Length.ToString()); }
private void _currentMenu_Click(object sender, EventArgs e) { #region 界面归零 module.MainListBox.Items.Clear(); module.MusicPathList.Clear(); module.MainProgressBar.Maximum = 0; module.MainProgressBar.Value = 0; #endregion FolderBrowserDialog _fd = new FolderBrowserDialog(); _fd.Description = "请选择歌曲与歌词所在的文件夹"; _fd.ShowDialog(); string[] files = null; if (_fd.SelectedPath != "") { files = Directory.GetFiles(_fd.SelectedPath, "*.mp3", SearchOption.AllDirectories); foreach (var item in files) { module.MainListBox.Items.Add(new ListViewItem(new string[] { item, "" })); } // 写入 module.MainProgressBar.Maximum = files.Length; int _count = 0; module.MainStatusStrip.Text = "开始写入LRC歌词文件..."; foreach (var item in files) { var _str = Path.GetDirectoryName(item) + @"\" + Path.GetFileNameWithoutExtension(item) + ".lrc"; if (File.Exists(_str)) { var _fr = new FileStream(_str, FileMode.Open); var _sr = new StreamReader(_fr); var _text = _sr.ReadToEnd(); try { // 写入ID3标签 ID3Info info = new ID3Info(item, true); info.ID3v2Info.SetTextFrame("TEXT", _text); info.Save(); module.MainListBox.Items[_count].SubItems[1].Text = "成功"; } catch { module.MainListBox.Items[_count].SubItems[1].Text = "失败"; } _sr.Close(); _fr.Close(); } else { module.MainListBox.Items[_count].SubItems[1].Text = "不存在LRC"; } _count++; module.MainProgressBar.Value++; } module.MainStatusStrip.Text = "歌词写入完成!"; } }
private void btDelete_Click(object sender, RoutedEventArgs e) { ID3Info selectedItem = dataGrid.SelectedItem as ID3Info; if (selectedItem != null) { collection.Remove(selectedItem); dataGrid.ItemsSource = collection; } }
/// <summary> /// 加载图片 /// </summary> public void LoadImages() { images = new List <FileInfo>(); var commonPicturesDir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures)); images.AddRange(commonPicturesDir.GetFiles("*.jpg", SearchOption.AllDirectories)); images.AddRange(commonPicturesDir.GetFiles("*.png", SearchOption.AllDirectories)); var myPicturesDir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)); images.AddRange(myPicturesDir.GetFiles("*.jpg", SearchOption.AllDirectories)); images.AddRange(myPicturesDir.GetFiles("*.png", SearchOption.AllDirectories)); myMusicDir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)); myCoverDir = new DirectoryInfo(myMusicDir.FullName + @"\Covers\"); if (!myCoverDir.Exists) { myCoverDir.Create(); } myLyricDir = new DirectoryInfo(myMusicDir.FullName + @"\Lyrics\"); if (!myLyricDir.Exists) { myLyricDir.Create(); } FileInfo[] musics = myMusicDir.GetFiles("*.mp3"); foreach (var music in musics) { string cover = myCoverDir + @"\" + System.IO.Path.GetFileNameWithoutExtension(music.FullName) + ".jpg"; if (!File.Exists(cover)) { ID3Info info = new ID3Info(music.FullName, true);//从ID3V2信息中读取封面 info.Load(); if (info.ID3v2Info.HaveTag && info.ID3v2Info.AttachedPictureFrames.Items.Length > 0) { MemoryStream ms = info.ID3v2Info.AttachedPictureFrames.Items[0].Data; System.Drawing.Image img = Bitmap.FromStream(ms); img.Save(cover, System.Drawing.Imaging.ImageFormat.Jpeg); } else { File.Copy(System.Environment.CurrentDirectory + @"\cover.jpg", cover, true); } } images.Add(new FileInfo(cover)); } images.Sort(new FileInfoComparer()); foreach (FileInfo f in images) { flow.Add(Environment.MachineName, f.FullName); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Forms.DialogResult result = fbd.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } SqlConnection conn = new SqlConnection(Properties.Settings.Default.MusicConnectionString); try { conn.Open(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } string path = fbd.SelectedPath.Trim(); string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".mp3") || s.EndsWith(".flac")).ToArray(); foreach (string file in files) { if (file.Contains("'")) { continue; } try { string Name = file.Substring(file.LastIndexOf("\\") + 1, file.LastIndexOf(".") - file.LastIndexOf("\\") - 1); ID3Info song = new ID3Info(file, true); string title = song.ID3v2Info.GetTextFrame("TIT2"); string artist = song.ID3v2Info.GetTextFrame("TPE1"); SqlCommand sqlCmd = new SqlCommand(string.Format("INSERT INTO MUSIC(Address,Name,Title,Artist) VALUES(N'{0}',N'{1}',N'{2}',N'{3}')", file, Name, title, artist), conn); sqlCmd.ExecuteNonQuery(); } catch (SqlException) { continue; } catch (OverflowException) { continue; } catch (ArgumentException) { continue; } } fbd.Dispose(); conn.Close(); GarbageCollect(); }
private void ExecCodeProj(string fileName) { ID3Info id3Info = new ID3Info(fileName, true); id3Info.Load(); textBox1.Text = id3Info.ID3v2Info.GetTextFrame("TIT2") + ";" + id3Info.ID3v1Info.Title; id3Info.ID3v2Info.SetTextFrame("TIT2", id3Info.ID3v1Info.Title.Trim()); id3Info.ID3v1Info.Title = id3Info.ID3v1Info.Title.Trim() + ""; id3Info.Save(); textBox2.Text = id3Info.ID3v2Info.GetTextFrame("TIT2") + ";" + id3Info.ID3v1Info.Title; }
public ID3vDetails(string filename) { ImageMP3 = new ID3Info(filename, true); foreach (AttachedPictureFrame frame in ImageMP3.ID3v2Info.AttachedPictureFrames) { Image temp = frame.Picture; attach = temp; } MP3 = new ID3v1(filename, true); namemp3 = MP3.FileName; title = MP3.Title; artist = MP3.Artist; album = MP3.Album; year = MP3.Year; }
private void SaveMp3IdInfo(MP3FileDataType mp3, ref OperationResult op) { try { ID3Info id3 = new ID3Info(mp3.FileNamePath, true); string track = mp3.Track != null?mp3.Track.ToString() : "1"; string title = !string.IsNullOrEmpty(mp3.SongTitleAndNumeration) ? GetMaxLen(mp3.SongTitleAndNumeration, 30) : string.Empty; string artists = !string.IsNullOrEmpty(mp3.ArtistsStrList) ? GetMaxLen(mp3.ArtistsStrList, 30) : string.Empty; string album = !string.IsNullOrEmpty(mp3.Album) ? GetMaxLen(mp3.Album, 30) : string.Empty; string comments = !string.IsNullOrEmpty(mp3.Comments) ? GetMaxLen(mp3.Comments, 28) : string.Empty; List <string> GenreList = BCHMP3Utilities.GetGenre(); int genreIndx = GenreList.Contains(mp3.Genre, StringComparer.CurrentCultureIgnoreCase) ? GenreList.FindIndex( s => s.Trim().Equals(mp3.Genre.Trim(), StringComparison.CurrentCultureIgnoreCase)) : GenreList.FindIndex( s => s.Trim().Equals("Other", StringComparison.CurrentCultureIgnoreCase)); id3.ID3v1Info.TrackNumber = byte.Parse(track); id3.ID3v1Info.Title = title; id3.ID3v1Info.Artist = artists; id3.ID3v1Info.Album = album; id3.ID3v1Info.Comment = comments; id3.ID3v1Info.Genre = Convert.ToByte(genreIndx); id3.ID3v2Info.SetTextFrame("TRCK", track); id3.ID3v2Info.SetTextFrame("TIT2", title); id3.ID3v2Info.SetTextFrame("TPE1", artists); id3.ID3v2Info.SetTextFrame("TALB", album); id3.ID3v2Info.SetTextFrame("WCOM", comments); id3.ID3v2Info.SetTextFrame("TCON", GenreList[genreIndx]); id3.ID3v2Info.HaveTag = true; id3.Save(); } catch (Exception ex) { op.AddException(ex); } }
public static void RewriteMP3Tags(DownloadItem item) { string localFileName = item.Filename; if (File.Exists(localFileName)) { try { ID3Info id3Info = new ID3Info(localFileName, true); string strTitle = id3Info.ID3v2Info.GetTextFrame("TIT2"); string strGenre = id3Info.ID3v2Info.GetTextFrame("TCON"); string strArtist = id3Info.ID3v2Info.GetTextFrame("TPE1"); string strAlbum = id3Info.ID3v2Info.GetTextFrame("TALB"); if (item.TagTitle != null && item.TagTitle != "") { strTitle = ParseMediaTags(item.TagTitle, item, id3Info); } if (item.TagGenre != null && item.TagGenre != "") { strGenre = ParseMediaTags(item.TagGenre, item, id3Info); } if (item.TagArtist != null && item.TagArtist != "") { strArtist = ParseMediaTags(item.TagArtist, item, id3Info); } if (item.TagAlbum != null && item.TagAlbum != "") { strAlbum = ParseMediaTags(item.TagAlbum, item, id3Info); } id3Info.ID3v2Info.HaveTag = true; id3Info.ID3v2Info.SetMinorVersion(3); id3Info.ID3v2Info.SetTextFrame("TIT2", strTitle); id3Info.ID3v2Info.SetTextFrame("TCON", strGenre); id3Info.ID3v2Info.SetTextFrame("TPE1", strArtist); id3Info.ID3v2Info.SetTextFrame("TALB", strAlbum); id3Info.Save(); } catch (Exception ex) { if (Settings.Default.LogLevel > 0) { log.Error(ex); } } } }
/// <summary> /// 打开图片展示或者音乐播放窗口 /// </summary> private void OpenSubWindow() { string path = CheckIfMusicPath(currentIndex); if (path != "") { ID3Info id3Info = new ID3Info(path, true); id3Info.Load(); BassEngine.Instance.OpenFile(path); musicWindow = new MusicWindow(images[currentIndex], id3Info); musicWindow.Show(); } else { detialWindow = new DetialWindow(images[currentIndex]); detialWindow.Show(); } }
private static string ParseMediaTags(string strTag, DownloadItem item, ID3Info id3Info) { strTag = strTag.Replace("%feedname%", item.FeedTitle); strTag = strTag.Replace("%feedtitle%", item.FeedTitle); strTag = strTag.Replace("%url%", item.FeedUrl); strTag = strTag.Replace("%playlist%", item.FeedPlaylist); strTag = strTag.Replace("%artist%", id3Info.ID3v2Info.GetTextFrame("TPE1")); strTag = strTag.Replace("%album%", id3Info.ID3v2Info.GetTextFrame("TALB")); strTag = strTag.Replace("%genre%", id3Info.ID3v2Info.GetTextFrame("TCON")); strTag = strTag.Replace("%date%", DateTime.Now.ToString("yyyy-MM-dd")); strTag = strTag.Replace("%time%", DateTime.Now.ToString("HH:mm:ss")); strTag = strTag.Replace("%y%", DateTime.Now.Year.ToString()); strTag = strTag.Replace("%m%", DateTime.Now.Month.ToString()); strTag = strTag.Replace("%d%", DateTime.Now.Day.ToString()); strTag = strTag.Replace("%posttitle%", item.PostTitle); System.IO.FileInfo fileInfo = new FileInfo(item.Filename); strTag = strTag.Replace("%file%", fileInfo.Name); return(strTag); }
public void Process(IStatus status) { this.status = status; status.Report("Updataing tags..."); ID3Info info = new ID3Info(this.source, true); info.ID3v1Info.HaveTag = true; info.ID3v1Info.Title = Helper.String.Clip(this.title, 30); info.ID3v1Info.Artist = Helper.String.Clip(this.artist, 30); info.ID3v1Info.Album = Helper.String.Clip(this.album, 30); info.ID3v1Info.Genre = 255; info.ID3v1Info.Year = DateTime.Now.Year.ToString(); info.ID3v1Info.Comment = string.Empty; info.ID3v1Info.TrackNumber = this.track; info.ID3v2Info.ClearAll(); info.ID3v2Info.HaveTag = true; info.ID3v2Info.SetMinorVersion(3); info.ID3v2Info.SetTextFrame("TIT2", this.title); info.ID3v2Info.SetTextFrame("TPE1", this.artist); info.ID3v2Info.SetTextFrame("TALB", this.album); info.ID3v2Info.SetTextFrame("TCON", this.genre); info.ID3v2Info.SetTextFrame("TRCK", this.track.ToString()); using (MemoryStream stream = Helper.Imaging.ImageToMemoryStream(this.artwork, System.Drawing.Imaging.ImageFormat.Jpeg)) { AttachedPictureFrame ATP = new AttachedPictureFrame(new FrameFlags(), "", TextEncodings.Ascii, "image/jpg", AttachedPictureFrame.PictureTypes.Cover_Front, stream); info.ID3v2Info.AttachedPictureFrames.Add(ATP); try { info.Save(); } catch (Exception ex) { status.Report(String.Format("Unable to save tags. (\"{0}\")", ex.Message)); } } //info.Save(); }
private void ConvertID3(string mp3FilePath) { ID3Info info = new ID3Info(mp3FilePath, true); if (info.ID3v1Info.HaveTag) { if (Regex.Match(StupiddEncoding(info.ID3v1Info.Artist), "[а-яА-Я№]").Value.Length > 0 || Regex.Match(StupiddEncoding(info.ID3v1Info.Album), "[а-яА-Я№]").Value.Length > 0 || Regex.Match(StupiddEncoding(info.ID3v1Info.Title), "[а-яА-Я№]").Value.Length > 0) { info.ID3v1Info.Artist = ConvName(StupiddEncoding(info.ID3v1Info.Artist)); info.ID3v1Info.Album = ConvName(StupiddEncoding(info.ID3v1Info.Album)); info.ID3v1Info.Title = ConvName(StupiddEncoding(info.ID3v1Info.Title)); info.ID3v1Info.Comment = ConvName(StupiddEncoding(info.ID3v1Info.Comment)); if (info.ID3v2Info.HaveTag) { info.ID3v2Info.ClearAll(); info.ID3v2Info.SetMinorVersion(3); //Title info.ID3v2Info.SetTextFrame("TIT2", ConvName(StupiddEncoding(info.ID3v1Info.Title))); //Track //info.ID3v2Info.SetTextFrame("TRCK", ConvName(StupiddEncoding(info.ID3v1Info.Title))); //Disk //info.ID3v2Info.SetTextFrame("TPOS","Text 3"); //Artist //info.ID3v2Info.SetTextFrame("TPE1", ConvName(StupiddEncoding(info.ID3v1Info.Artist))); //Album //info.ID3v2Info.SetTextFrame("TALB", ConvName(StupiddEncoding(info.ID3v1Info.Album))); //Genre //info.ID3v2Info.SetTextFrame("TCON", cmb2Genre.Genre); //Languege //info.ID3v2Info.SetTextFrame("TLAN", cmb2Language.Language); } info.Save(); } } }
// Adding new file to datagrid public void AddNewFile(string filePath) { ID3Info ID3File; try { var file = TagLib.File.Create(filePath); var fileInfo = new FileInfo(filePath); ID3File = new ID3Info(filePath, true); ID3File.FileSize = fileInfo.Length; ID3File.ID3Size = file.InvariantStartPosition / 1000; collection.Add(ID3File); _Data = ID3File; dataGrid.ItemsSource = collection; } catch (Exception ex) { MessageBox.Show(filePath + "\nCan't load file. " + ex.Message, "Loading File"); return; } }
public void getID3() { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("xml/id3.xml")); XmlNode root = doc.SelectSingleNode("id3"); root.RemoveAll(); string info_data = ""; string path = Server.MapPath("play\\" + song + ".mp3"); ID3Info info = new ID3Info(path, true); bool b = info.ID3v2Info.HaveTag; if (b) { XmlElement xe2 = doc.CreateElement("title"); xe2.SetAttribute("id", "标题"); info_data = fix_data(info.ID3v2Info.GetTextFrame("TIT2")); xe2.SetAttribute("name", info_data); xe2.InnerText = info_data; root.AppendChild(xe2); XmlElement xe = doc.CreateElement("singer"); xe.SetAttribute("id", "演唱"); info_data = fix_data(info.ID3v2Info.GetTextFrame("TPE1")); xe.SetAttribute("name", info_data); xe.InnerText = info_data; root.AppendChild(xe); XmlElement xe3 = doc.CreateElement("album"); xe3.SetAttribute("id", "专辑"); info_data = fix_data(info.ID3v2Info.GetTextFrame("TALB")); xe3.SetAttribute("name", info_data); xe3.InnerText = info_data; root.AppendChild(xe3); doc.Save(Server.MapPath("xml/id3.xml")); } }
public void AddNewFile(string FilePath) { ID3Info ID3File; try { ID3File = new ID3Info(FilePath, true); collection.Add(ID3File); dataGrid.ItemsSource = collection; } catch (Exception ex) { MessageBox.Show(FilePath + "\nCan't load file. " + ex.Message, "Loading File"); return; } //dataGrid.ItemsSource = collection; //_Tags.Remove(FilePath); // remove previous file if was in list //_Tags.Add(FilePath, ID3File); //_ErrorDialog.AddErrors(ID3File); //ID3File.ID3v2Info.Errors.Clear(); }
public static SoundFileInformation GetSoundFileInformation(string filename) { SoundFileInformation sfInfo = new SoundFileInformation(); try { if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) { return(sfInfo); } ID3Info id3Info = new ID3Info(filename, true); int id3Version = Settings.Current.UseID3Version; if (id3Info.ID3v1Info != null && id3Info.ID3v1Info.HaveTag && id3Version != 1) { sfInfo.Artist = id3Info.ID3v1Info.Artist.Trim(); sfInfo.Title = id3Info.ID3v1Info.Title.Trim(); sfInfo.Comment = id3Info.ID3v1Info.Comment.Trim(); sfInfo.Album = id3Info.ID3v1Info.Album.Trim(); sfInfo.Year = id3Info.ID3v1Info.Year.Trim(); sfInfo.Genre = MapID3GenreToHitbaseGenre(id3Info.ID3v1Info.Genre); sfInfo.TrackNumber = id3Info.ID3v1Info.TrackNumber; sfInfo.ID3Version = 1; } if (id3Info.ID3v2Info != null && id3Info.ID3v2Info.HaveTag && id3Version != 0) { sfInfo.Artist = id3Info.ID3v2Info.GetTextFrame("TPE1").Trim(); sfInfo.Title = id3Info.ID3v2Info.GetTextFrame("TIT2").Trim(); sfInfo.Comment = id3Info.ID3v2Info.GetTextFrame("COMM").Trim(); sfInfo.Album = id3Info.ID3v2Info.GetTextFrame("TALB").Trim(); sfInfo.Year = id3Info.ID3v2Info.GetTextFrame("TYER").Trim(); String trackNumber = id3Info.ID3v2Info.GetTextFrame("TRCK"); sfInfo.TrackNumber = Misc.Atoi(trackNumber); sfInfo.Genre = id3Info.ID3v2Info.GetTextFrame("TCON").Trim(); sfInfo.Composer = id3Info.ID3v2Info.GetTextFrame("TCOM").Trim(); sfInfo.Language = id3Info.ID3v2Info.GetTextFrame("TLAN").Trim(); // Das mit dem Rating geht irgendwie anders. Erst mal raus //string rating = id3Info.ID3v2Info.GetTextFrame("POPM").Trim(); //sfInfo.Rating = Misc.Atoi(rating); string bpm = id3Info.ID3v2Info.GetTextFrame("TBPM").Trim(); sfInfo.BPM = Misc.Atoi(bpm); string length = id3Info.ID3v2Info.GetTextFrame("TLEN"); if (Misc.Atoi(length) > 0) { sfInfo.Length = Misc.Atoi(length); } sfInfo.Images = new List <byte[]>(); if (id3Info.ID3v2Info.AttachedPictureFrames.Items.Length > 0) { ID3.ID3v2Frames.BinaryFrames.BinaryFrame binaryFrame = id3Info.ID3v2Info.AttachedPictureFrames.Items[0]; foreach (AttachedPictureFrame apf in id3Info.ID3v2Info.AttachedPictureFrames.Items) { sfInfo.Images.Add(apf.Data.ToArray()); } } sfInfo.ID3Version = 2; } if (sfInfo.Length == 0) { FMOD.Sound sound = null; FMOD.RESULT res = SoundEngine.FMODSystem.createStream(filename, FMOD.MODE.OPENONLY, ref sound); uint length = 0; if (sound != null) { sound.getLength(ref length, FMOD.TIMEUNIT.MS); sound.release(); sfInfo.Length = (int)length; } } } catch { // Zuerst mal hier alle Fehler ignorieren. } return(sfInfo); }
/// <summary> /// 下载红心歌曲 /// </summary> public void Download() { if (Directory.Exists(Path) == false)//如果不存在就创建文件夹 { Directory.CreateDirectory(Path); } client.NewList(); client.SwitchChannel(Channel.RedHeart); int times = 0; int num = 0; while (dic.Count <= Total) { foreach (Song song in client.Playlist) { if (!dic.Keys.Contains(song.SongID)) { dic.Add(song.SongID, song); num++; currentSong = song; string fileName = Path + song.Title + ".mp3"; try { image = Image.FromStream(WebRequest.Create(song.PictureURL).GetResponse().GetResponseStream()); } catch (Exception) { image = Properties.Resources.cover; } NewSong.Invoke(num, image, song.Title, song.Artist); if (File.Exists(fileName)) { Exist++; } else { if (Downfile(song.MediaURL, fileName)) { Success++; ID3Info info = new ID3Info(fileName, true); info.Load(); info.ID3v2Info.SetMinorVersion(3); AttachedPictureFrame pic = null; try { if (!string.IsNullOrEmpty(CoverPath))//保存封面 { image.Save(CoverPath + song.Title + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } ms = new System.IO.MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); // 创建新封面 pic = new AttachedPictureFrame( FrameFlags.Compression, "cover.jpg", TextEncodings.UTF_16, "", AttachedPictureFrame.PictureTypes.Cover_Front, ms); info.ID3v2Info.AttachedPictureFrames.Add(pic); // 添加新封面到MP3中 } catch { } if (!string.IsNullOrEmpty(lyricPath))//下载歌词 { downloadLrc.SaveLyric(song.Artist, song.Title, lyricPath + song.Title + ".lrc"); } // 设置其它属性(ID3V1) info.ID3v1Info.Title = song.Title; info.ID3v1Info.Artist = song.Artist; info.ID3v1Info.Album = song.AlbumTitle; //jasine fixed 2015.9.23 info.ID3v1Info.Year = song.PublicationTime; //info.ID3v1Info.Year = ""; info.ID3v1Info.Comment = "*****@*****.**"; //注释---------添加不上去 info.ID3v1Info.Genre = 12; //类型代码Other:12 对应于ID3V2中自定义类型RedHeart // 设置其它属性(ID3V2) info.ID3v2Info.SetTextFrame("TIT2", song.Title); info.ID3v2Info.SetTextFrame("TPE1", song.Artist); info.ID3v2Info.SetTextFrame("TALB", song.AlbumTitle); //jasine fixed 2015.9.23 info.ID3v2Info.SetTextFrame("TYER", song.PublicationTime); //info.ID3v2Info.SetTextFrame("TYER", ""); //info.ID3v2Info.SetTextFrame("COMM", "*****@*****.**");//注释---------添加不上去 info.ID3v2Info.SetTextFrame("TCON", "RedHeart");//类型 //jasine fixed 2015.9.23 //info.ID3v2Info.SetTextFrame("TPUB", song.Publisher);//发布者,发布单位 info.ID3v2Info.SetTextFrame("TPUB", "");//发布者,发布单位 // 保存到MP3中 if (ID3Version == 1) { info.ID3v1Info.Save(); } else { //info.Save(3); info.ID3v2Info.PopularimeterFrames.Add(new ID3.ID3v2Frames.TextFrames.PopularimeterFrame( FrameFlags.TagAlterPreservation, "fm.douban.com", song.Rating, 0));//豆瓣评分 info.ID3v2Info.Save(3); } } else { //下载失败 Fail++; } } if ((Success + Fail + Exist) >= Total) { Msg.Invoke(Success, Fail, Exist, "下载完成"); Stop(); } else { Msg.Invoke(Success, Fail, Exist, ""); } } } client.Skip(); times++; if (times > 10000) { Fail = Total - (Success + Exist); Msg.Invoke(Success, Fail, Exist, "尝试次数过多,未成功下载歌曲请过几小时后再在原文件夹下载"); Stop(); } } Msg.Invoke(Success, Fail, Exist, "下载完成"); }
private void ConvertID3_2(string mp3FilePath) { ID3Info info = new ID3Info(mp3FilePath, true); if (info.ID3v1Info.HaveTag) { if (Regex.Match(Converts(info.ID3v1Info.Artist, Encoding.GetEncoding((int)comboBoxInput.SelectedValue), Encoding.GetEncoding((int)comboBoxOut.SelectedValue)), "[а-яА-Я№]").Value.Length > 0 || Regex.Match(Converts(info.ID3v1Info.Album, Encoding.GetEncoding((int)comboBoxInput.SelectedValue), Encoding.GetEncoding((int)comboBoxOut.SelectedValue)), "[а-яА-Я№]").Value.Length > 0 || Regex.Match(Converts(info.ID3v1Info.Title, Encoding.GetEncoding((int)comboBoxInput.SelectedValue), Encoding.GetEncoding((int)comboBoxOut.SelectedValue)), "[а-яА-Я№]").Value.Length > 0 || Regex.Match(Converts(info.ID3v1Info.Comment, Encoding.GetEncoding((int)comboBoxInput.SelectedValue), Encoding.GetEncoding((int)comboBoxOut.SelectedValue)), "[а-яА-Я№]").Value.Length > 0) { info.ID3v1Info.Artist = Converts(info.ID3v1Info.Artist, Encoding.GetEncoding((int)comboBoxInput.SelectedValue), Encoding.GetEncoding((int)comboBoxOut.SelectedValue)); info.ID3v1Info.Album = Converts(info.ID3v1Info.Album, Encoding.GetEncoding((int)comboBoxInput.SelectedValue), Encoding.GetEncoding((int)comboBoxOut.SelectedValue)); info.ID3v1Info.Title = Converts(info.ID3v1Info.Title, Encoding.GetEncoding((int)comboBoxInput.SelectedValue), Encoding.GetEncoding((int)comboBoxOut.SelectedValue)); info.ID3v1Info.Comment = Converts(info.ID3v1Info.Comment, Encoding.GetEncoding((int)comboBoxInput.SelectedValue), Encoding.GetEncoding((int)comboBoxOut.SelectedValue)); info.ID3v2Info.ClearAll(); info.ID3v2Info.SetMinorVersion(3); //Title info.ID3v2Info.SetTextFrame("TIT2", info.ID3v1Info.Title); //Artist info.ID3v2Info.SetTextFrame("TPE1", info.ID3v1Info.Artist); //Album info.ID3v2Info.SetTextFrame("TALB", info.ID3v1Info.Album); info.ID3v1Info.Album = ""; info.ID3v1Info.Artist = ""; info.ID3v1Info.Comment = ""; info.ID3v1Info.Title = ""; info.Save(); } } /* * if (info.ID3v1Info.HaveTag) * { * if (Regex.Match(Converts(info.ID3v1Info.Artist, Encoding.GetEncoding(1251), Encoding.GetEncoding(1250)), "[а-яА-Я№]").Value.Length > 0 || * Regex.Match(Converts(info.ID3v1Info.Album, Encoding.GetEncoding(1251), Encoding.GetEncoding(1250)), "[а-яА-Я№]").Value.Length > 0 || * Regex.Match(Converts(info.ID3v1Info.Title, Encoding.GetEncoding(1251), Encoding.GetEncoding(1250)), "[а-яА-Я№]").Value.Length > 0 || * Regex.Match(Converts(info.ID3v1Info.Comment, Encoding.GetEncoding(1251), Encoding.GetEncoding(1250)), "[а-яА-Я№]").Value.Length > 0) * { * * info.ID3v1Info.Artist = Converts(info.ID3v1Info.Artist, Encoding.GetEncoding(1251), Encoding.GetEncoding(1250)); * info.ID3v1Info.Album = Converts(info.ID3v1Info.Album, Encoding.GetEncoding(1251), Encoding.GetEncoding(1250)); * info.ID3v1Info.Title = Converts(info.ID3v1Info.Title, Encoding.GetEncoding(1251), Encoding.GetEncoding(1250)); * info.ID3v1Info.Comment = Converts(info.ID3v1Info.Comment, Encoding.GetEncoding(1251), Encoding.GetEncoding(1250)); * * * * * info.ID3v2Info.ClearAll(); * info.ID3v2Info.SetMinorVersion(3); * //Title * info.ID3v2Info.SetTextFrame("TIT2", info.ID3v1Info.Title); * //Artist * info.ID3v2Info.SetTextFrame("TPE1", info.ID3v1Info.Artist); * //Album * info.ID3v2Info.SetTextFrame("TALB", info.ID3v1Info.Album); * * info.ID3v1Info.Album = ""; * info.ID3v1Info.Artist = ""; * info.ID3v1Info.Comment = ""; * info.ID3v1Info.Title = ""; * * * info.Save(); * } * } */ }
public MusicWindow(FileInfo imgSrc, ID3Info id3) { InitializeComponent(); SpectrumAnalyzer.RegisterSoundPlayer(BassEngine.Instance); fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + @"\Lyrics\" + System.IO.Path.GetFileNameWithoutExtension(imgSrc.Name) + ".lrc"; if (id3.ID3v2Info.HaveTag) { songName.Text = id3.ID3v2Info.GetTextFrame("TIT2") != "" ? id3.ID3v2Info.GetTextFrame("TIT2") : System.IO.Path.GetFileNameWithoutExtension(imgSrc.Name); artist.Text = id3.ID3v2Info.GetTextFrame("TPE1") != "" ? id3.ID3v2Info.GetTextFrame("TPE1") : "未知艺术家"; album.Text = id3.ID3v2Info.GetTextFrame("TALB") != "" ? "《" + id3.ID3v2Info.GetTextFrame("TALB") + "》" : "未知专辑"; year.Text = id3.ID3v2Info.GetTextFrame("TYER"); //kind.Text = id3.ID3v2Info.GetTextFrame("TCON"); } else { songName.Text = id3.ID3v1Info.Title != "" ? id3.ID3v1Info.Title : System.IO.Path.GetFileNameWithoutExtension(imgSrc.Name); artist.Text = id3.ID3v1Info.Artist != "" ? id3.ID3v1Info.Artist : "未知艺术家"; album.Text = id3.ID3v1Info.Album != "" ? "《" + id3.ID3v1Info.Album + "》" : "未知专辑"; year.Text = id3.ID3v1Info.Year; //kind.Text = genre[id3.ID3v1Info.Genre]; } timerLyric = new DispatcherTimer(); timerLyric.Interval = TimeSpan.FromMilliseconds(200); timerLyric.Tick += (a, b) => { ShowLyric(); }; timerLyric.Start(); this.Width = SystemParameters.PrimaryScreenWidth; this.Height = SystemParameters.PrimaryScreenHeight; this.Left = 0; this.Top = 0; // this.Topmost = true; gdCenter = new Point(0, 0); img = new BitmapImage(new Uri(imgSrc.FullName)); //根据分辨率不同,调整DetialWindow出现的位置 if (this.Width > 1300) { size = SystemParameters.PrimaryScreenWidth * 0.415; } else if (this.Width < 1300 && this.Width > 1000) { size = SystemParameters.PrimaryScreenWidth * 0.3; } gd.Background = new ImageBrush(img); if (img.Width >= img.Height) { w = size; h = size / img.Width * img.Height; } else { h = size; w = size / img.Height * img.Width; } stdStart = (Storyboard)this.Resources["start"]; stdMiddle = (Storyboard)this.Resources["middle"]; stdEnd = (Storyboard)this.Resources["end"]; stdEnd2 = (Storyboard)this.Resources["end_2"]; stdStart.Completed += (a, b) => { //stdMiddle.Begin(); MusicInfo.Visibility = Visibility.Visible; var datImg = new DoubleAnimation(0, -1 * SystemParameters.PrimaryScreenWidth * 0.2, new Duration(TimeSpan.FromMilliseconds(700))); var datInfo = new DoubleAnimation(0, SystemParameters.PrimaryScreenWidth * 0.2, new Duration(TimeSpan.FromMilliseconds(700))); var datPrs = new DoubleAnimation(0, 300, new Duration(TimeSpan.FromMilliseconds(2000))); tlt.BeginAnimation(TranslateTransform.XProperty, datImg); infoTlt.BeginAnimation(TranslateTransform.XProperty, datInfo); process.BeginAnimation(ProgressBar.WidthProperty, datPrs); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(200); timer.Tick += (c, d) => { double lX = Canvas.GetLeft(LeftHand) + LeftHand.ActualWidth / 2; double lY = Canvas.GetTop(LeftHand) + LeftHand.ActualHeight / 2; double rX = Canvas.GetLeft(RightHand) + RightHand.ActualWidth / 2; double rY = Canvas.GetTop(RightHand) + RightHand.ActualHeight / 2; double centerX = (rX - lX) / 2 + lX; double centerY = (rY - lY) / 2 + lY; double lenY = rX - lX; double timesX = lenY / gd.ActualWidth; timesX = timesX * timesX * 2; //double timesX = Math.Abs(rightHand.X - leftHand.X) / 300; double angleY = Math.Atan((rightHand.Y - leftHand.Y) / (rightHand.X - leftHand.X)) * 180 / Math.PI; double angleYLast = Math.Atan((rightHandLast.Y - leftHandLast.Y) / (rightHandLast.X - leftHandLast.X)) * 180 / Math.PI; leftHandLast = leftHand; rightHandLast = rightHand; if (double.IsInfinity(timesX) || double.IsNaN(timesX) || leftHandLast.X == 0 || rightHandLast.X == 0 || double.IsNaN(angleYLast) || Math.Abs(angleY - angleYLast) < 1.5) { return; } //timesX = Math.Sqrt(timesX); //if (Math.Abs(timesX - lastTimesX) > 0.2) //{ var das1 = new DoubleAnimation(lastTimesX, timesX, new Duration(TimeSpan.FromMilliseconds(200))); var das2 = new DoubleAnimation(lastTimesX, timesX, new Duration(TimeSpan.FromMilliseconds(200))); sct.CenterX = gd.ActualWidth / 2; sct.CenterY = gd.ActualHeight / 2; sct.BeginAnimation(ScaleTransform.ScaleXProperty, das1); sct.BeginAnimation(ScaleTransform.ScaleYProperty, das2); lastTimesX = timesX; //// } //double tanOffset = gd.RenderSize.Width / 2 + centerX / gd.RenderSize.Height / 2 + centerY; //angleY += Math.Atan(tanOffset) * 180 / Math.PI; var dar1 = new DoubleAnimation(angleYLast, angleY, new Duration(TimeSpan.FromMilliseconds(200))); rt.CenterX = gd.ActualWidth / 2; rt.CenterY = gd.ActualHeight / 2; rt.BeginAnimation(RotateTransform.AngleProperty, dar1); double deltaX = centerX - gd.ActualWidth / 2; double deltaY = centerY - gd.ActualHeight / 2; var dat1 = new DoubleAnimation(gdCenter.X, deltaX * 1.5, new Duration(TimeSpan.FromMilliseconds(200))); var dat2 = new DoubleAnimation(gdCenter.Y, deltaY * 1.5, new Duration(TimeSpan.FromMilliseconds(200))); tlt.BeginAnimation(TranslateTransform.XProperty, dat1); tlt.BeginAnimation(TranslateTransform.YProperty, dat2); gdCenter.X = deltaX; gdCenter.Y = deltaY; }; //timer.Start(); }; stdEnd.Completed += (c, d) => { CloseAnmit(); stdEnd2.Begin(); }; stdEnd2.Completed += (e, f) => { this.Close(); }; this.Loaded += MainWindow_Loaded; }
private void updateTagView(string file) { try { ID3Info info = new ID3Info(file, true); string text = Helper.String.Normalise(info.ID3v2Info.GetTextFrame("TIT2")); if (!String.IsNullOrEmpty(text)) { if (text != textTitle.Text) { if (textTitle.Text == String.Empty) { textTitle.Text = text; } else { textTitle.ForeColor = Color.Red; } } } text = Helper.String.Normalise(info.ID3v2Info.GetTextFrame("TPE1")); if (!String.IsNullOrEmpty(text)) { if (text != textArtist.Text) { if (textArtist.Text == String.Empty) { textArtist.Text = text; } else { textArtist.ForeColor = Color.Red; } } } text = Helper.String.Normalise(info.ID3v2Info.GetTextFrame("TALB")); if (!String.IsNullOrEmpty(text)) { if (text != textAlbum.Text) { if (textAlbum.Text == String.Empty) { textAlbum.Text = text; } else { textAlbum.ForeColor = Color.Red; } } } text = Helper.String.Normalise(info.ID3v2Info.GetTextFrame("TCON")); if (!String.IsNullOrEmpty(text)) { if (text != textGenre.Text) { if (textGenre.Text == String.Empty) { textGenre.Text = text; } else { textGenre.ForeColor = Color.Red; } } } text = Helper.String.Normalise(info.ID3v2Info.GetTextFrame("TRCK")); if (String.IsNullOrEmpty(text)) { comboTrack.Text = "1"; } else { if (String.IsNullOrEmpty(comboTrack.Text)) { int n = int.Parse(text); if (n > 0 && comboTrack.Text == string.Empty) { comboTrack.Text = n.ToString(); } } } if (pictureArtwork.Image == null) { List <Frame> frames = new List <Frame>(); foreach (AttachedPictureFrame ATP in info.ID3v2Info.AttachedPictureFrames.Items) { if (ATP.PictureType == AttachedPictureFrame.PictureTypes.Cover_Front) { ViewPicture(ATP); } } } } catch (Exception ex) { } }
public static void WriteMP3Tags(string filename, CD cd, int track) { ID3Info id3Info = new ID3Info(filename, true); int id3Version = Settings.Current.UseID3Version; int year = cd.Tracks[track].YearRecorded != 0 ? cd.Tracks[track].YearRecorded : cd.YearRecorded; if (id3Version == 0 || id3Version == 2) { // HACK JUS 08.04.2007: Damit ID3v2 Tags auch geschrieben werden, wenn kein ID3v2 Header vorhanden ist! // Ab und zu mal schauen, ob es vielleicht eine neue Version der Lib gibt // http://www.codeproject.com/cs/library/Do_Anything_With_ID3.asp id3Info.ID3v1Info.HaveTag = true; id3Info.ID3v1Info.Artist = cd.Sampler ? cd.Tracks[track].Artist : cd.Artist; id3Info.ID3v1Info.Title = cd.Tracks[track].Title; id3Info.ID3v1Info.Comment = cd.Comment; id3Info.ID3v1Info.TrackNumber = (byte)(track + 1); id3Info.ID3v1Info.Album = cd.Title; id3Info.ID3v1Info.Year = year != 0 ? year.ToString() : ""; } if (id3Version == 1 || id3Version == 2) { // HACK JUS 08.04.2007: Damit ID3v2 Tags auch geschrieben werden, wenn kein ID3v2 Header vorhanden ist! // Ab und zu mal schauen, ob es vielleicht eine neue Version der Lib gibt // http://www.codeproject.com/cs/library/Do_Anything_With_ID3.asp id3Info.ID3v2Info.HaveTag = true; id3Info.ID3v2Info.SetMinorVersion(3); id3Info.ID3v2Info.SetTextFrame("TPE1", cd.Sampler ? cd.Tracks[track].Artist : cd.Artist); id3Info.ID3v2Info.SetTextFrame("TIT2", cd.Tracks[track].Title); id3Info.ID3v2Info.SetTextWithLanguageFrame("COMM", cd.Comment); id3Info.ID3v2Info.SetTextFrame("TRCK", (track + 1).ToString()); id3Info.ID3v2Info.SetTextFrame("TALB", cd.Title); id3Info.ID3v2Info.SetTextFrame("TYER", year != 0 ? year.ToString() : ""); id3Info.ID3v2Info.SetTextFrame("TCON", cd.Category); id3Info.ID3v2Info.SetTextFrame("TCOM", cd.Composer); id3Info.ID3v2Info.SetTextFrame("TLAN", cd.Language); // Das mit dem Rating geht irgendwie anders. Erst mal raus // id3Info.ID3v2Info.PopularimeterFrames.Add(.SetTextFrame("POPM", cd.Rating > 0 ? cd.Rating.ToString() : ""); id3Info.ID3v2Info.SetTextFrame("TBPM", cd.Tracks[track].Bpm > 0 ? cd.Tracks[track].Bpm.ToString() : ""); id3Info.ID3v2Info.SetTextFrame("TLEN", cd.Tracks[track].Length > 0 ? cd.Tracks[track].Length.ToString() : ""); try { if (!string.IsNullOrEmpty(cd.CDCoverFrontFilename)) { byte[] filefrontcover = File.ReadAllBytes(cd.CDCoverFrontFilename); string mimetype; mimetype = GetMIMEType(Path.GetExtension(cd.CDCoverFrontFilename)); MemoryStream memstream = new MemoryStream(filefrontcover); AttachedPictureFrame item = new AttachedPictureFrame((FrameFlags)0, "", 0, mimetype, AttachedPictureFrame.PictureTypes.Cover_Front, memstream); id3Info.ID3v2Info.AttachedPictureFrames.Add(item); } } catch { // Pech gehabt - kein Cover } try { if (!string.IsNullOrEmpty(cd.Tracks[track].Lyrics)) { ID3.ID3v2Frames.TextFrames.TextWithLanguageFrame textFrame = new ID3.ID3v2Frames.TextFrames.TextWithLanguageFrame("USLT", 0, cd.Tracks[track].Lyrics, "", TextEncodings.UTF_16, "und"); id3Info.ID3v2Info.TextWithLanguageFrames.Add(textFrame); } } catch { // Sicherheitshalber mal abgefragt } } try { switch (id3Version) { case 0: id3Info.ID3v1Info.Save(); break; case 1: id3Info.ID3v2Info.Save(); break; case 2: id3Info.ID3v1Info.Save(); id3Info.ID3v2Info.Save(); break; } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString(), System.Windows.Forms.Application.ProductName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } }