/** * Test Duration in seconds * * @dataProvider secondsProvider * * @param string $filename The filename * @param integer $expectedDuration Number in seconds of total duration */ public function testFileDurationSeconds($filename, $expectedDurationSeconds) { $file = new File($filename); $this->assertSame($expectedDurationSeconds, $file->getDuration()->getSeconds()); }
<?php require 'vendor/autoload.php'; require_once 'config.php'; use RadiorecorderApi\File; use RadiorecorderApi\Duration\SimpleFormatter as DurationFormatter; use RadiorecorderApi\Size\HumanReadableFormatter as SizeFormatter; $files = glob('/home/abez/recordings/' . $radiostation_path . '/*'); sort($files); $recordings = []; foreach ($files as $path) { $file = new File($path); $recording = ['size' => $file->getSize()->format(new SizeFormatter()), 'date_time' => $file->getDate()->format('d.m.Y'), 'done' => true, 'filename' => $path, 'duration' => $file->getDuration()->format(new DurationFormatter())]; $recordings[] = $recording; } echo json_encode($recordings);