支持flv视频预览
parent
3f40b60c64
commit
41d9015023
|
@ -1,5 +1,6 @@
|
|||
package cn.keking.service.impl;
|
||||
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.service.FilePreview;
|
||||
import cn.keking.utils.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -20,6 +21,11 @@ public class MediaFilePreviewImpl implements FilePreview {
|
|||
@Override
|
||||
public String filePreviewHandle(String url, Model model) {
|
||||
model.addAttribute("mediaUrl", url);
|
||||
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
|
||||
String suffix=fileAttribute.getSuffix();
|
||||
if ("flv".equalsIgnoreCase(suffix)) {
|
||||
return "flv";
|
||||
}
|
||||
return "media";
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>多媒体文件预览</title>
|
||||
</head>
|
||||
<style>
|
||||
body{background-color: #262626}
|
||||
.m{ margin-left: auto; margin-right: auto; width:1024px; margin-top: 100px; }
|
||||
</style>
|
||||
<body>
|
||||
<div class="m">
|
||||
<video width="1024" id="videoElement"></video>
|
||||
</div>
|
||||
<script src="js/flv.min.js"></script>
|
||||
<script>
|
||||
if (flvjs.isSupported()) {
|
||||
var videoElement = document.getElementById('videoElement');
|
||||
var flvPlayer = flvjs.createPlayer({
|
||||
type: 'flv',
|
||||
url: '${mediaUrl}'
|
||||
});
|
||||
flvPlayer.attachMediaElement(videoElement);
|
||||
flvPlayer.load();
|
||||
flvPlayer.play();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue