新增FFmpeg转码功能
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
<script type="text/html" id="listTools">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="play">播放</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="download">下载</a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="ffmpeg">转码</a>
|
||||
</script>
|
||||
<script src="/layui/layui.js"></script>
|
||||
<script src="/js/jquery-3.2.1.js"></script>
|
||||
@@ -47,9 +48,9 @@
|
||||
{field: 'name', title: 'UP主/房间号', width: 150, sort: true, fixed: 'left'}
|
||||
, {field: 'date', title: '日期', width: 120, sort: true}
|
||||
, {field: 'time', title: '时间', width: 80, sort: true}
|
||||
, {field: 'fileName', title: '文件名', width: 300}
|
||||
, {field: 'fileName', title: '文件名', width: 250}
|
||||
, {field: 'fileSize', title: '大小', width: 80}
|
||||
, {field: "right", width: 120, toolbar: '#listTools'}
|
||||
, {field: "right", width: 170, toolbar: '#listTools'}
|
||||
]]
|
||||
});
|
||||
table.on('tool(listTools)', function (obj) {
|
||||
@@ -61,6 +62,15 @@
|
||||
case 'play':
|
||||
play("/download/" + obj.data.date + "/" + encodeURI(obj.data.fileName), obj.data.fileName);
|
||||
break;
|
||||
case 'ffmpeg':
|
||||
$.post('/bili/video/set/ffmpeg.do',{fileName:encodeURI(obj.data.fileName)},function (json) {
|
||||
if (json.code === undefined || json.code !== 0) {
|
||||
layer.msg("您无权操作")
|
||||
return;
|
||||
}
|
||||
layer.msg(json.msg)
|
||||
})
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -79,20 +89,18 @@
|
||||
, area: ['640px', '480px']
|
||||
, maxmin: false
|
||||
, resize: false
|
||||
, content: '<div><video id="' + id + '" style="height: 100%;width: 100%">' +
|
||||
'</video><a href="javascript:;" class="layui-btn layui-btn-xs" id="pause">暂停/播放</a>' +
|
||||
, content: '<div><video id="' + id + '" style="height: 100%;width: 100%" controls>' +
|
||||
'</video><a href="javascript:;" class="layui-btn layui-btn-xs" id="reset">重播</a>' +
|
||||
'</video><a href="javascript:;" class="layui-btn layui-btn-xs" id="danmu">弹幕</a>' +
|
||||
'</video><a href="javascript:;" class="layui-btn layui-btn-xs" id="volume">静音</a>' +
|
||||
'</video><a href="javascript:;" class="layui-btn layui-btn-xs" id="seekDown">-10s</a>' +
|
||||
'</video><a href="javascript:;" class="layui-btn layui-btn-xs" id="seekUp">+10s</a>' +
|
||||
'<a href="javascript:;" class="layui-btn layui-btn-xs" id="danmu">弹幕</a>' +
|
||||
'<a href="javascript:;" class="layui-btn layui-btn-xs" id="seekDown">-10s</a>' +
|
||||
'<a href="javascript:;" class="layui-btn layui-btn-xs" id="seekUp">+10s</a>' +
|
||||
'</div>'
|
||||
, success: function (layero, index) {
|
||||
|
||||
layer.setTop(layero);
|
||||
let videoElement = document.getElementById(id);
|
||||
videoElement.onended=function (){
|
||||
layer.close(index)
|
||||
videoElement.onended = function () {
|
||||
layer.close(index)
|
||||
};
|
||||
let playerConfig = {
|
||||
enableWorker: false,
|
||||
@@ -100,10 +108,14 @@
|
||||
stashInitialSize: 512 * 1024,
|
||||
enableStashBuffer: true
|
||||
}
|
||||
let playType = 'flv'
|
||||
if (url.indexOf('_ffmpeg') !== -1) {
|
||||
playType = 'mp4'
|
||||
}
|
||||
flvPlayer = flvjs.createPlayer({
|
||||
type: 'flv',
|
||||
type: playType,
|
||||
url: url
|
||||
},playerConfig)
|
||||
}, playerConfig)
|
||||
|
||||
flvPlayer.attachMediaElement(videoElement);
|
||||
flvPlayer.load();
|
||||
@@ -114,7 +126,7 @@
|
||||
} else {
|
||||
flvPlayer.play();
|
||||
}
|
||||
isPlay=!isPlay;
|
||||
isPlay = !isPlay;
|
||||
})
|
||||
$('#reset').click(function () {
|
||||
flvPlayer.unload();
|
||||
|
||||
Reference in New Issue
Block a user