|
| 1 | +[node-taglib-sharp](../README.md) / [Exports](../modules.md) / Id3v2FrameFactory |
| 2 | + |
| 3 | +# Class: Id3v2FrameFactory |
| 4 | + |
| 5 | +Performs the necessary operations to determine and create the correct child classes of |
| 6 | +Frame for a given raw ID3v2 frame. |
| 7 | +By default, this will only load frames contained in the library. To add additional frames to the |
| 8 | +process, register a frame creator with [addFrameCreator](Id3v2FrameFactory.md#addframecreator). |
| 9 | + |
| 10 | +## Table of contents |
| 11 | + |
| 12 | +### Constructors |
| 13 | + |
| 14 | +- [constructor](Id3v2FrameFactory.md#constructor) |
| 15 | + |
| 16 | +### Methods |
| 17 | + |
| 18 | +- [addFrameCreator](Id3v2FrameFactory.md#addframecreator) |
| 19 | +- [clearFrameCreators](Id3v2FrameFactory.md#clearframecreators) |
| 20 | +- [createFrame](Id3v2FrameFactory.md#createframe) |
| 21 | + |
| 22 | +## Constructors |
| 23 | + |
| 24 | +### constructor |
| 25 | + |
| 26 | +• **new Id3v2FrameFactory**() |
| 27 | + |
| 28 | +## Methods |
| 29 | + |
| 30 | +### addFrameCreator |
| 31 | + |
| 32 | +▸ `Static` **addFrameCreator**(`creator`): `void` |
| 33 | + |
| 34 | +Adds a custom frame creator to try before using standard frame creation methods. |
| 35 | +Frame creators are used before standard methods so custom checking can be used and new |
| 36 | +formats can be added. They are executed in reverse order in which they are added. |
| 37 | + |
| 38 | +#### Parameters |
| 39 | + |
| 40 | +| Name | Type | Description | |
| 41 | +| :------ | :------ | :------ | |
| 42 | +| `creator` | [`Id3v2FrameCreator`](../modules.md#id3v2framecreator) | Frame creator function * data: ByteVector Raw ID3v2 frame * offset: number Offset in data at which the frame data begins (should be int) * header: Id3v2FrameHeader Header for the frame contained in data * version: number ID3v2 version the raw frame data is stored in (should be byte) * returns Frame if method was able to match the frame, falsy otherwise | |
| 43 | + |
| 44 | +#### Returns |
| 45 | + |
| 46 | +`void` |
| 47 | + |
| 48 | +___ |
| 49 | + |
| 50 | +### clearFrameCreators |
| 51 | + |
| 52 | +▸ `Static` **clearFrameCreators**(): `void` |
| 53 | + |
| 54 | +Removes all custom frame creators |
| 55 | + |
| 56 | +#### Returns |
| 57 | + |
| 58 | +`void` |
| 59 | + |
| 60 | +___ |
| 61 | + |
| 62 | +### createFrame |
| 63 | + |
| 64 | +▸ `Static` **createFrame**(`data`, `file`, `offset`, `version`, `alreadyUnsynced`): `Object` |
| 65 | + |
| 66 | +Creates a Frame object by reading it from raw ID3v2 frame data. |
| 67 | + |
| 68 | +#### Parameters |
| 69 | + |
| 70 | +| Name | Type | Description | |
| 71 | +| :------ | :------ | :------ | |
| 72 | +| `data` | [`ByteVector`](ByteVector.md) | Raw ID3v2 frame | |
| 73 | +| `file` | [`File`](File.md) | File to read the frame from if `data` is falsy | |
| 74 | +| `offset` | `number` | Index into `file` or in `data` if truthy, at which the frame begins. After reading, the offset where the next frame can be read is returned in the `offset` property of the returned object | |
| 75 | +| `version` | `number` | ID3v2 version the frame is encoded with. Must be unsigned 8-bit int | |
| 76 | +| `alreadyUnsynced` | `boolean` | Whether or not the entire tag has already been unsynchronized | |
| 77 | + |
| 78 | +#### Returns |
| 79 | + |
| 80 | +`Object` |
| 81 | + |
| 82 | +Undefined is returned if there are no more frames to read. |
| 83 | + Object is returned if a frame was found. Object has the following properties: |
| 84 | + * frame: Frame that was read |
| 85 | + * offset: updated offset where the next frame starts |
| 86 | + |
| 87 | +| Name | Type | |
| 88 | +| :------ | :------ | |
| 89 | +| `frame` | [`Id3v2Frame`](Id3v2Frame.md) | |
| 90 | +| `offset` | `number` | |
0 commit comments