SchedulePage.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. Platform,
  11. StyleSheet,
  12. Text,
  13. View,
  14. Image,
  15. TouchableOpacity,
  16. ImageBackground,
  17. FlatList,
  18. StatusBar,
  19. Button,
  20. DeviceEventEmitter
  21. } from "react-native";
  22. import Orientation from "react-native-orientation";
  23. import AndroidUtil from "../../util/AndroidUtil";
  24. import BasePage from "../BasePage";
  25. import CourseTitle from "./CourseTitle";
  26. import ScheduleFlatItem from "./ScheduleFlatItem";
  27. import CusVideo from "./CusVideo";
  28. const instructions = Platform.select({
  29. ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
  30. android:
  31. "Double tap R on your keyboard to reload,\n" +
  32. "Shake or press menu button for dev menu"
  33. });
  34. type Props = {};
  35. export default class SchedulePage extends BasePage {
  36. constructor(props) {
  37. super(props);
  38. this.state = {
  39. statusbar_hidden: false,
  40. videoImg_flex: 1,
  41. videoImg_width: "100%",
  42. videoImg_height: "100%",
  43. video_flex: 0,
  44. video_width: "0%",
  45. video_height: "0%",
  46. video_uri:
  47. "http://efunvideo.ai160.com/vs2m/056/05602002/05602002001/05602002001.m3u8",
  48. title_height: "6%",
  49. video_frame_height: "32%",
  50. seat_height: "2%",
  51. flatlist_height: "60%",
  52. isFull: false
  53. };
  54. }
  55. render() {
  56. return (
  57. <View
  58. style={{
  59. flex: 1
  60. }}
  61. >
  62. <StatusBar
  63. // backgroundColor={"transparent"}
  64. barStyle={"dark-content"}
  65. backgroundColor={"white"}
  66. translucent={false}
  67. hidden={this.state.statusbar_hidden}
  68. />
  69. <View
  70. style={{
  71. flex: 1,
  72. backgroundColor: "#F3F3F3",
  73. justifyContent: "center",
  74. alignItems: "center"
  75. }}
  76. >
  77. <View
  78. style={{
  79. height: this.state.title_height,
  80. backgroundColor: "white"
  81. }}
  82. >
  83. <CourseTitle
  84. width={this.getWindowWidth()}
  85. title="第12周 爱上幼儿园"
  86. lefttype={1}
  87. righttype={1}
  88. textcolor={"red"}
  89. // backPress={() => this.goBack()}
  90. backPress={() => alert("左侧按钮")}
  91. rightPress={() => alert("右侧按钮")}
  92. />
  93. </View>
  94. <View
  95. style={{
  96. height: this.state.video_frame_height,
  97. width: "100%"
  98. }}
  99. >
  100. <Image
  101. source={{
  102. uri:
  103. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg"
  104. }}
  105. style={{
  106. flex: this.state.videoImg_flex,
  107. width: this.state.videoImg_width,
  108. height: this.state.videoImg_height
  109. }}
  110. />
  111. <CusVideo
  112. uri={this.state.video_uri}
  113. ref={view => (this.video = view)}
  114. needback={true}
  115. videoback={this.clickVideoBack.bind(this)}
  116. videofullScreenPlayer={this.fullScreenPlayer.bind(this)}
  117. style={{
  118. flex: this.state.video_flex,
  119. width: this.state.video_width,
  120. height: this.state.video_height
  121. }}
  122. />
  123. </View>
  124. <View style={{ height: this.state.seat_height }} />
  125. <View
  126. style={{
  127. height: this.state.flatlist_height,
  128. justifyContent: "center",
  129. alignItems: "center",
  130. width: "100%"
  131. }}
  132. >
  133. <FlatList
  134. ItemSeparatorComponent={() => (
  135. <View
  136. style={{
  137. height: 10
  138. }}
  139. />
  140. )}
  141. ListFooterComponent={() => (
  142. <View
  143. style={{
  144. height: 30
  145. }}
  146. />
  147. )}
  148. renderItem={({ item }) => {
  149. return this.loadFlatItem(item);
  150. }}
  151. keyExtractor={(item, index) => item.key.toString()}
  152. horizontal={false}
  153. data={[
  154. {
  155. key: 1,
  156. typecolor: "#74E0FF",
  157. typename: "习惯养成",
  158. videoname: "碗里不剩一粒米",
  159. videourl: "碗里不剩一粒米xxxx"
  160. },
  161. {
  162. key: 2,
  163. typecolor: "#FB5B76",
  164. typename: "品格礼仪",
  165. videoname: "我有很多朋友",
  166. videourl: "我有很多朋友xxxx"
  167. },
  168. {
  169. key: 3,
  170. typecolor: "#EC48E1",
  171. typename: "自我保护",
  172. videoname: "小猫喵喵叫",
  173. videourl: "小猫喵喵叫xxxx"
  174. },
  175. {
  176. key: 4,
  177. typecolor: "#39D6B9",
  178. typename: "亲子游戏",
  179. videoname: "安静的睡前游戏-全家人都睡了",
  180. videourl: "安静的睡前游戏xxxx"
  181. },
  182. {
  183. key: 5,
  184. typecolor: "#3397F0",
  185. typename: "欢乐音乐",
  186. videoname: "小鸡捉虫子",
  187. videourl: "小鸡捉虫子xxxx"
  188. },
  189. {
  190. key: 11,
  191. typecolor: "#74E0FF",
  192. typename: "习惯养成",
  193. videoname: "碗里不剩一粒米",
  194. videourl: "碗里不剩一粒米xxxx"
  195. },
  196. {
  197. key: 12,
  198. typecolor: "#FB5B76",
  199. typename: "品格礼仪",
  200. videoname: "我有很多朋友",
  201. videourl: "我有很多朋友xxxx"
  202. },
  203. {
  204. key: 13,
  205. typecolor: "#EC48E1",
  206. typename: "自我保护",
  207. videoname: "小猫喵喵叫",
  208. videourl: "小猫喵喵叫xxxx"
  209. },
  210. {
  211. key: 14,
  212. typecolor: "#39D6B9",
  213. typename: "亲子游戏",
  214. videoname: "安静的睡前游戏-全家人都睡了",
  215. videourl:
  216. "https://www.apple.com/105/media/cn/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-cn-20170912_1280x720h.mp4"
  217. },
  218. {
  219. key: 15,
  220. typecolor: "#3397F0",
  221. typename: "欢乐音乐",
  222. videoname: "小鸡捉虫子",
  223. videourl:
  224. "http://efunvideo.ai160.com/vs2m/056/05602002/05602002001/05602002001.m3u8"
  225. }
  226. ]}
  227. />
  228. </View>
  229. </View>
  230. </View>
  231. );
  232. }
  233. loadFlatItem(data) {
  234. return (
  235. <ScheduleFlatItem
  236. width={this.getWindowWidth() * 0.9}
  237. height={50}
  238. data={data}
  239. onPress={() => this.changeUrl(data.videourl)}
  240. />
  241. );
  242. }
  243. fullScreenPlayer() {
  244. if (!this.state.isFull) {
  245. Orientation.lockToLandscape();
  246. this.setState({
  247. title_height: "0%",
  248. video_frame_height: "100%",
  249. seat_height: "0%",
  250. flatlist_height: "0%",
  251. statusbar_hidden: true,
  252. isFull: true
  253. });
  254. } else {
  255. Orientation.lockToPortrait();
  256. this.setState({
  257. title_height: "6%",
  258. video_frame_height: "32%",
  259. seat_height: "2%",
  260. flatlist_height: "60%",
  261. statusbar_hidden: false,
  262. isFull: false
  263. });
  264. }
  265. }
  266. changeUrl(url) {
  267. //切换视频并且播放
  268. // alert(url);
  269. this.setState({
  270. videoImg_flex: 0,
  271. videoImg_width: "0%",
  272. videoImg_height: "0%",
  273. video_flex: 1,
  274. video_width: "100%",
  275. video_height: "100%",
  276. video_uri: url
  277. });
  278. this.video.refreshVideo();
  279. this.video.start();
  280. }
  281. clickVideoBack() {
  282. alert("click video back");
  283. }
  284. }