-
Notifications
You must be signed in to change notification settings - Fork 1
/
subtitle.mdvd.class.php
59 lines (55 loc) · 1.73 KB
/
subtitle.mdvd.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Klsa do obsługi napisów w formacie mDVD
* @author: [email protected]
* @version: $Id: subtitle.mdvd.class.php,v 1.4 2009/11/06 08:16:06 wojtekb Exp $
* Opis formatu mDVD :
http://www.gtw.avx.pl/modules.php?name=Content2&pa=showpage&pid=35
*/
class MdvdSubtitle extends Subtitle{
private $fps = null;
public function __construct($fps = null){
if($fps && is_numeric($fps))
$this->setFps($fps);
}
public function setFps($fps){
$this->fps = floatval($fps);
}
public function getFps(){
return $this->fps;
}
// private $events;
protected function _parse(&$f){
if($this->fps != null)
MTime::setFps($this->fps);
$s = explode("\n",$f);
$xp = "/^\{(\d+)\}\{(\d*)\}(.*)$/";
for($i=0, $l=count($s); $i<$l; $i++){
if(preg_match($xp,$s[$i],$ma))
$this->_addLine(Array('start' => MTime::fromMdvd($ma[1]),
'end' => MTime::fromMdvd($ma[2]),
'text' => MText::fromMdvd($ma[3])));
}
}
public function get(){
ksort($this->events);
if($this->fps != null)
MTime::setFps($this->fps);
foreach($this->events AS $r){
$l[] = sprintf('{%d}{%d}%s', MTime::toMdvd($r['start']),
MTime::toMdvd($r['end']),
MText::toMdvd($r['text']));
}
return join("\n",$l);
}
public function decodeTime($v){
return MTime::fromMdvd($v);
}
public function encodeTime($t){
return MTime::toMdvd($t);
}
public static function getVersion(){
return '$Id: subtitle.mdvd.class.php,v 1.4 2009/11/06 08:16:06 wojtekb Exp $';
}
}
?>