com.beaglebuddy.id3.v24.frame_body

## Class ID3v24FrameBodyPositionSynchronization

- java.lang.Object
- - com.beaglebuddy.util.Utility
  - - com.beaglebuddy.id3.v24.frame_body.ID3v24FrameBodyUtility
    - - com.beaglebuddy.id3.v24.frame_body.ID3v24FrameBody
      - - com.beaglebuddy.id3.v24.frame_body.ID3v24FrameBodyPositionSynchronization

-     public class ID3v24FrameBodyPositionSynchronization
      extends ID3v24FrameBody

  An position synchronization frame body is associated with an ID3v2.4 `POSS` `frame` which is used to deliver information to the listener on how far into the audio stream he picked up. In effect, it states the time offset of the first frame in the stream. The position synchronization frame body contains the following fields:

  Position Synchronization Frame Body Fields
  | Field | Description
  --- | --- | ---
  1. | `time stamp format` | `units` of the position field.
  2. | position | the position in the audio the listener starts to receive, i.e. the beginning of the next frame.

  There may only be one position synchronization frame in the tag.

  See Also:
    `ID3v24Frame`, ID3 tag version 2.4.0 standard, wikipedia history of ID3 tags

- - ### Field Summary

    - ### Fields inherited from class com.beaglebuddy.id3.v24.frame_body.ID3v24FrameBody

      `buffer, dirty, frameType`

    - ### Fields inherited from class com.beaglebuddy.id3.v24.frame_body.ID3v24FrameBodyUtility

      `nextNullTerminatorIndex, nullTerminatorIndex`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ID3v24FrameBodyPositionSynchronization()` The default constructor is called when creating a new frame.
    `ID3v24FrameBodyPositionSynchronization(java.io.InputStream inputStream, int frameBodySize)` This constructor is called when reading in an existing frame from an .mp3 file.
    `ID3v24FrameBodyPositionSynchronization(TimeStampFormat timeStampFormat, int position)` This constructor is called when creating a new frame.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getPosition()` gets the position within the song.
    `TimeStampFormat` | `getTimeStampFormat()` get the time stamp format.
    `void` | `parse()` parses the raw bytes of the frame body and stores the parsed values in the frame's fields.
    `void` | `setBuffer()` If the frame body's values have been modified, then resize the raw binary buffer and store the new values there.
    `void` | `setPosition(int position)` sets the position within the song.
    `void` | `setTimeStampFormat(TimeStampFormat timeStampFormat)` sets the time stamp format.
    `java.lang.String` | `toString()` gets a string representation of the position synchronization frame body showing all of the frame's fields and their values.

    - ### Methods inherited from class com.beaglebuddy.id3.v24.frame_body.ID3v24FrameBody

      `getFrameType, getNextNullTerminator, getSize, isDirty, save, save`

    - ### Methods inherited from class com.beaglebuddy.id3.v24.frame_body.ID3v24FrameBodyUtility

      `getNextNullTerminator, pricesToString, stringToBytes`

    - ### Methods inherited from class com.beaglebuddy.util.Utility

      `bytesToInt, bytesToInt, bytesToShort, bytesToShort, bytesToSynchsafeInt, bytesToSynchsafeShort, formateDate, getUTF16String, getUTF8String, hex, hex, hex, intToBytes, littleEndianBytesToInt, pad, shortToBytes, synchsafeIntToBytes`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ID3v24FrameBodyPositionSynchronization

          public ID3v24FrameBodyPositionSynchronization()

      The default constructor is called when creating a new frame. The default values used are:
      - time stamp format in milliseconds
      - position 0

    - #### ID3v24FrameBodyPositionSynchronization

          public ID3v24FrameBodyPositionSynchronization(TimeStampFormat timeStampFormat,
                                                int position)

      This constructor is called when creating a new frame.
      Parameters:
        `timeStampFormat` - units of the time stamp. see `setTimeStampFormat(TimeStampFormat)`
        `position` - position within song

    - #### ID3v24FrameBodyPositionSynchronization

          public ID3v24FrameBodyPositionSynchronization(java.io.InputStream inputStream,
                                                int frameBodySize)
                                                 throws java.io.IOException

      This constructor is called when reading in an existing frame from an .mp3 file. This is then followed by a call to the parse() method.
      Parameters:
        `inputStream` - input stream pointing to a position synchronization frame body in the .mp3 file.
        `frameBodySize` - size (in bytes) of the frame's body.
      Throws:
        `java.io.IOException` - if there is an error while reading in the frame body.

  - ### Method Detail

    - #### parse

          public void parse()
                     throws java.lang.IllegalArgumentException

      parses the raw bytes of the frame body and stores the parsed values in the frame's fields.
      Overrides:
        `parse` in class `ID3v24FrameBody`
      Throws:
        `java.lang.IllegalArgumentException` - if an invalid value is detected while parsing the frame body's raw bytes.

    - #### getPosition

          public int getPosition()

      gets the position within the song.
      Returns:
        the position within the song.
      See Also:
        `setPosition(int)`

    - #### getTimeStampFormat

          public TimeStampFormat getTimeStampFormat()

      get the time stamp format.
      Returns:
        the time stamp format.
      See Also:
        `setTimeStampFormat(TimeStampFormat)`

    - #### setTimeStampFormat

          public void setTimeStampFormat(TimeStampFormat timeStampFormat)

      sets the time stamp format.
      Parameters:
        `timeStampFormat` - the units of the time stamp.
      See Also:
        `getTimeStampFormat()`

    - #### setPosition

          public void setPosition(int position)
                           throws java.lang.IllegalArgumentException

      sets the position within the song.
      Parameters:
        `position` - the position within the song.
      Throws:
        `java.lang.IllegalArgumentException` - if the position is less than 0.
      See Also:
        `getPosition()`

    - #### setBuffer

          public void setBuffer()

      If the frame body's values have been modified, then resize the raw binary buffer and store the new values there. When finished, the dirty flag is reset to indicate that the buffer is up to date, and the frame is now ready to be saved to the .mp3 file.
      Overrides:
        `setBuffer` in class `ID3v24FrameBody`

    - #### toString

          public java.lang.String toString()

      gets a string representation of the position synchronization frame body showing all of the frame's fields and their values.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a string representation of the frame body.