VideoExplain.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import React, { Component } from "react";
  9. import {
  10. StyleSheet,
  11. Text,
  12. View,
  13. Image,
  14. ScrollView,
  15. StatusBar,
  16. FlatList
  17. } from "react-native";
  18. import Orientation from "react-native-orientation";
  19. import CusVideo from "./CusVideo";
  20. // 获取屏幕宽高
  21. import { Dimensions } from 'react-native'
  22. const { height, width } = Dimensions.get('window');
  23. export default class VideoExplain extends Component {
  24. static propTypes = {
  25. // uri: PropTypes.string,
  26. // title: PropTypes.string,
  27. // details: PropTypes.string,
  28. };
  29. state = {
  30. isFull: false,
  31. video_height: 210,
  32. statusbar_hidden: false,
  33. videoStyle: {
  34. width: "100%"
  35. }
  36. };
  37. render() {
  38. return (
  39. <View style={this.state.videoStyle}>
  40. <StatusBar
  41. // backgroundColor={"transparent"}
  42. barStyle={"dark-content"}
  43. backgroundColor={"white"}
  44. translucent={false}
  45. hidden={this.state.statusbar_hidden}
  46. />
  47. {/* <View style={{ width: "100%", height: 210 }} /> */}
  48. <CusVideo
  49. show={true} //是否显示
  50. uri={this.props.uri} //播放路径
  51. ref={view => (this.video = view)} //设置ID
  52. needback={true}
  53. videoback={() => alert("videoback")}
  54. videofullScreenPlayer={this.fullScreenPlayer.bind(this)}
  55. style={{
  56. width: "100%",
  57. height: this.state.video_height
  58. }}
  59. />
  60. <View style={styles.videoExplain}>
  61. <View style={styles.title}>
  62. <Text style={styles.font}>{this.props.title}</Text>
  63. <View style={styles.icon}>
  64. <Image src="" style={styles.iconSize} />
  65. <Image src="" style={styles.iconSize} />
  66. </View>
  67. </View>
  68. <View style={[styles.title, styles.tops]}>
  69. <Text style={styles.font}>课程介绍:</Text>
  70. <Text style={styles.clor}>更多 ></Text>
  71. </View>
  72. <Text style={styles.clor}>{this.props.details}</Text>
  73. </View>
  74. </View>
  75. );
  76. }
  77. fullScreenPlayer() {
  78. if (!this.state.isFull) {
  79. Orientation.lockToLandscape();
  80. this.setState({
  81. statusbar_hidden: true,
  82. isFull: true,
  83. video_height: "100%",
  84. videoStyle: {
  85. width: "100%",
  86. height: width
  87. }
  88. });
  89. } else {
  90. Orientation.lockToPortrait();
  91. this.setState({
  92. statusbar_hidden: false,
  93. isFull: false,
  94. video_height: 210,
  95. videoStyle: {
  96. width: "100%"
  97. }
  98. });
  99. }
  100. this.props.full(this.state.isFull);
  101. }
  102. }
  103. const styles = StyleSheet.create({
  104. videoExplain: {
  105. width: "100%",
  106. backgroundColor: "white",
  107. paddingLeft: 20,
  108. paddingRight: 20,
  109. paddingTop: 13,
  110. paddingBottom: 13
  111. },
  112. title: {
  113. width: "100%",
  114. display: "flex",
  115. flexDirection: "row",
  116. justifyContent: "space-between",
  117. alignItems: "center"
  118. },
  119. font: {
  120. fontSize: 18,
  121. color: "black",
  122. fontWeight: "bold"
  123. },
  124. clor: {
  125. fontSize: 14,
  126. color: "black"
  127. },
  128. icon: {
  129. display: "flex",
  130. flexDirection: "row"
  131. },
  132. iconSize: {
  133. width: 20,
  134. height: 20,
  135. backgroundColor: "red",
  136. marginLeft: 10
  137. },
  138. tops: {
  139. marginTop: 18
  140. }
  141. });