-
Notifications
You must be signed in to change notification settings - Fork 0
/
Popularimeter.cs
45 lines (38 loc) · 1.31 KB
/
Popularimeter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace NAudio.Flac
{
public class Popularimeter : Frame
{
public string UserEmail { get; private set; }
/// <summary>
/// Range from 1(worst) to 255(best). Zero -> Rating disabled.
/// </summary>
public byte Rating { get; private set; }
/// <summary>
/// - 1 -> ommit the counter. Default length is 4 byte. If 4 byte is not enough to hold the
/// number, a byte will be added(up to 8 bytes total).
/// </summary>
public long PlayedCounter { get; private set; }
public Popularimeter(FrameHeader header)
: base(header)
{
}
protected override void Decode(byte[] content)
{
int offset = 0;
int read;
UserEmail = ID3Utils.ReadString(content, 0, -1, ID3Utils.Iso88591, out read);
offset += read;
Rating = content[offset];
offset++;
if (offset < content.Length)
{
int pos = 0;
for (int i = offset; i < content.Length; i++)
{
PlayedCounter |= ((uint)(content[i] << pos)); //cast to uint to fix warning CS0675
pos += 8;
}
}
}
}
}