2019-03-01 11:58:27 +08:00
|
|
|
import React from 'react';
|
2025-02-14 14:04:25 +08:00
|
|
|
import { createRoot } from 'react-dom/client';
|
2019-03-29 15:30:44 +08:00
|
|
|
import SharedFileView from './components/shared-file-view/shared-file-view';
|
|
|
|
import SharedFileViewTip from './components/shared-file-view/shared-file-view-tip';
|
2019-03-01 11:58:27 +08:00
|
|
|
import VideoPlayer from './components/video-player';
|
2024-09-19 11:12:10 +08:00
|
|
|
import { MimetypesKind } from './utils/constants';
|
2019-03-01 11:58:27 +08:00
|
|
|
|
|
|
|
import './css/video-file-view.css';
|
|
|
|
|
2024-09-19 11:12:10 +08:00
|
|
|
const { rawPath, err, fileExt } = window.shared.pageOptions;
|
2019-03-01 11:58:27 +08:00
|
|
|
|
2019-03-29 15:30:44 +08:00
|
|
|
class SharedFileViewImage extends React.Component {
|
|
|
|
render() {
|
|
|
|
return <SharedFileView content={<FileContent />} />;
|
2019-03-01 11:58:27 +08:00
|
|
|
}
|
2019-03-29 15:30:44 +08:00
|
|
|
}
|
2019-03-01 11:58:27 +08:00
|
|
|
|
2019-03-29 15:30:44 +08:00
|
|
|
class FileContent extends React.Component {
|
|
|
|
render() {
|
2019-03-01 11:58:27 +08:00
|
|
|
if (err) {
|
2019-03-29 15:30:44 +08:00
|
|
|
return <SharedFileViewTip />;
|
2019-03-01 11:58:27 +08:00
|
|
|
}
|
2019-03-29 15:30:44 +08:00
|
|
|
const videoJsOptions = {
|
|
|
|
autoplay: false,
|
|
|
|
controls: true,
|
|
|
|
preload: 'auto',
|
2023-02-04 21:14:17 +08:00
|
|
|
playbackRates: [0.5, 1, 1.5, 2],
|
2019-03-29 15:30:44 +08:00
|
|
|
sources: [{
|
2024-09-19 11:12:10 +08:00
|
|
|
src: rawPath,
|
|
|
|
type: MimetypesKind[fileExt] || 'video/mp4'
|
2019-03-29 15:30:44 +08:00
|
|
|
}]
|
|
|
|
};
|
2019-03-01 11:58:27 +08:00
|
|
|
return (
|
2019-03-29 15:30:44 +08:00
|
|
|
<div className="shared-file-view-body d-flex">
|
|
|
|
<div className="flex-1">
|
|
|
|
<VideoPlayer { ...videoJsOptions } />
|
2019-03-01 11:58:27 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-14 14:04:25 +08:00
|
|
|
const root = createRoot(document.getElementById('wrapper'));
|
|
|
|
root.render(<SharedFileViewImage />);
|