5 class JSONcc extends CaptionFormat
\r
8 * Imports a caption string into a CaptionCollection
\r
10 * @param String $theCCString the caption file as string
\r
11 * @return CaptionCollection $myCcCollection A CaptionCollection Object
\r
13 public function importCC($theJsonString)
\r
15 $theCcArray = json_decode($theJsonString,true);
\r
17 // Create a Caption Collection Object
\r
18 $theCollection = new CaptionCollection();
\r
20 // set all global text styles using JSON-decoded array ???????
\r
21 $theCollection->setTxtStylesGlobal($theCcArray['global_caption_styles']);
\r
23 // check if there are captions in the captionCollection array and then add them to the Collection
\r
24 if (count($theCcArray['clip_collection']['clips'])!=0 )
\r
26 foreach ($theCcArray['clip_collection']['clips'] as $CapArray)
\r
28 // create a Caption Object
\r
29 $newCaptionObj = new Caption($CapArray['inTime'],$CapArray['outTime'],$CapArray['caption_text'],$CapArray['caption_styles']);
\r
31 // add caption object to the CaptionCollection
\r
32 $theCollection->addCaption($newCaptionObj);
\r
36 return $theCollection;
\r
42 * Exports a CaptionCollection object into a string
\r
44 * @param CaptionCollection $theCollection A CaptionCollection Object
\r
45 * @return String $captionString The caption as a String
\r
47 public function exportCC($theCollection)
\r
51 // Use php built-in json encoder
\r
52 $ccExport = json_encode($theCollection);
\r
59 * Verify if the caption file is a JSON caption file
\r
61 public function checkFormat($theCCString)
\r
64 } // end checkFormat()
\r
67 * Here functions to re-define
\r
69 public function getName()
\r
74 public function getAbout()
\r
76 return 'JSON is a data representation model + much more. Captions can be played on any browser/OS using JavaScrinpt. However, plaing the video/audio binary files will require additional plugins such as QuickTime, Windows Media Player, etc... in order to load in a browser ';
\r
79 public function getVersion()
\r
84 public function getFileExtension()
\r
89 public function getIdPattern()
\r
91 //$idPattern = '/(.*)/'; // match any pattern
\r
92 $idPattern = '/"clips":\[/';
\r
98 public function allowsTextStyles()
\r
103 public function template()
\r
107 return $ccTemplate;
\r
112 } // end CCJSON Class
\r