Commit c4a62a7c by zhanghaozhe

video

parent 6b58fb66
...@@ -25,7 +25,7 @@ class Video extends Component { ...@@ -25,7 +25,7 @@ class Video extends Component {
state = { state = {
title: '', title: '',
courseId: null, courseId: null,
video_catalog: [], videoList: [],
datum: [], datum: [],
currentVideoSrc: '', currentVideoSrc: '',
activeIndex: 0, activeIndex: 0,
...@@ -42,8 +42,9 @@ class Video extends Component { ...@@ -42,8 +42,9 @@ class Video extends Component {
this.setState({ this.setState({
courseId: this.courseID courseId: this.courseID
}) })
this.getVideoCatalog() this.getVideoList()
this.getDatumCatalog() this.getDatumCatalog()
} }
initializePlayer = () => { initializePlayer = () => {
...@@ -54,10 +55,13 @@ class Video extends Component { ...@@ -54,10 +55,13 @@ class Video extends Component {
bigPlayButton: true, bigPlayButton: true,
textTrackDisplay: false, textTrackDisplay: false,
posterImage: false, posterImage: false,
errorDisplay: false errorDisplay: false,
playbackRates: ['0.75', '1', '1.5', '2']
}) })
this.player.enableTouchActivity() this.player.enableTouchActivity()
this.player.on('useractive', function () {
console.log('active');
})
} }
componentWillUnmount() { componentWillUnmount() {
...@@ -69,7 +73,7 @@ class Video extends Component { ...@@ -69,7 +73,7 @@ class Video extends Component {
handleClick = index => { handleClick = index => {
if (this.hasAuth()) { if (this.hasAuth()) {
this.setPlayerSrc(this.state.video_catalog[index]['play_url']) this.setPlayerSrc(this.state.videoList[index]['play_url'])
this.playVideo() this.playVideo()
} }
this.setState({ this.setState({
...@@ -78,7 +82,7 @@ class Video extends Component { ...@@ -78,7 +82,7 @@ class Video extends Component {
} }
getVideoCatalog = () => { getVideoList = () => {
http.get(`${api.home}/m/course/play/${this.courseID}`) http.get(`${api.home}/m/course/play/${this.courseID}`)
.then(res => { .then(res => {
const data = res.data const data = res.data
...@@ -86,7 +90,7 @@ class Video extends Component { ...@@ -86,7 +90,7 @@ class Video extends Component {
this.setState( this.setState(
state => ({ state => ({
video_catalog: data.data['lessons'], videoList: data.data['lessons'],
currentVideoSrc: data.data['lessons'][state.activeIndex]['play_url'], currentVideoSrc: data.data['lessons'][state.activeIndex]['play_url'],
course: data.data.course, course: data.data.course,
courseId: data.data.course['course_id'], courseId: data.data.course['course_id'],
...@@ -149,8 +153,8 @@ class Video extends Component { ...@@ -149,8 +153,8 @@ class Video extends Component {
} }
lessonAvailable = () => { lessonAvailable = () => {
const {video_catalog, activeIndex} = this.state const {videoList, activeIndex} = this.state
return video_catalog[activeIndex]['video_size'] !== 0 return videoList[activeIndex]['video_size'] !== 0
} }
getCoursePrice = () => { getCoursePrice = () => {
...@@ -166,16 +170,16 @@ class Video extends Component { ...@@ -166,16 +170,16 @@ class Video extends Component {
} }
playWithAuth = () => { playWithAuth = () => {
const {video_catalog, activeIndex} = this.state const {videoList, activeIndex} = this.state
if (this.hasAuth()) { if (this.hasAuth()) {
this.setPlayerSrc(video_catalog[activeIndex]['play_url']) this.setPlayerSrc(videoList[activeIndex]['play_url'])
} }
} }
hasAuth = (index) => { hasAuth = (index) => {
const {course, video_catalog, activeIndex} = this.state const {course, videoList, activeIndex} = this.state
let lesson = video_catalog[activeIndex] let lesson = videoList[activeIndex]
if (!lesson['is_free']) { if (!lesson['is_free']) {
if (course['is_audition']) { if (course['is_audition']) {
this.setState({ this.setState({
...@@ -205,7 +209,7 @@ class Video extends Component { ...@@ -205,7 +209,7 @@ class Video extends Component {
render() { render() {
let {match, location} = this.props let {match, location} = this.props
const {video_catalog, activeIndex, isAuth, salePrice} = this.state const {videoList, activeIndex, isAuth, salePrice} = this.state
return ( return (
<div className='play'> <div className='play'>
<HeaderBar title={this.state.title} arrow={true}/> <HeaderBar title={this.state.title} arrow={true}/>
...@@ -221,7 +225,7 @@ class Video extends Component { ...@@ -221,7 +225,7 @@ class Video extends Component {
<div className='btns'> <div className='btns'>
<button type='button' className='purchase-class'>¥{salePrice} 购买课程</button> <button type='button' className='purchase-class'>¥{salePrice} 购买课程</button>
<button type='button' <button type='button'
className='purchase-episode'>¥{video_catalog.length && video_catalog[activeIndex]['class_price']} 购买单集 className='purchase-episode'>¥{videoList.length && videoList[activeIndex]['class_price']} 购买单集
</button> </button>
</div> </div>
</div> </div>
...@@ -252,7 +256,7 @@ class Video extends Component { ...@@ -252,7 +256,7 @@ class Video extends Component {
return <VideoCatalog return <VideoCatalog
activeIndex={this.state.activeIndex} activeIndex={this.state.activeIndex}
handleClick={this.handleClick} handleClick={this.handleClick}
videoCatalog={this.state.video_catalog} videoCatalog={this.state.videoList}
{...props}/> {...props}/>
}}/> }}/>
<Route path={`${match.path}/datum`} render={props => { <Route path={`${match.path}/datum`} render={props => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment