Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50ea1e4
commit e9df2e5
Showing
6 changed files
with
181 additions
and
54 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
TL_ROOT/system/modules/backboneit_multimedia/AbstractMultimediaVideoSource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
class AbstractMultimediaVideoSource implements MultimediaVideoSource { | ||
|
||
private $strType; | ||
|
||
private $strURL; | ||
|
||
protected function __construct($strURL, $strType) { | ||
$this->strURL = $strURL; | ||
$this->strType = $strType; | ||
} | ||
|
||
public function serialize() { | ||
return serialize(array( | ||
$this->strType, | ||
$this->strURL, | ||
)); | ||
} | ||
|
||
public function unserialize($strSerialized) { | ||
list( | ||
$this->strType, | ||
$this->strURL, | ||
) = unserialize($strSerialized); | ||
} | ||
|
||
public function getType() { | ||
return $this->strType; | ||
} | ||
|
||
public function getURL() { | ||
return $this->strURL; | ||
} | ||
|
||
public function isValid() { | ||
try { | ||
$this->validate(); | ||
return true; | ||
} catch(Exception $e) { | ||
return false; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
TL_ROOT/system/modules/backboneit_multimedia/MultimediaVideoHTTPSource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
class MultimediaVideoHTTPSource implements AbstractMultimediaVideoSource { | ||
|
||
private static $arrMIMEs = array( | ||
'application/ogg' => true, | ||
'video/ogg' => true, | ||
'video/webm' => true, | ||
'video/mp4' => true, | ||
'video/x-flv' => true, | ||
); | ||
|
||
private $strMIME; | ||
|
||
public function __construct($strURL, $strType = 'http') { | ||
parent::__construct($strURL, $strType); | ||
} | ||
|
||
public function serialize() { | ||
return serialize(array( | ||
parent::serialize(), | ||
$this->strMIME, | ||
)); | ||
} | ||
|
||
public function unserialize($strSerialized) { | ||
list( | ||
$strParent, | ||
$this->strMIME, | ||
) = unserialize($strSerialized); | ||
parent::unserialize($strParent); | ||
} | ||
|
||
public function validate() { | ||
if(!isset(self::$arrMIMEs[$this->getMIME()])) { | ||
throw new Exception(sprintf('[%s] does not respond with a valid internet video MIME', $this->getURL())); | ||
} | ||
} | ||
|
||
public function getMIME() { | ||
return $this->strMIME ? $this->strMIME : $this->strMIME = $this->fetchMIME(); | ||
} | ||
|
||
protected function fetchMIME() { | ||
// $objReq = new RequestExtendedCached(60 * 60); // bugged see #2991 | ||
$objReq = new RequestExtended(); | ||
$objReq->send($this->getURL(), false, 'HEAD'); | ||
|
||
if($objReq->hasError()) { | ||
throw new Exception(sprintf('Source request responded with error: [%s]', $objReq->error), $objReq->code); | ||
} | ||
|
||
list($strMIME) = explode(';', $objReq->headers['Content-Type'], 2); | ||
return $strMIME ? $strMIME : 'application/octet-stream'; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
TL_ROOT/system/modules/backboneit_multimedia/MultimediaVideoLocalSource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
class MultimediaVideoLocalSource implements MultimediaVideoHTTPSource { | ||
|
||
public function __construct($strURL) { | ||
parent::__construct($strURL, 'local'); | ||
} | ||
|
||
public function getURL() { | ||
return Environment::getInstance()->base . parent::getURL(); | ||
} | ||
|
||
public function getLocalPath() { | ||
return parent::getURL(); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
TL_ROOT/system/modules/backboneit_multimedia/MultimediaVideoSource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
interface MultimediaVideoSource extends Serializable { | ||
|
||
public function getType(); | ||
|
||
public function getURL(); | ||
|
||
public function isValid(); | ||
|
||
public function validate(); | ||
|
||
} |