public RemoveBlock ( long start, long length ) : void | ||
start | long |
/// A |
length | long |
/// A |
return | void |
private static void RemoveLyrics(TagLib.File mp3File) { var maxLength = 512; ByteVector initVector = new ByteVector(Encoding.UTF8.GetBytes("LYRICSBEGIN")); long initOffset = mp3File.Find(initVector, startPosition: 0); if ((initOffset != -1)) { // The Lyrics3 block can end with one of these two markups, so we need to evaluate both. foreach (string str in new[] { "LYRICS200", "LYRICSEND" }) { ByteVector endVector = new ByteVector(Encoding.UTF8.GetBytes(str)); long endOffset = mp3File.Find(endVector, startPosition: initOffset); if ((endOffset != -1)) { int length = System.Convert.ToInt32(endOffset - initOffset) + (str.Length); if ((length < maxLength)) { try { mp3File.Seek(initOffset, SeekOrigin.Begin); // Dim raw As String = Me.mp3File.ReadBlock(length).ToString() mp3File.RemoveBlock(initOffset, length); Console.WriteLine($"Removed lyrics in {mp3File.Name}"); return; } catch (Exception ex) { throw ex; } finally { mp3File.Seek(0, SeekOrigin.Begin); } } else { // We can handle it or continue... continue; } } } } }