Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Wire up file preview for video files #8140

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions src/components/views/dialogs/UploadConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ interface IProps {

@replaceableComponent("views.dialogs.UploadConfirmDialog")
export default class UploadConfirmDialog extends React.Component<IProps> {
private objectUrl: string;
private mimeType: string;
private readonly objectUrl: string;
private readonly mimeType: string;

static defaultProps = {
totalFiles: 1,
Expand Down Expand Up @@ -69,7 +69,7 @@ export default class UploadConfirmDialog extends React.Component<IProps> {
};

render() {
let title;
let title: string;
if (this.props.totalFiles > 1 && this.props.currentIndex !== undefined) {
title = _t(
"Upload files (%(current)s of %(total)s)",
Expand All @@ -82,23 +82,23 @@ export default class UploadConfirmDialog extends React.Component<IProps> {
title = _t('Upload files');
}

let preview;
if (this.mimeType.startsWith('image/')) {
preview = <div className="mx_UploadConfirmDialog_previewOuter">
<div className="mx_UploadConfirmDialog_previewInner">
<div><img className="mx_UploadConfirmDialog_imagePreview" src={this.objectUrl} /></div>
<div>{ this.props.file.name } ({ filesize(this.props.file.size) })</div>
</div>
</div>;
let preview: JSX.Element;
let placeholder: JSX.Element;
if (this.mimeType.startsWith("image/")) {
preview = (
<img className="mx_UploadConfirmDialog_imagePreview" src={this.objectUrl} />
);
} else if (this.mimeType.startsWith("video/")) {
preview = (
<video className="mx_UploadConfirmDialog_imagePreview" src={this.objectUrl} playsInline controls={false} />
);
} else {
preview = <div>
<div>
<img className="mx_UploadConfirmDialog_fileIcon"
src={require("../../../../res/img/feather-customised/files.svg").default}
/>
{ this.props.file.name } ({ filesize(this.props.file.size) })
</div>
</div>;
placeholder = (
<img
className="mx_UploadConfirmDialog_fileIcon"
src={require("../../../../res/img/feather-customised/files.svg").default}
/>
);
}

let uploadAllButton;
Expand All @@ -109,14 +109,23 @@ export default class UploadConfirmDialog extends React.Component<IProps> {
}

return (
<BaseDialog className='mx_UploadConfirmDialog'
<BaseDialog
className="mx_UploadConfirmDialog"
fixedWidth={false}
onFinished={this.onCancelClick}
title={title}
contentId='mx_Dialog_content'
contentId="mx_Dialog_content"
>
<div id='mx_Dialog_content'>
{ preview }
<div id="mx_Dialog_content">
<div className="mx_UploadConfirmDialog_previewOuter">
<div className="mx_UploadConfirmDialog_previewInner">
{ preview && <div>{ preview }</div> }
<div>
{ placeholder }
{ this.props.file.name } ({ filesize(this.props.file.size) })
</div>
</div>
</div>
</div>

<DialogButtons primaryButton={_t('Upload')}
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/voip/VideoFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
),
});

content= (
content = (
<video className={videoClasses} ref={this.setElementRef} />
);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/blobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const ALLOWED_BLOB_MIMETYPES = [
'video/mp4',
'video/webm',
'video/ogg',
'video/quicktime',

'audio/mp4',
'audio/webm',
Expand Down