예제 #1
0
 public function render($caption_set, $file = false)
 {
     $captions = array();
     foreach ($caption_set->captions() as $index => $caption) {
         $captions[] = sprintf("%d\n%s --> %s\n%s", $index + 1, SrtHelper::time_to_string($caption->start()), SrtHelper::time_to_string($caption->end()), $caption->text());
     }
     $string = implode("\n\n", $captions);
     if ($file) {
         return file_put_contents($file, $string);
     } else {
         return $string;
     }
 }
예제 #2
0
 public function test_time_to_string()
 {
     $this->assertSame(SrtHelper::time_to_string(3600 + 120 + 3 + 0.456), '01:02:03,456');
 }