Skip to content

Commit e6a7d8f

Browse files
committed
add Properties.HasImage
1 parent 4ec19d0 commit e6a7d8f

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

taglib.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ taglib_file_audioproperties(const char *filename) {
9999
arr[2] = audioProperties->sampleRate();
100100
arr[3] = audioProperties->bitrate();
101101

102+
const auto &pictures = file.complexProperties("PICTURE");
103+
arr[4] = pictures.isEmpty() ? 0 : 1;
104+
102105
return arr;
103106
}
104107

taglib.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ type Properties struct {
179179
SampleRate uint
180180
// Bitrate in kbit/s
181181
Bitrate uint
182+
// HasImage indicates whether the file contains embedded images
183+
HasImage bool
182184
}
183185

184186
// ReadProperties reads the audio properties from a file at the given path.
@@ -201,6 +203,7 @@ func ReadProperties(path string) (Properties, error) {
201203
audioPropertyChannels
202204
audioPropertySampleRate
203205
audioPropertyBitrate
206+
audioPropertyHasImage
204207
audioPropertyLen
205208
)
206209

@@ -214,6 +217,7 @@ func ReadProperties(path string) (Properties, error) {
214217
Channels: uint(raw[audioPropertyChannels]),
215218
SampleRate: uint(raw[audioPropertySampleRate]),
216219
Bitrate: uint(raw[audioPropertyBitrate]),
220+
HasImage: raw[audioPropertyHasImage] == 1,
217221
}, nil
218222
}
219223

taglib.wasm

140 Bytes
Binary file not shown.

taglib_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ func TestMultiOpen(t *testing.T) {
250250

251251
func TestReadImage(t *testing.T) {
252252
path := tmpf(t, egFLAC, "eg.flac")
253+
254+
properties, err := taglib.ReadProperties(path)
255+
nilErr(t, err)
256+
eq(t, properties.HasImage, true)
257+
253258
imgBytes, err := taglib.ReadImage(path)
254259
nilErr(t, err)
255260
if imgBytes == nil {

0 commit comments

Comments
 (0)