+++ /dev/null
-<?php\r
-/**\r
- * JSONcc Class\r
- */\r
-class JSONcc extends CaptionFormat\r
-{\r
- /**\r
- * Imports a caption string into a CaptionCollection \r
- *\r
- * @param String $theCCString the caption file as string\r
- * @return CaptionCollection $myCcCollection A CaptionCollection Object\r
- */\r
- public function importCC($theJsonString)\r
- { \r
- $theCcArray = json_decode($theJsonString,true);\r
- \r
- // Create a Caption Collection Object\r
- $theCollection = new CaptionCollection();\r
- \r
- // set all global text styles using JSON-decoded array ???????\r
- $theCollection->setTxtStylesGlobal($theCcArray['global_caption_styles']);\r
-\r
- // check if there are captions in the captionCollection array and then add them to the Collection\r
- if (count($theCcArray['clip_collection']['clips'])!=0 )\r
- { \r
- foreach ($theCcArray['clip_collection']['clips'] as $CapArray)\r
- {\r
- // create a Caption Object\r
- $newCaptionObj = new Caption($CapArray['inTime'],$CapArray['outTime'],$CapArray['caption_text'],$CapArray['caption_styles']);\r
- \r
- // add caption object to the CaptionCollection \r
- $theCollection->addCaption($newCaptionObj);\r
- } // end foreach \r
- }// end if\r
- \r
- return $theCollection; \r
- \r
- } // end importCC()\r
- \r
- \r
- /**\r
- * Exports a CaptionCollection object into a string\r
- *\r
- * @param CaptionCollection $theCollection A CaptionCollection Object\r
- * @return String $captionString The caption as a String\r
- */\r
- public function exportCC($theCollection)\r
- {\r
- $ccExport = '';\r
- \r
- // Use php built-in json encoder\r
- $ccExport = json_encode($theCollection);\r
-\r
- return $ccExport;\r
- \r
- } // end exportCC()\r
- \r
- /**\r
- * Verify if the caption file is a JSON caption file \r
- */\r
- public function checkFormat($theCCString)\r
- {\r
- \r
- } // end checkFormat()\r
-\r
- /*\r
- * Here functions to re-define\r
- */\r
- public function getName()\r
- {\r
- return 'JSON';\r
- }\r
- \r
- public function getAbout()\r
- {\r
- 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
- }\r
- \r
- public function getVersion()\r
- {\r
- return '1.0';\r
- }\r
- \r
- public function getFileExtension()\r
- {\r
- return 'JSON';\r
- }\r
- \r
- public function getIdPattern()\r
- {\r
- //$idPattern = '/(.*)/'; // match any pattern\r
- $idPattern = '/"clips":\[/'; \r
- \r
- \r
- return $idPattern;\r
- }\r
-\r
- public function allowsTextStyles()\r
- {\r
- return '1';\r
- }\r
- \r
- public function template()\r
- {\r
- $ccTemplate = '';\r
- \r
- return $ccTemplate;\r
- }\r
-\r
- \r
- \r
-} // end CCJSON Class\r
-?>
\ No newline at end of file