Commit ba906614 by Рамис

fix refresh optimized video

parent d7d8cbd7
import React from 'react'
import React, { useEffect } from 'react'
import QEditor from 'react-ag-qeditor'
import 'react-ag-qeditor/dist/index.css'
......
......@@ -27,7 +27,7 @@ export default class QEditor extends React.Component {
}
Quill.register('formats/video', VideoBlot)
// Quill.register('formats/videoLocal', VideoLocalBlot)
Quill.register('formats/videoLocal', VideoLocalBlot)
Quill.register('modules/blotFormatter', BlotFormatter)
Quill.register('formats/image', ImageBlot)
}
......@@ -36,6 +36,20 @@ export default class QEditor extends React.Component {
this.setState({
init: true
});
if(window.checkOptimizeVideo === undefined){
window.checkOptimizeVideo = setInterval(()=>{
const children = [...document.getElementsByTagName('video')];
if(children.length > 0){
children.forEach((video, i) => {
if(video.duration === 2.48){
video.setAttribute('src', video.getAttribute('src') + `?${Date.now()/1000}`)
}
})
}
}, 3000);
}
}
modules = {
......@@ -50,7 +64,7 @@ export default class QEditor extends React.Component {
{indent: '+1'}
],
[{align: []}, {color: []}, {background: []}],
['link', 'image', 'video'/* , 'videoLocal' */],
['link', 'image', 'video', 'videoLocal'],
['formula'],
['clean']
],
......@@ -69,7 +83,7 @@ export default class QEditor extends React.Component {
() => this.editorModal.show({title: 'Видео по ссылке'})
)
},
/* videoLocal: (a) => {
videoLocal: (a) => {
const quill = this.quillRef.getEditor();
let range = quill.getSelection();
let index = range ? range.index : 0;
......@@ -79,7 +93,7 @@ export default class QEditor extends React.Component {
innerModalType: 'videoLocal',
focusedIndex: index
}, () => this.editorModal.show({title: 'Загрузить видео'}));
}, */
},
image: (a) => {
const quill = this.quillRef.getEditor();
let range = quill.getSelection();
......@@ -102,7 +116,7 @@ export default class QEditor extends React.Component {
'bold', 'italic', 'underline', 'strike', 'blockquote',
'list', 'bullet', 'indent',
'align',
'link', 'image', 'video', 'color', 'background', /* 'videoLocal', */
'link', 'image', 'video', 'color', 'background', 'videoLocal',
'formula',
]
......@@ -208,6 +222,7 @@ export default class QEditor extends React.Component {
this.setState({
uploaderUid: `uid${new Date()}`,
embedContent: '',
uplodedPaths: [],
focusedIndex: 0
}, () => this.editorModal.hide());
}
......
......@@ -16,6 +16,9 @@ export default class VideoLocalBlot extends BlockEmbed {
// node.setAttribute('loop', true);
node.setAttribute('src', value);
node.setAttribute('controls', true);
node.setAttribute('disabled', true);
node.setAttribute('poster', value + '.jpg');
return node;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment