저는 VideoStream 클래스를 사용하고 있습니다. 매우 잘 동작합니다. 나는 Page_Controller
안에 그것을 통합하고 비디오가 업로드되는 것을 보호하려고합니다. 따라서 페이지가로드 될 때마다 비디오 링크는 항상 다시로드 할 때 변경되며 아무도 브라우저 URL에서 직접 다운로드 할 수 없습니다.SilverStripe의 PHP VideoStream 클래스
하지만 수업은 효과가없는 것 같아서 내가 무엇을 놓쳤는 지 모릅니다. 또한 ChunkedUpload 모듈을 사용하여 대용량 파일을 CMS에 업로드합니다.
그 아이디어는 어떻게 사용합니까?
여기 내 코드입니다. 여기에 내 코드는 아래에 내가 한 메모를 작동 "내 원래 ..."
PageVideo.ss
<video controls preload="auto" id="video1">
<% if $VideoMP4 %><source src="id/$Video($VideoMP4.ID)" type="video/mp4"><% end_if %>
Your browser does not support HTML5 video.
</video>
PageVideo.php
class PageVideo extends Page {
private static $has_one = array(
'VideoMP4' => 'File'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab(
'Root.Main ',
$uploadField = new ChunkedUploadField(
$name = 'VideoMP4',
$title = "VideoMP4"
)
);
$uploadField->setFolderName('Uploads/videos/');
$uploadField->setDisplayFolderName('Uploads/videos');
$uploadField->getValidator()->allowedExtensions = array("mp4");
$sizeMB = 500 * 1024 * 1024; // 500 MB in bytes
$uploadField->getValidator()->setAllowedMaxFileSize($sizeMB);
$uploadField->setConfig('maxChunkSize', .05 * 1024 * 1024);
return $fields;
}
}
class PageVideo_Controller extends Page_Controller {
private static $allowed_actions = array('VideoGrab');
private static $url_handlers = array('id/$hash' => 'VideoGrab');
public function VideoGrab(SS_HTTPRequest $request) {
$hash = $request->param('hash');
$file = File::get()->filter('ID', $_SESSION['keyID'])->first();
if (md5($file->Name . $_SESSION['key']) == $hash) {
$_SESSION['key'] = "";
$_SESSION['keyID'] = "";
//**************** HERE IS THE CLASS *********************
include "libraries/VideoStream.php";
$stream = new VideoStream($file->AbsoluteURL);
$stream->start();
exit;
// the original php working just for some browsing and bad codes
/*
$ext = pathinfo($file->Filename);
header('Cache-control: private');
header('Content-Type: video/' . $ext['extension']);
header('Accept-Ranges: bytes');
header("Content-Transfer-Encoding: binary");
return readfile($file->AbsoluteURL);
exit;
*/
} else {
return $this->httpError(404, "Not Found");
}
}
public function Video($n) {
$file = File::get()->filter('ID', $n)->First();
$_SESSION['key'] = time();
$_SESSION['keyID'] = $file->ID;
return md5($file->Name . $_SESSION['key']);
}
}
결과 페이지 (비디오 부분)의 소스 코드는 무엇입니까? src = ""속성에 예상 값이 입니까? –
비디오 소스 VideoMP4는 페이지 모델에 has_one 배열로 유지됩니다. 실버 스트라이프에 대한 경험이 있습니까? – StefGuev
@ 3dgoo, 제 영어와 코드를 청소 해 주셔서 감사합니다! 대답 있어요? 당신은 실버 스트라이프 코딩 전문가로 보인다. – StefGuev