add working video upload / grab
This commit is contained in:
parent
d4ca88e22c
commit
83dc09f9ba
|
@ -92,10 +92,12 @@ const createJSON = values => {
|
|||
description,
|
||||
media: {
|
||||
isPlaying,
|
||||
url: formatMedia(video),
|
||||
type: 'video'
|
||||
}
|
||||
}
|
||||
|
||||
if (isWeb(video)) Object.assign(manifest.media, { url: formatMedia(video) })
|
||||
else Object.assign(manifest.media, { file: formatMedia(video) })
|
||||
return JSON.stringify(manifest, null, 2)
|
||||
}
|
||||
|
||||
|
@ -204,6 +206,23 @@ const SubmissionSection = ({ classes }) => {
|
|||
onBlur={handleBlur}
|
||||
value={values.title || ''}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.textField}
|
||||
InputProps={{
|
||||
classes: {
|
||||
input: classes.textInput
|
||||
}
|
||||
}}
|
||||
id="subtitle"
|
||||
name="subtitle"
|
||||
label="Enter a sub heading description for your project"
|
||||
placeholder="Enter a sub heading description for your project"
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.subtitle || ''}
|
||||
/>
|
||||
<TextField
|
||||
id="commitTime"
|
||||
name="commitTime"
|
||||
|
@ -222,23 +241,6 @@ const SubmissionSection = ({ classes }) => {
|
|||
onBlur={handleBlur}
|
||||
value={values.commitTime || ''}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.textField}
|
||||
InputProps={{
|
||||
classes: {
|
||||
input: classes.textInput
|
||||
}
|
||||
}}
|
||||
id="subtitle"
|
||||
name="subtitle"
|
||||
label="Enter a sub heading description for your project"
|
||||
placeholder="Enter a sub heading description for your project"
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.subtitle || ''}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.textField}
|
||||
InputProps={{
|
||||
|
|
|
@ -147,8 +147,10 @@ async function getProjectAssets(hash, setState){
|
|||
const getProjectManifest = assets => assets ? JSON.parse(assets.find(a => a.name.toLowerCase() === 'manifest.json').content) : null
|
||||
|
||||
const formatMedia = content => {
|
||||
const blob = new Blob([content], {type : 'video/mp4'})
|
||||
return URL.createObjectURL(blob)
|
||||
const type = 'video/mp4'
|
||||
const blob = new Blob([content], {type})
|
||||
const src = URL.createObjectURL(blob)
|
||||
return src
|
||||
}
|
||||
|
||||
const getMediaType = assets => {
|
||||
|
@ -157,6 +159,7 @@ const getMediaType = assets => {
|
|||
if (media.type.toLowerCase().includes('video')) return true
|
||||
}
|
||||
|
||||
const getFile = filePath => filePath.split('/').slice(-1)[0]
|
||||
const getMediaSrc = assets => {
|
||||
if (!assets) return null
|
||||
const { media } = getProjectManifest(assets)
|
||||
|
@ -164,13 +167,12 @@ const getMediaSrc = assets => {
|
|||
if (media.url) return media.url
|
||||
if (media.file) {
|
||||
return formatMedia(
|
||||
assets.find(a => a.name === media.file).content
|
||||
assets.find(a => a.name === getFile(media.file)).content
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Project({ classes, match, profile, transfers, pledges, projectAddedEvents }) {
|
||||
const projectId = match.params.id
|
||||
const { projectAge, projectAssets, manifest } = useProjectData(projectId, profile, projectAddedEvents)
|
||||
|
@ -204,7 +206,7 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
|
|||
</div>
|
||||
<div className={classes.secondRow}>
|
||||
{mediaType
|
||||
? <ReactPlayer width="100%" height="100%" url={mediaUrl} playing={manifest.media.isPlaying} />
|
||||
? <ReactPlayer width="100%" height="100%" url={mediaUrl} playing={manifest.media.isPlaying} controls />
|
||||
: <CardMedia
|
||||
component="img"
|
||||
alt="video"
|
||||
|
|
Loading…
Reference in New Issue