2
* MusicTag Copyright (C)2003,2004
4
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
5
* General Public License as published by the Free Software Foundation; either version 2.1 of the License,
6
* or (at your option) any later version.
8
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
* See the GNU Lesser General Public License for more details.
12
* You should have received a copy of the GNU Lesser General Public License along with this library; if not,
13
* you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
package org.jaudiotagger.tag.id3.framebody;
18
import org.jaudiotagger.tag.InvalidTagException;
19
import org.jaudiotagger.tag.datatype.DataTypes;
20
import org.jaudiotagger.tag.datatype.NumberVariableLength;
21
import org.jaudiotagger.tag.id3.ID3v24Frames;
23
import java.nio.ByteBuffer;
29
* This is simply a counter of the number of times a file has been
30
* played. The value is increased by one every time the file begins to
31
* play. There may only be one "PCNT" frame in each tag. When the
32
* counter reaches all one's, one byte is inserted in front of the
33
* counter thus making the counter eight bits bigger. The counter must
34
* be at least 32-bits long to begin with.
35
* </p><p><table border=0 width="70%">
36
* <tr><td colspan=2> <Header for 'Play counter', ID: "PCNT"></td></tr>
37
* <tr><td>Counter </td><td>$xx xx xx xx (xx ...)</td></tr>
40
* <p>For more details, please refer to the ID3 specifications:
42
* <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
45
* @author : Paul Taylor
46
* @author : Eric Farng
47
* @version $Id: FrameBodyPCNT.java,v 1.12 2007/08/06 16:04:34 paultaylor Exp $
49
public class FrameBodyPCNT extends AbstractID3v2FrameBody implements ID3v24FrameBody,ID3v23FrameBody
51
private static final int COUNTER_MINIMUM_FIELD_SIZE=4;
54
* Creates a new FrameBodyPCNT datatype.
56
public FrameBodyPCNT()
58
this.setObjectValue(DataTypes.OBJ_NUMBER, 0L);
61
public FrameBodyPCNT(FrameBodyPCNT body)
67
* Creates a new FrameBodyPCNT datatype.
71
public FrameBodyPCNT(long counter)
73
this.setObjectValue(DataTypes.OBJ_NUMBER, counter);
77
* Creates a new FrameBodyPCNT datatype.
79
* @throws InvalidTagException if unable to create framebody from buffer
81
public FrameBodyPCNT(ByteBuffer byteBuffer, int frameSize)
82
throws InvalidTagException
84
super(byteBuffer, frameSize);
90
* @return the play count of this file
92
public long getCounter()
94
return ((Number) getObjectValue(DataTypes.OBJ_NUMBER)).longValue();
98
* Set the play counter of this file
102
public void setCounter(long counter)
104
setObjectValue(DataTypes.OBJ_NUMBER, counter);
107
* The ID3v2 frame identifier
109
* @return the ID3v2 frame identifier for this frame type
111
public String getIdentifier()
113
return ID3v24Frames.FRAME_ID_PLAY_COUNTER;
119
protected void setupObjectList()
121
objectList.add(new NumberVariableLength(DataTypes.OBJ_NUMBER, this,COUNTER_MINIMUM_FIELD_SIZE));