1 | package org.farng.mp3.id3; |
2 | |
3 | import org.farng.mp3.InvalidTagException; |
4 | import org.farng.mp3.object.ObjectNumberFixedLength; |
5 | import org.farng.mp3.object.ObjectNumberVariableLength; |
6 | import org.farng.mp3.object.ObjectStringNullTerminated; |
7 | |
8 | import java.io.IOException; |
9 | import java.io.RandomAccessFile; |
10 | |
11 | /** |
12 | * <h3>4.17. Popularimeter</h3> |
13 | * <p/> |
14 | * <p> The purpose of this frame is to specify how good an audio file is.<br> Many interesting |
15 | * applications could be found to this frame such as a<br> playlist that features better audio files more |
16 | * often than others or<br> |
17 | * <p/> |
18 | * it could be used to profile a person's taste and find other 'good'<br> files by comparing |
19 | * people's profiles. The frame contains the email<br> address to the user, one rating byte and a four byte |
20 | * play counter,<br> intended to be increased with one for every time the file is played.<br> |
21 | * The email is a terminated string. The rating is 1-255 where 1 is<br> |
22 | * <p/> |
23 | * worst and 255 is best. 0 is unknown. If no personal counter is wanted<br> it may be |
24 | * omitted. When the counter reaches all one's, one byte is<br> inserted in front of the counter thus |
25 | * making the counter eight bits<br> bigger in the same away as the play counter ("PCNT"). There |
26 | * may be<br> |
27 | * <p/> |
28 | * more than one "POPM" frame in each tag, but only one with the same<br> email |
29 | * address.</p> |
30 | * <p/> |
31 | * <p> <Header for 'Popularimeter', ID: "POPM"><br> |
32 | * Email to user <text string> $00<br> |
33 | * <p/> |
34 | * Rating $xx<br> |
35 | * Counter $xx xx xx xx (xx ...)<br> </p> |
36 | * |
37 | * @author Eric Farng |
38 | * @version $Revision: 1.4 $ |
39 | */ |
40 | public class FrameBodyPOPM extends AbstractID3v2FrameBody { |
41 | |
42 | /** |
43 | * Creates a new FrameBodyPOPM object. |
44 | */ |
45 | public FrameBodyPOPM() { |
46 | super(); |
47 | } |
48 | |
49 | /** |
50 | * Creates a new FrameBodyPOPM object. |
51 | */ |
52 | public FrameBodyPOPM(final FrameBodyPOPM body) { |
53 | super(body); |
54 | } |
55 | |
56 | /** |
57 | * Creates a new FrameBodyPOPM object. |
58 | */ |
59 | public FrameBodyPOPM(final String emailToUser, final byte rating, final long counter) { |
60 | setObject("Email to User", emailToUser); |
61 | setObject("Rating", new Byte(rating)); |
62 | setObject("Counter", new Long(counter)); |
63 | } |
64 | |
65 | /** |
66 | * Creates a new FrameBodyPOPM object. |
67 | */ |
68 | public FrameBodyPOPM(final RandomAccessFile file) throws IOException, InvalidTagException { |
69 | this.read(file); |
70 | } |
71 | |
72 | public void setEmailToUser(final String description) { |
73 | setObject("Email to User", description); |
74 | } |
75 | |
76 | public String getEmailToUser() { |
77 | return (String) getObject("Email to User"); |
78 | } |
79 | |
80 | public String getIdentifier() { |
81 | return "POPM" + ((char) 0) + getEmailToUser(); |
82 | } |
83 | |
84 | protected void setupObjectList() { |
85 | appendToObjectList(new ObjectStringNullTerminated("Email to User")); |
86 | appendToObjectList(new ObjectNumberFixedLength("Rating", 1)); |
87 | appendToObjectList(new ObjectNumberVariableLength("Counter", 1)); |
88 | } |
89 | } |