support flv
This commit is contained in:
parent
d699979d35
commit
08deefdcfb
6 changed files with 25 additions and 3 deletions
|
@ -26,6 +26,7 @@ const external_js = [
|
|||
'marked',
|
||||
'mousetrap',
|
||||
'nprogress',
|
||||
'flv.js',
|
||||
'superagent',
|
||||
'underscore',
|
||||
];
|
||||
|
|
|
@ -50,6 +50,20 @@ class PostMainView {
|
|||
postContainerNode.querySelector(".post-overlay"),
|
||||
ctx.post
|
||||
);
|
||||
// suppurt flv play
|
||||
if (ctx.post.mimeType === "video/x-flv") {
|
||||
const flvjs = require("flv.js");
|
||||
if (flvjs.isSupported()) {
|
||||
const video = document.querySelector(".post-content video");
|
||||
const src = video.querySelector("source").src
|
||||
const player = flvjs.createPlayer({
|
||||
type: 'flv',
|
||||
url: src,
|
||||
});
|
||||
player.attachMediaElement(video);
|
||||
player.load();
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.post.type === "video" || ctx.post.type === "flash") {
|
||||
this._postContentControl.disableOverlay();
|
||||
|
|
|
@ -163,7 +163,7 @@ class PostUploadView extends events.EventTarget {
|
|||
this._contentInputNode,
|
||||
{
|
||||
extraText:
|
||||
"Allowed extensions: .jpg, .png, .gif, .webm, .mp4, .swf, .avif, .heif, .heic",
|
||||
"Allowed extensions: .jpg, .png, .gif, .webm, .mp4, .swf, .avif, .heif, .heic, .flv",
|
||||
allowUrls: true,
|
||||
allowMultiple: true,
|
||||
lock: false,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"dompurify": "^2.0.17",
|
||||
"flv.js": "^1.6.2",
|
||||
"font-awesome": "^4.7.0",
|
||||
"ios-inner-height": "^1.0.3",
|
||||
"js-cookie": "^2.2.0",
|
||||
|
|
|
@ -39,6 +39,9 @@ def get_mime_type(content: bytes) -> str:
|
|||
if content[4:12] in (b"ftypisom", b"ftypiso5", b"ftypmp42", b"ftypM4V "):
|
||||
return "video/mp4"
|
||||
|
||||
if content[0:3] == b"FLV":
|
||||
return "video/x-flv"
|
||||
|
||||
return "application/octet-stream"
|
||||
|
||||
|
||||
|
@ -55,14 +58,17 @@ def get_extension(mime_type: str) -> Optional[str]:
|
|||
"image/heic": "heic",
|
||||
"video/mp4": "mp4",
|
||||
"video/webm": "webm",
|
||||
"video/x-flv": "flv",
|
||||
"application/octet-stream": "dat",
|
||||
}
|
||||
return extension_map.get((mime_type or "").strip().lower(), None)
|
||||
|
||||
|
||||
def is_flash(mime_type: str) -> bool:
|
||||
return mime_type.lower() == "application/x-shockwave-flash"
|
||||
|
||||
def is_flv(mime_type: str) -> bool:
|
||||
return mime_type.lower() == "video/x-flv"
|
||||
|
||||
|
||||
def is_video(mime_type: str) -> bool:
|
||||
return mime_type.lower() in ("application/ogg", "video/mp4", "video/webm")
|
||||
|
|
|
@ -619,7 +619,7 @@ def update_post_content(post: model.Post, content: Optional[bytes]) -> None:
|
|||
post.type = model.Post.TYPE_ANIMATION
|
||||
else:
|
||||
post.type = model.Post.TYPE_IMAGE
|
||||
elif mime.is_video(post.mime_type):
|
||||
elif mime.is_video(post.mime_type) or mime.is_flv(post.mime_type):
|
||||
post.type = model.Post.TYPE_VIDEO
|
||||
else:
|
||||
raise InvalidPostContentError(
|
||||
|
|
Reference in a new issue