Browse Source

add mp3 support

master
filesite 2 months ago
parent
commit
452d502179
  1. 2
      conf/app.php
  2. 14
      plugins/Html.php
  3. 9
      themes/beauty/controller/SiteController.php
  4. 2
      themes/beauty/views/site/player.php
  5. 2
      www/girls/README.md

2
conf/app.php

@ -54,6 +54,8 @@ $configs = array(
'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif', 'svg'), 'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif', 'svg'),
'supportedVideoExts' => array('mp4', 'mov', 'm3u8'), 'supportedVideoExts' => array('mp4', 'mov', 'm3u8'),
'supportedAudioExts' => array('mp3'),
'screenshot_start' => 1000, //视频播放页快照截取开始时间,单位:毫秒 'screenshot_start' => 1000, //视频播放页快照截取开始时间,单位:毫秒
'screenshot_expire_seconds' => 315360000, //视频封面图缓存3650天 'screenshot_expire_seconds' => 315360000, //视频封面图缓存3650天
'small_image_zoom_rate' => 2.5, //缩略图在最小尺寸基础上的放大倍数,以确保清晰度 'small_image_zoom_rate' => 2.5, //缩略图在最小尺寸基础上的放大倍数,以确保清晰度

14
plugins/Html.php

@ -277,4 +277,18 @@ eof;
return $html; return $html;
} }
public static function getMediaSourceType($fileExtension) {
$sourceType = 'video/mp4';
if ($fileExtension == 'mov') {
$sourceType = 'video/mp4';
}else if ($fileExtension == 'm3u8') {
$sourceType = 'application/x-mpegURL';
}else if ($fileExtension == 'mp3') {
$sourceType = 'audio/mp3';
}
return $sourceType;
}
} }

9
themes/beauty/controller/SiteController.php

@ -5,6 +5,7 @@
require_once __DIR__ . '/../../../lib/DirScanner.php'; require_once __DIR__ . '/../../../lib/DirScanner.php';
require_once __DIR__ . '/../../../plugins/Parsedown.php'; require_once __DIR__ . '/../../../plugins/Parsedown.php';
require_once __DIR__ . '/../../../plugins/Common.php'; require_once __DIR__ . '/../../../plugins/Common.php';
require_once __DIR__ . '/../../../plugins/Html.php';
Class SiteController extends Controller { Class SiteController extends Controller {
@ -560,6 +561,8 @@ Class SiteController extends Controller {
return $this->renderJson(compact('code', 'msg')); return $this->renderJson(compact('code', 'msg'));
} }
//TODO: 增加mp3播放器,以及mp3时长获取
public function actionPlayer() { public function actionPlayer() {
$videoUrl = $this->get('url', ''); $videoUrl = $this->get('url', '');
$videoId = $this->get('id', ''); $videoId = $this->get('id', '');
@ -576,6 +579,10 @@ Class SiteController extends Controller {
$arr = parse_url($videoUrl); $arr = parse_url($videoUrl);
$videoFilename = basename($arr['path']); $videoFilename = basename($arr['path']);
//增加文件后缀格式检查,区分:mp4, mov, m3u8
$videoExtension = pathinfo($arr['path'], PATHINFO_EXTENSION);
$videoSourceType = Html::getMediaSourceType($videoExtension);
//获取联系方式 //获取联系方式
$maxScanDeep = 0; //最大扫描目录级数 $maxScanDeep = 0; //最大扫描目录级数
@ -596,7 +603,7 @@ Class SiteController extends Controller {
$params = compact( $params = compact(
'videoUrl', 'videoId', 'videoFilename', 'videoUrl', 'videoId', 'videoFilename',
'cateId', 'cacheParentDataId', 'page', 'pageSize', 'cateId', 'cacheParentDataId', 'page', 'pageSize',
'copyright', 'isAdminIp' 'copyright', 'isAdminIp', 'videoExtension', 'videoSourceType'
); );
return $this->render($viewName, $params, $pageTitle); return $this->render($viewName, $params, $pageTitle);
} }

2
themes/beauty/views/site/player.php

@ -38,7 +38,7 @@
playsinline playsinline
poster="" poster=""
id="my-player"> id="my-player">
<source src="<?php echo $viewData['videoUrl']; ?>" type="video/mp4"> <source src="<?php echo $viewData['videoUrl']; ?>" type="<?php echo $viewData['videoSourceType']; ?>">
</video> </video>
<div class="text-right mt-2 mr-1"> <div class="text-right mt-2 mr-1">
<?php if (!empty($viewData['isAdminIp'])) { ?> <?php if (!empty($viewData['isAdminIp'])) { ?>

2
www/girls/README.md

@ -1,6 +1,6 @@
# 家庭相册 # 家庭相册
Machete是一款简单易用的家庭相册系统,可方便更新升级、支持Docker安装。 Filesite/Machete是一款简单易用的家庭相册系统,可方便更新升级、支持Docker安装。
## 使用场景 ## 使用场景

Loading…
Cancel
Save