Change "video/mpeg4-generic" to "video/mp4", fix video tag BT#14372

Remove filename when using "inline" not needed

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
pull/2606/head
Julio Montoya 7 years ago
parent 6509cc5032
commit 673dd3d346
  1. 1
      main/document/download.php
  2. 26
      main/inc/lib/document.lib.php

@ -103,6 +103,7 @@ if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) {
// Launch event
Event::event_download($doc_url);
$download = !empty($_GET['dl']) ? true : false;
$result = DocumentManager::file_send_for_download($fullFileName, $download);
if ($result === false) {
api_not_allowed(true);

@ -139,7 +139,7 @@ class DocumentManager
'movie' => 'video/x-sgi-movie',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'mp4' => 'video/mpeg4-generic',
'mp4' => 'video/mp4',
'mpa' => 'audio/mpeg',
'mpe' => 'video/mpeg',
'mpeg' => 'video/mpeg',
@ -258,12 +258,12 @@ class DocumentManager
return $mime_types;
}
//get the extension of the file
// Get the extension of the file
$extension = explode('.', $filename);
//$filename will be an array if a . was found
// $filename will be an array if a . was found
if (is_array($extension)) {
$extension = strtolower($extension[sizeof($extension) - 1]);
$extension = strtolower($extension[count($extension) - 1]);
} else {
//file without extension
$extension = 'empty';
@ -273,6 +273,7 @@ class DocumentManager
if (isset($mime_types[$extension])) {
return $mime_types[$extension];
}
//else return octet-stream
return 'application/octet-stream';
}
@ -349,7 +350,9 @@ class DocumentManager
// Commented to avoid double caching declaration when playing with IE and HTTPS
//header('Cache-Control: no-cache, must-revalidate');
//header('Pragma: no-cache');
$contentType = self::file_get_mime_type($filename);
switch ($contentType) {
case 'text/html':
if (isset($lpFixedEncoding) && $lpFixedEncoding === 'true') {
@ -379,11 +382,13 @@ class DocumentManager
header('Content-type: '.$contentType);
header('Content-Length: '.$len);
$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($user_agent, 'msie')) {
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($userAgent, 'msie')) {
header('Content-Disposition: ; filename= '.$filename);
} else {
header('Content-Disposition: inline; filename= '.$filename);
//header('Content-Disposition: inline');
header('Content-Disposition: inline;');
}
if ($fixLinksHttpToHttps) {
@ -3132,7 +3137,12 @@ class DocumentManager
}*/
//$type = "video/$extension";
$html = '<video id="myvideo" src="'.$file.'" controls '.$type.'">';
//$fileInfo = parse_url($file);
//$type = self::file_get_mime_type(basename($fileInfo['path']));
$html = '<video id="myvideo" controls>';
$html .= '<source src="'.$file.'" >';
$html .= '</video>';
return $html;
}

Loading…
Cancel
Save