|
1 | 1 | using System.Buffers.Binary; |
2 | 2 | using ATL.AudioData; |
3 | 3 | using System.Drawing; |
| 4 | +using System.Text; |
4 | 5 | using ATL.test.IO.MetaData; |
5 | 6 | using static ATL.Logging.Log; |
6 | 7 | using ATL.Logging; |
@@ -1278,6 +1279,7 @@ public void TagIO_RW_Year_or_Date_On_File() |
1278 | 1279 | { |
1279 | 1280 | tagIO_RW_Year_or_Date_On_File("MP4/empty.m4a", "MP4/mp4.m4a", "MP4/mp4_date_in_©day.m4a", 20, 26); |
1280 | 1281 | tagIO_RW_Year_or_Date_On_File("OGG/empty.ogg", "OGG/chapters.ogg", "OGG/ogg.ogg", 9, 15); |
| 1282 | + tagIO_RW_Year_or_Date_On_File("WMA/empty_full.wma", "WMA/wma.wma", "WMA/date_in_year.wma", 10, 22); |
1281 | 1283 |
|
1282 | 1284 | MetaDataIOFactory.TagType defType = ATL.Settings.DefaultTagsWhenNoMetadata[0]; |
1283 | 1285 | ATL.Settings.DefaultTagsWhenNoMetadata[0] = MetaDataIOFactory.TagType.APE; |
@@ -1398,6 +1400,7 @@ private int getDateFieldLength(string filePath) |
1398 | 1400 | using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) |
1399 | 1401 | { |
1400 | 1402 | if (filePath.EndsWith("ogg")) return getVorbisDateFieldLength(fs); |
| 1403 | + if (filePath.EndsWith("wma")) return getWmaDateFieldLength(fs); |
1401 | 1404 | if (filePath.EndsWith("m4a")) return getMP4DateFieldLength(fs); |
1402 | 1405 | if (filePath.EndsWith("mp3")) return getApeDateFieldLength(fs); |
1403 | 1406 | return -1; |
@@ -1440,6 +1443,15 @@ private int getApeDateFieldLength(Stream s) |
1440 | 1443 | return BinaryPrimitives.ReadInt32LittleEndian(buffer); |
1441 | 1444 | } |
1442 | 1445 |
|
| 1446 | + private int getWmaDateFieldLength(Stream s) |
| 1447 | + { |
| 1448 | + Assert.AreEqual(true, StreamUtils.FindSequence(s, Encoding.BigEndianUnicode.GetBytes("WM/Year"))); |
| 1449 | + byte[] buffer = new byte[4]; |
| 1450 | + s.Seek(2, SeekOrigin.Current); |
| 1451 | + s.Read(buffer, 0, 4); |
| 1452 | + return BinaryPrimitives.ReadInt32BigEndian(buffer); |
| 1453 | + } |
| 1454 | + |
1443 | 1455 | [TestMethod] |
1444 | 1456 | public void TagIO_RW_Track_Number_Str_Num() |
1445 | 1457 | { |
|
0 commit comments