|
8 | 8 | [![tests][tests-src]][tests-href] |
9 | 9 | [![codecov][codecov-src]][codecov-href] |
10 | 10 |
|
11 | | -PHP package to read audio files with ID3, parser uses [JamesHeinrich/getID3](https://github.com/JamesHeinrich/getID3). |
| 11 | +PHP package to read audio files, parser uses [JamesHeinrich/getID3](https://github.com/JamesHeinrich/getID3). |
12 | 12 |
|
13 | 13 | | Format | Supported | Type | Notes | |
14 | 14 | | :----: | :-------: | :----------------------------------: | :---: | |
@@ -61,77 +61,77 @@ composer require kiwilan/php-audio |
61 | 61 | ```php |
62 | 62 | $audio = Audio::read('path/to/audio.mp3'); |
63 | 63 |
|
64 | | -$audio->path(); // string to get path |
65 | | -$audio->extension(); // string to get extension |
66 | | -$audio->title(); // ?string to get title |
67 | | -$audio->artist(); // ?string to get artist |
68 | | -$audio->album(); // ?string to get album |
69 | | -$audio->genre(); // ?string to get genre |
70 | | -$audio->year(); // ?int to get year |
71 | | -$audio->trackNumber(); // ?string to get track number |
72 | | -$audio->comment(); // ?string to get comment |
73 | | -$audio->albumArtist(); // ?string to get album artist |
74 | | -$audio->composer(); // ?string to get composer |
75 | | -$audio->discNumber(); // ?string to get disc number |
76 | | -$audio->isCompilation(); // bool to know if is compilation |
77 | | -$audio->creationDate(); // ?string to get creation date (audiobook) |
78 | | -$audio->copyright(); // ?string to get copyright (audiobook) |
79 | | -$audio->encoding(); // ?string to get encoding |
80 | | -$audio->description(); // ?string to get description (audiobook) |
81 | | -$audio->lyrics(); // ?string (audiobook) |
82 | | -$audio->stik(); // ?string (audiobook) |
83 | | -$audio->duration(); // ?float to get duration in seconds |
84 | | -$audio->extras(); // array with raw metadata |
85 | | -$audio->hasCover(); // bool to know if has cover |
86 | | -$audio->isValid(); // bool to know if file is valid audio file |
87 | | - |
88 | | -$audio->id3(); // Id3 metadata |
89 | | -$audio->stat(); // FileStat (from `stat` function) |
90 | | -$audio->audio(); // ?AudioMetadata with audio metadata |
91 | | -$audio->cover(); // ?AudioCover with cover metadata |
| 64 | +$audio->path(); // `string` to get path |
| 65 | +$audio->extension(); // `string` to get extension |
| 66 | +$audio->title(); // `?string` to get title |
| 67 | +$audio->artist(); // `?string` to get artist |
| 68 | +$audio->album(); // `?string` to get album |
| 69 | +$audio->genre(); // `?string` to get genre |
| 70 | +$audio->year(); // `?int` to get year |
| 71 | +$audio->trackNumber(); // `?string` to get track number |
| 72 | +$audio->comment(); // `?string` to get comment |
| 73 | +$audio->albumArtist(); // `?string` to get album artist |
| 74 | +$audio->composer(); // `?string` to get composer |
| 75 | +$audio->discNumber(); // `?string` to get disc number |
| 76 | +$audio->isCompilation(); // `bool` to know if is compilation |
| 77 | +$audio->creationDate(); // `?string` to get creation date (audiobook) |
| 78 | +$audio->copyright(); // `?string` to get copyright (audiobook) |
| 79 | +$audio->encoding(); // `?string` to get encoding |
| 80 | +$audio->description(); // `?string` to get description (audiobook) |
| 81 | +$audio->lyrics(); // `?string` (audiobook) |
| 82 | +$audio->stik(); // `?string` (audiobook) |
| 83 | +$audio->duration(); // `?float` to get duration in seconds |
| 84 | +$audio->extras(); // `array` with raw metadata |
| 85 | +$audio->hasCover(); // `bool` to know if has cover |
| 86 | +$audio->isValid(); // `bool` to know if file is valid audio file |
| 87 | + |
| 88 | +$audio->id3(); // `Id3` metadata |
| 89 | +$audio->stat(); // `FileStat` (from `stat` function) |
| 90 | +$audio->audio(); // `?AudioMetadata` with audio metadata |
| 91 | +$audio->cover(); // `?AudioCover` with cover metadata |
92 | 92 | ``` |
93 | 93 |
|
94 | | -## Id3 |
| 94 | +## ID3 |
95 | 95 |
|
96 | 96 | Data from `JamesHeinrich/getID3` package with formatting. |
97 | 97 |
|
98 | 98 | ```php |
99 | 99 | $audio = Audio::read('path/to/audio.mp3'); |
100 | 100 |
|
101 | | -$audio->id3()->raw(); // array with raw metadata |
102 | | -$audio->id3()->item(); // ?Id3Item with item metadata |
103 | | -$audio->id3()->instance(); // getID3 instance |
| 101 | +$audio->id3()->raw(); // `array` with raw metadata |
| 102 | +$audio->id3()->item(); // `?Id3Item` with item metadata |
| 103 | +$audio->id3()->instance(); // `getID3` instance |
104 | 104 | ``` |
105 | 105 |
|
106 | 106 | ## AudioMetadata |
107 | 107 |
|
108 | 108 | ```php |
109 | 109 | $audio = Audio::read('path/to/audio.mp3'); |
110 | 110 |
|
111 | | -$audio->audio()->filesize(); // ?int in bytes |
112 | | -$audio->audio()->extension(); // ?string (mp3, m4a, ...) |
113 | | -$audio->audio()->encoding(); // ?string (UTF-8...) |
114 | | -$audio->audio()->mimeType(); // ?string (audio/mpeg, audio/mp4, ...) |
115 | | -$audio->audio()->durationSeconds(); // ?float in seconds |
116 | | -$audio->audio()->durationReadable(); // ?string (00:00:00) |
117 | | -$audio->audio()->bitrate(); // ?int in kbps |
118 | | -$audio->audio()->bitrateMode(); // ?string (cbr, vbr, ...) |
119 | | -$audio->audio()->sampleRate(); // ?int in Hz |
120 | | -$audio->audio()->channels(); // ?int (1, 2, ...) |
121 | | -$audio->audio()->channelMode(); // ?string (mono, stereo, ...) |
122 | | -$audio->audio()->lossless(); // bool to know if is lossless |
123 | | -$audio->audio()->compressionRatio(); // ?float |
| 111 | +$audio->audio()->filesize(); // `?int` in bytes |
| 112 | +$audio->audio()->extension(); // `?string` (mp3, m4a, ...) |
| 113 | +$audio->audio()->encoding(); // `?string` (UTF-8...) |
| 114 | +$audio->audio()->mimeType(); // `?string` (audio/mpeg, audio/mp4, ...) |
| 115 | +$audio->audio()->durationSeconds(); // `?float` in seconds |
| 116 | +$audio->audio()->durationReadable(); // `?string` (00:00:00) |
| 117 | +$audio->audio()->bitrate(); // `?int` in kbps |
| 118 | +$audio->audio()->bitrateMode(); // `?string` (cbr, vbr, ...) |
| 119 | +$audio->audio()->sampleRate(); // `?int` in Hz |
| 120 | +$audio->audio()->channels(); // `?int` (1, 2, ...) |
| 121 | +$audio->audio()->channelMode(); // `?string` (mono, stereo, ...) |
| 122 | +$audio->audio()->lossless(); // `bool` to know if is lossless |
| 123 | +$audio->audio()->compressionRatio(); // `?float` |
124 | 124 | ``` |
125 | 125 |
|
126 | 126 | ## AudioCover |
127 | 127 |
|
128 | 128 | ```php |
129 | 129 | $audio = Audio::read('path/to/audio.mp3'); |
130 | 130 |
|
131 | | -$audio->cover()->content(); // ?string raw file |
132 | | -$audio->cover()->mimeType(); // ?string (image/jpeg, image/png, ...) |
133 | | -$audio->cover()->width(); // ?int in pixels |
134 | | -$audio->cover()->height(); // ?int in pixels |
| 131 | +$audio->cover()->content(); // `?string` raw file |
| 132 | +$audio->cover()->mimeType(); // `?string` (image/jpeg, image/png, ...) |
| 133 | +$audio->cover()->width(); // `?int` in pixels |
| 134 | +$audio->cover()->height(); // `?int` in pixels |
135 | 135 | ``` |
136 | 136 |
|
137 | 137 | ## Testing |
|
0 commit comments