addressing author requested fixes/changes
This commit is contained in:
parent
456d9c6485
commit
8950598211
3 changed files with 6 additions and 2 deletions
|
|
@ -108,6 +108,7 @@ class Audio extends AbstractStreamableMedia
|
|||
*
|
||||
* @param integer $width
|
||||
* @param integer $height
|
||||
* @param array $colors Array of colors for ffmpeg to use. Color format is #000000 (RGB hex string with #)
|
||||
* @return Waveform
|
||||
*/
|
||||
public function waveform($width = 640, $height = 120, $colors = [Waveform::DEFAULT_COLOR])
|
||||
|
|
|
|||
|
|
@ -79,13 +79,14 @@ class Waveform extends AbstractMediaType
|
|||
* example #FFFFFF or #000000. By default the color is set to black. Keep in mind that if you save the waveform
|
||||
* as jpg file, it will appear completely black and to avoid this you can set the waveform color to white (#FFFFFF).
|
||||
* Saving waveforms to png is strongly suggested.
|
||||
*
|
||||
* @param array $colors
|
||||
*/
|
||||
public function setColors(array $colors)
|
||||
{
|
||||
foreach ($colors as $row => $value)
|
||||
{
|
||||
if ($value{0} != '#' || strlen($value) != 7)
|
||||
if (!preg_match_all('/^#(?:[0-9a-fA-F]{6})$/', $value))
|
||||
{
|
||||
//invalid color
|
||||
unset($colors[$row]);
|
||||
|
|
@ -102,6 +103,7 @@ class Waveform extends AbstractMediaType
|
|||
* Returns an array of colors that will be passed to ffmpeg to use for waveform generation. Colors are applied ONLY
|
||||
* to the waveform. Background cannot be controlled that easily and it is probably easier to save the waveform
|
||||
* as a transparent png file and then add background of choice.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getColors()
|
||||
|
|
@ -111,6 +113,7 @@ class Waveform extends AbstractMediaType
|
|||
|
||||
/**
|
||||
* Compiles the selected colors into a string, using a pipe separator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function compileColors()
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class WaveformTest extends AbstractMediaTestCase
|
|||
return array(
|
||||
array(
|
||||
array(
|
||||
'-i', NULL, '-filter_complex',
|
||||
'-y', '-i', NULL, '-filter_complex',
|
||||
'showwavespic=colors=#FFFFFF:s=640x120',
|
||||
'-frames:v', '1',
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue