You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$audio->getAudio(); // `?AudioMetadata` with audio metadata
106
+
$audio->getCover(); // `?AudioCover` with cover metadata
101
107
```
102
108
103
109
### Update
@@ -109,8 +115,10 @@ You can update audio files metadata with `Audio::class`, but not all formats are
109
115
> You can use any property of `Audio::class` but if you use a property not supported by the format, it will be ignored.
110
116
111
117
```php
118
+
use Kiwilan\Audio\Audio;
119
+
112
120
$audio = Audio::get('path/to/audio.mp3');
113
-
$audio->title(); // `Title`
121
+
$audio->getTitle(); // `Title`
114
122
115
123
$tag = $audio->update()
116
124
->title('New Title')
@@ -134,8 +142,8 @@ $tag = $audio->update()
134
142
->save();
135
143
136
144
$audio = Audio::get('path/to/audio.mp3');
137
-
$audio->title(); // `New Title`
138
-
$audio->creationDate(); // `null` because `creationDate` is not supported by `MP3`
145
+
$audio->getTitle(); // `New Title`
146
+
$audio->getCreationDate(); // `null` because `creationDate` is not supported by `MP3`
139
147
```
140
148
141
149
Some properties are not supported by all formats, for example `MP3` can't handle some properties like `lyrics` or `stik`, if you try to update these properties, they will be ignored.
@@ -151,8 +159,10 @@ You can set tags manually with `tags` method, but you need to know the format of
151
159
> If your key is not supported, `save` method will throw an exception, unless you use `preventFailOnErrors`.
152
160
153
161
```php
162
+
use Kiwilan\Audio\Audio;
163
+
154
164
$audio = Audio::get('path/to/audio.mp3');
155
-
$audio->albumArtist(); // `Band`
165
+
$audio->getAlbumArtist(); // `Band`
156
166
157
167
$tag = $audio->update()
158
168
->tags([
@@ -163,29 +173,33 @@ $tag = $audio->update()
163
173
->save();
164
174
165
175
$audio = Audio::get('path/to/audio.mp3');
166
-
$audio->albumArtist(); // `New Band`
176
+
$audio->getAlbumArtist(); // `New Band`
167
177
```
168
178
169
179
#### Arrow functions
170
180
171
181
```php
182
+
use Kiwilan\Audio\Audio;
183
+
172
184
$audio = Audio::get('path/to/audio.mp3');
173
-
$audio->albumArtist(); // `Band`
185
+
$audio->getAlbumArtist(); // `Band`
174
186
175
187
$tag = $audio->update()
176
188
->title('New Title')
177
189
->albumArtist('New Band') // `albumArtist` will set `band` for `id3v2`, exception safe
178
190
->save();
179
191
180
192
$audio = Audio::get('path/to/audio.mp3');
181
-
$audio->albumArtist(); // `New Band`
193
+
$audio->getAlbumArtist(); // `New Band`
182
194
```
183
195
184
196
#### Prevent fail on errors
185
197
186
198
You can use `preventFailOnError` to prevent exception if you use unsupported format.
187
199
188
200
```php
201
+
use Kiwilan\Audio\Audio;
202
+
189
203
$audio = Audio::get('path/to/audio.mp3');
190
204
191
205
$tag = $audio->update()
@@ -200,6 +214,8 @@ $tag = $audio->update()
200
214
Arrow functions are exception safe for properties but not for unsupported formats.
$audio->getCover()->getWidth(); // `?int` in pixels
329
+
$audio->getCover()->getHeight(); // `?int` in pixels
304
330
```
305
331
306
332
## Supported formats
@@ -424,8 +450,10 @@ composer test
424
450
In `Audio::class`, you have a property `extras` which contains all raw metadata, if `JamesHeinrich/getID3` support this field, you will find it in this property.
425
451
426
452
```php
453
+
use Kiwilan\Audio\Audio;
454
+
427
455
$audio = Audio::get('path/to/audio.mp3');
428
-
$extras = $audio->extras();
456
+
$extras = $audio->getExtras();
429
457
430
458
$custom = null;
431
459
$id3v2 = $extras['id3v2'] ?? [];
@@ -442,9 +470,11 @@ If your field could be added to global properties of `Audio::class`, you could c
442
470
You can check `extras` property to know if some metadata are available.
0 commit comments