ID3v2-Tag kopieren

    • VB.NET

      ID3v2-Tag kopieren

      Mit dieser Sub kann man einen ID3v2-Tag von der source-MP3 in die dest-MP3 kopieren:

      VB.NET-Quellcode

      1. Private Sub CopyID3Tag(ByVal source As String, ByVal dest As String)
      2. Dim bytes() As Byte, orgbytes() As Byte
      3. bytes = IO.File.ReadAllBytes(dest)
      4. orgbytes = IO.File.ReadAllBytes(source)
      5. Dim l As Long, orgl As Long
      6. l = Math.Pow(128, 3) * bytes(6) + Math.Pow(128, 2) * bytes(7) + 128 * bytes(8) + bytes(9)
      7. orgl = Math.Pow(128, 3) * orgbytes(6) + Math.Pow(128, 2) * orgbytes(7) + 128 * orgbytes(8) + orgbytes(9)
      8. Using bw As New IO.BinaryWriter(New IO.FileStream(dest, IO.FileMode.Open))
      9. Dim b(orgl + 10) As Byte
      10. Array.ConstrainedCopy(orgbytes, 0, b, 0, b.Length)
      11. bw.Write(b)
      12. Dim bb(bytes.Length - l - 11) As Byte
      13. Array.ConstrainedCopy(bytes, l + 10, bb, 0, bb.Length)
      14. bw.Write(bb)
      15. bw.Close()
      16. End Using
      17. End Sub