|
@@ -15,7 +15,8 @@ import {
|
|
ScrollView,
|
|
ScrollView,
|
|
StatusBar,
|
|
StatusBar,
|
|
BackHandler,
|
|
BackHandler,
|
|
- FlatList
|
|
|
|
|
|
+ FlatList,
|
|
|
|
+ TouchableOpacity
|
|
} from "react-native";
|
|
} from "react-native";
|
|
import Orientation from "react-native-orientation";
|
|
import Orientation from "react-native-orientation";
|
|
import CusVideo from "./CusVideo";
|
|
import CusVideo from "./CusVideo";
|
|
@@ -35,7 +36,9 @@ export default class VideoExplain extends Component {
|
|
statusbar_hidden: false,
|
|
statusbar_hidden: false,
|
|
videoStyle: {
|
|
videoStyle: {
|
|
width: "100%"
|
|
width: "100%"
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ collectImage: require('../images/courseDetails/collect.png'),
|
|
|
|
+ isCollect: true
|
|
};
|
|
};
|
|
|
|
|
|
render() {
|
|
render() {
|
|
@@ -54,7 +57,7 @@ export default class VideoExplain extends Component {
|
|
uri={this.props.uri} //播放路径
|
|
uri={this.props.uri} //播放路径
|
|
ref={view => (this.video = view)} //设置ID
|
|
ref={view => (this.video = view)} //设置ID
|
|
needback={true}
|
|
needback={true}
|
|
- videoback={() => alert("videoback")}
|
|
|
|
|
|
+ videoback={this.back.bind(this)}
|
|
videofullScreenPlayer={this.fullScreenPlayer.bind(this)}
|
|
videofullScreenPlayer={this.fullScreenPlayer.bind(this)}
|
|
onError={this.onError.bind(this)}
|
|
onError={this.onError.bind(this)}
|
|
onEnd={this.onEnd.bind(this)}
|
|
onEnd={this.onEnd.bind(this)}
|
|
@@ -65,10 +68,14 @@ export default class VideoExplain extends Component {
|
|
/>
|
|
/>
|
|
<View style={styles.videoExplain}>
|
|
<View style={styles.videoExplain}>
|
|
<View style={styles.title}>
|
|
<View style={styles.title}>
|
|
- <Text style={styles.font}>{this.props.title}</Text>
|
|
|
|
|
|
+ <Text style={styles.font}>{this.props.dataList}</Text>
|
|
<View style={styles.icon}>
|
|
<View style={styles.icon}>
|
|
- <Image src="" style={styles.iconSize} />
|
|
|
|
- <Image src="" style={styles.iconSize} />
|
|
|
|
|
|
+ <TouchableOpacity onPress={this.collection.bind(this)}>
|
|
|
|
+ <Image source={this.state.collectImage} style={styles.iconSize} />
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ <TouchableOpacity onPress={this.share}>
|
|
|
|
+ <Image source={require('../images/courseDetails/share.png')} style={styles.iconSize} />
|
|
|
|
+ </TouchableOpacity>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
<View style={[styles.title, styles.tops]}>
|
|
<View style={[styles.title, styles.tops]}>
|
|
@@ -80,6 +87,7 @@ export default class VideoExplain extends Component {
|
|
</View>
|
|
</View>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+ // 全屏播放
|
|
fullScreenPlayer() {
|
|
fullScreenPlayer() {
|
|
if (!this.state.isFull) {
|
|
if (!this.state.isFull) {
|
|
Orientation.lockToLandscape();
|
|
Orientation.lockToLandscape();
|
|
@@ -105,32 +113,60 @@ export default class VideoExplain extends Component {
|
|
}
|
|
}
|
|
this.props.full(this.state.isFull);
|
|
this.props.full(this.state.isFull);
|
|
}
|
|
}
|
|
|
|
+ // 播放器异常
|
|
onError() {
|
|
onError() {
|
|
alert("播放器异常");
|
|
alert("播放器异常");
|
|
}
|
|
}
|
|
|
|
+ // 播放结束
|
|
onEnd() {
|
|
onEnd() {
|
|
alert("播放结束");
|
|
alert("播放结束");
|
|
this.video.refreshVideo();
|
|
this.video.refreshVideo();
|
|
}
|
|
}
|
|
|
|
+ back(){
|
|
|
|
+ this.props.videoback();
|
|
|
|
+ }
|
|
componentWillMount() {
|
|
componentWillMount() {
|
|
- BackHandler.addEventListener(
|
|
|
|
|
|
+ this.backlistener=BackHandler.addEventListener(
|
|
"hardwareBackPress",
|
|
"hardwareBackPress",
|
|
- this.onBackAndroid.bind(this)
|
|
|
|
|
|
+ this.onBackAndroid
|
|
);
|
|
);
|
|
}
|
|
}
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
- BackHandler.removeEventListener(
|
|
|
|
- "hardwareBackPress",
|
|
|
|
- this.onBackAndroid.bind(this)
|
|
|
|
- );
|
|
|
|
|
|
+ console.log("componentWillUnmount")
|
|
|
|
+ if( this.backlistener){
|
|
|
|
+ BackHandler.removeEventListener(
|
|
|
|
+ "hardwareBackPress",
|
|
|
|
+ this.onBackAndroid
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
- onBackAndroid() {
|
|
|
|
|
|
+ // 播放器返回
|
|
|
|
+ onBackAndroid=() => {
|
|
if (this.state.isFull) {
|
|
if (this.state.isFull) {
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|
|
alert("返回。。。");
|
|
alert("返回。。。");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 收藏
|
|
|
|
+ collection() {
|
|
|
|
+ if (this.state.isCollect) {
|
|
|
|
+ this.setState({
|
|
|
|
+ collectImage: require('../images/courseDetails/have_collect.png'),
|
|
|
|
+ isCollect: false
|
|
|
|
+ })
|
|
|
|
+ }else {
|
|
|
|
+ this.setState({
|
|
|
|
+ collectImage: require('../images/courseDetails/collect.png'),
|
|
|
|
+ isCollect: true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 分享
|
|
|
|
+ share() {
|
|
|
|
+ alert('点击分享')
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
const styles = StyleSheet.create({
|
|
@@ -165,7 +201,6 @@ const styles = StyleSheet.create({
|
|
iconSize: {
|
|
iconSize: {
|
|
width: 20,
|
|
width: 20,
|
|
height: 20,
|
|
height: 20,
|
|
- backgroundColor: "red",
|
|
|
|
marginLeft: 10
|
|
marginLeft: 10
|
|
},
|
|
},
|
|
tops: {
|
|
tops: {
|