encodeSync method

List<int> encodeSync(
  1. MetadataEditable data
)

synchronous encoding id3

  • data: ID3 tag metadata information, you can set ID3v1/v1.1 or ID3v2.3 or ID3v2.4 metadataBody, but not support ID3v2.2
final encoder = ID3Encoder(bytes);
final resultBytes = encoder.encodeSync(MetadataV2p3Body(
            title: '听我说谢谢你!',
            artist: '歌手ijinfeng',
            userDefines: {"时长": '2:48', "userId": "ijinfeng"},
            album: 'ijinfeng出产的专辑',
        ));

Implementation

List<int> encodeSync(MetadataEditable data) {
  if (data is MetadataV1Body) {
    final encoder = ID3V1Encoder(_bytes);
    return encoder.encode(data);
  } else if (data is MetadataV2p3Body)  {
    final encoder = ID3V2p3Encoder(_bytes);
    return encoder.encode(data);
  } else if (data is MetadataV2p4Body) {
    final encoder = ID3V2p4Encoder(_bytes);
    return encoder.encode(data);
  }
  return _bytes;
}