Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Commit

Permalink
#12 Add videoを複数再生することができるように
Browse files Browse the repository at this point in the history
  • Loading branch information
res0nanz committed Feb 27, 2019
1 parent 3402869 commit 2168db0
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { Component } from 'react'
import LoadVideo from '../containers/LoadVideo'
// import VideoList from '../containers/VideosList'
import VideoList from '../containers/VideosList'

class App extends Component {
render() {
return (
<div className="App">
<LoadVideo />
{/* <VideoList /> */}
<VideoList />
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/LoadForm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import PropTypes from 'prop-types'

const LoadForm = props => (
const LoadForm = ({ onLoadVideo }) => (
<input type="file" onChange={e =>
props.onLoadVideo(e.target.files[0].path)} />
onLoadVideo(e.target.files[0].path)} />
)

LoadForm.propTypes = {
Expand Down
14 changes: 14 additions & 0 deletions src/components/Video.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import PropTypes from 'prop-types'

const Video = ({ path }) => (
<video width="500" height="300" controls loop>
<source src={path}/>
</video>
)

Video.protoTypes = {
path: PropTypes.string.isRequired
}

export default Video
Empty file removed src/components/Videos.js
Empty file.
17 changes: 17 additions & 0 deletions src/components/VideosListView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import PropTypes from 'prop-types'
import Video from './Video'

const VideosListView = ({ videos }) => (
videos.map((video, index) => (
<Video key={index} path={video.path} />
))
)

VideosListView.propTypes = {
videos: PropTypes.arrayOf({
path: PropTypes.string.isRequired
})
}

export default VideosListView
19 changes: 19 additions & 0 deletions src/containers/VideosList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { connect } from 'react-redux'
import VideoListView from '../components/VideosListView'

const mapStateToProps = state => {
return {
videos: state
}
}

const mapDispatchToProps = dispatch => {
return {}
}

const LoadVideo = connect(
mapStateToProps,
mapDispatchToProps
)(VideoListView)

export default LoadVideo
4 changes: 2 additions & 2 deletions src/reducers/videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ function videos(state = [], action) {
return [
...state,
{
file: action.file,
position: state.length
path: action.path,
// position: state.length
}
]
default:
Expand Down

0 comments on commit 2168db0

Please sign in to comment.