add working video upload / grab
This commit is contained in:
parent
d4ca88e22c
commit
83dc09f9ba
|
@ -92,10 +92,12 @@ const createJSON = values => {
|
||||||
description,
|
description,
|
||||||
media: {
|
media: {
|
||||||
isPlaying,
|
isPlaying,
|
||||||
url: formatMedia(video),
|
|
||||||
type: '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)
|
return JSON.stringify(manifest, null, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +206,23 @@ const SubmissionSection = ({ classes }) => {
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
value={values.title || ''}
|
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
|
<TextField
|
||||||
id="commitTime"
|
id="commitTime"
|
||||||
name="commitTime"
|
name="commitTime"
|
||||||
|
@ -222,23 +241,6 @@ const SubmissionSection = ({ classes }) => {
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
value={values.commitTime || ''}
|
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
|
<TextField
|
||||||
className={classes.textField}
|
className={classes.textField}
|
||||||
InputProps={{
|
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 getProjectManifest = assets => assets ? JSON.parse(assets.find(a => a.name.toLowerCase() === 'manifest.json').content) : null
|
||||||
|
|
||||||
const formatMedia = content => {
|
const formatMedia = content => {
|
||||||
const blob = new Blob([content], {type : 'video/mp4'})
|
const type = 'video/mp4'
|
||||||
return URL.createObjectURL(blob)
|
const blob = new Blob([content], {type})
|
||||||
|
const src = URL.createObjectURL(blob)
|
||||||
|
return src
|
||||||
}
|
}
|
||||||
|
|
||||||
const getMediaType = assets => {
|
const getMediaType = assets => {
|
||||||
|
@ -157,6 +159,7 @@ const getMediaType = assets => {
|
||||||
if (media.type.toLowerCase().includes('video')) return true
|
if (media.type.toLowerCase().includes('video')) return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getFile = filePath => filePath.split('/').slice(-1)[0]
|
||||||
const getMediaSrc = assets => {
|
const getMediaSrc = assets => {
|
||||||
if (!assets) return null
|
if (!assets) return null
|
||||||
const { media } = getProjectManifest(assets)
|
const { media } = getProjectManifest(assets)
|
||||||
|
@ -164,13 +167,12 @@ const getMediaSrc = assets => {
|
||||||
if (media.url) return media.url
|
if (media.url) return media.url
|
||||||
if (media.file) {
|
if (media.file) {
|
||||||
return formatMedia(
|
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 }) {
|
function Project({ classes, match, profile, transfers, pledges, projectAddedEvents }) {
|
||||||
const projectId = match.params.id
|
const projectId = match.params.id
|
||||||
const { projectAge, projectAssets, manifest } = useProjectData(projectId, profile, projectAddedEvents)
|
const { projectAge, projectAssets, manifest } = useProjectData(projectId, profile, projectAddedEvents)
|
||||||
|
@ -204,7 +206,7 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.secondRow}>
|
<div className={classes.secondRow}>
|
||||||
{mediaType
|
{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
|
: <CardMedia
|
||||||
component="img"
|
component="img"
|
||||||
alt="video"
|
alt="video"
|
||||||
|
|
Loading…
Reference in New Issue