Skip to content

Commit 514d290

Browse files
committed
WMA : Support full date in YEAR field [#374]
1 parent 442267b commit 514d290

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

ATL.unit-test/IO/HighLevel.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Buffers.Binary;
22
using ATL.AudioData;
33
using System.Drawing;
4+
using System.Text;
45
using ATL.test.IO.MetaData;
56
using static ATL.Logging.Log;
67
using ATL.Logging;
@@ -1278,6 +1279,7 @@ public void TagIO_RW_Year_or_Date_On_File()
12781279
{
12791280
tagIO_RW_Year_or_Date_On_File("MP4/empty.m4a", "MP4/mp4.m4a", "MP4/mp4_date_in_©day.m4a", 20, 26);
12801281
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);
12811283

12821284
MetaDataIOFactory.TagType defType = ATL.Settings.DefaultTagsWhenNoMetadata[0];
12831285
ATL.Settings.DefaultTagsWhenNoMetadata[0] = MetaDataIOFactory.TagType.APE;
@@ -1398,6 +1400,7 @@ private int getDateFieldLength(string filePath)
13981400
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
13991401
{
14001402
if (filePath.EndsWith("ogg")) return getVorbisDateFieldLength(fs);
1403+
if (filePath.EndsWith("wma")) return getWmaDateFieldLength(fs);
14011404
if (filePath.EndsWith("m4a")) return getMP4DateFieldLength(fs);
14021405
if (filePath.EndsWith("mp3")) return getApeDateFieldLength(fs);
14031406
return -1;
@@ -1440,6 +1443,15 @@ private int getApeDateFieldLength(Stream s)
14401443
return BinaryPrimitives.ReadInt32LittleEndian(buffer);
14411444
}
14421445

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+
14431455
[TestMethod]
14441456
public void TagIO_RW_Track_Number_Str_Num()
14451457
{
33.8 KB
Binary file not shown.

ATL/AudioData/IO/WMA.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private void Reset()
9393
{ "WM/AUTHOR", Field.ARTIST },
9494
{ "WM/COPYRIGHT", Field.COPYRIGHT },
9595
{ "WM/DESCRIPTION", Field.COMMENT },
96-
{ "WM/Year", Field.RECORDING_YEAR },
96+
{ "WM/Year", Field.RECORDING_DATE_OR_YEAR },
9797
{ "WM/Genre", Field.GENRE },
9898
{ "WM/TrackNumber", Field.TRACK_NUMBER_TOTAL },
9999
{ "WM/PartOfSet", Field.DISC_NUMBER_TOTAL },

0 commit comments

Comments
 (0)