SchedulePage.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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={false}
  115. videofullScreenPlayer={this.fullScreenPlayer.bind(this)}
  116. style={{
  117. flex: this.state.video_flex,
  118. width: this.state.video_width,
  119. height: this.state.video_height
  120. }}
  121. />
  122. </View>
  123. <View style={{ height: this.state.seat_height }} />
  124. <View
  125. style={{
  126. height: this.state.flatlist_height,
  127. justifyContent: "center",
  128. alignItems: "center",
  129. width: "100%"
  130. }}
  131. >
  132. <FlatList
  133. ItemSeparatorComponent={() => (
  134. <View
  135. style={{
  136. height: 10
  137. }}
  138. />
  139. )}
  140. ListFooterComponent={() => (
  141. <View
  142. style={{
  143. height: 30
  144. }}
  145. />
  146. )}
  147. renderItem={({ item }) => {
  148. return this.loadFlatItem(item);
  149. }}
  150. keyExtractor={(item, index) => item.key.toString()}
  151. horizontal={false}
  152. data={[
  153. {
  154. key: 1,
  155. typecolor: "#74E0FF",
  156. typename: "习惯养成",
  157. videoname: "碗里不剩一粒米",
  158. videourl: "碗里不剩一粒米xxxx"
  159. },
  160. {
  161. key: 2,
  162. typecolor: "#FB5B76",
  163. typename: "品格礼仪",
  164. videoname: "我有很多朋友",
  165. videourl: "我有很多朋友xxxx"
  166. },
  167. {
  168. key: 3,
  169. typecolor: "#EC48E1",
  170. typename: "自我保护",
  171. videoname: "小猫喵喵叫",
  172. videourl: "小猫喵喵叫xxxx"
  173. },
  174. {
  175. key: 4,
  176. typecolor: "#39D6B9",
  177. typename: "亲子游戏",
  178. videoname: "安静的睡前游戏-全家人都睡了",
  179. videourl: "安静的睡前游戏xxxx"
  180. },
  181. {
  182. key: 5,
  183. typecolor: "#3397F0",
  184. typename: "欢乐音乐",
  185. videoname: "小鸡捉虫子",
  186. videourl: "小鸡捉虫子xxxx"
  187. },
  188. {
  189. key: 11,
  190. typecolor: "#74E0FF",
  191. typename: "习惯养成",
  192. videoname: "碗里不剩一粒米",
  193. videourl: "碗里不剩一粒米xxxx"
  194. },
  195. {
  196. key: 12,
  197. typecolor: "#FB5B76",
  198. typename: "品格礼仪",
  199. videoname: "我有很多朋友",
  200. videourl: "我有很多朋友xxxx"
  201. },
  202. {
  203. key: 13,
  204. typecolor: "#EC48E1",
  205. typename: "自我保护",
  206. videoname: "小猫喵喵叫",
  207. videourl: "小猫喵喵叫xxxx"
  208. },
  209. {
  210. key: 14,
  211. typecolor: "#39D6B9",
  212. typename: "亲子游戏",
  213. videoname: "安静的睡前游戏-全家人都睡了",
  214. videourl:
  215. "https://www.apple.com/105/media/cn/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-cn-20170912_1280x720h.mp4"
  216. },
  217. {
  218. key: 15,
  219. typecolor: "#3397F0",
  220. typename: "欢乐音乐",
  221. videoname: "小鸡捉虫子",
  222. videourl:
  223. "http://efunvideo.ai160.com/vs2m/056/05602002/05602002001/05602002001.m3u8"
  224. }
  225. ]}
  226. />
  227. </View>
  228. </View>
  229. </View>
  230. );
  231. }
  232. loadFlatItem(data) {
  233. return (
  234. <ScheduleFlatItem
  235. width={this.getWindowWidth() * 0.9}
  236. height={50}
  237. data={data}
  238. onPress={() => this.changeUrl(data.videourl)}
  239. />
  240. );
  241. }
  242. fullScreenPlayer() {
  243. if (!this.state.isFull) {
  244. Orientation.lockToLandscape();
  245. this.setState({
  246. title_height: "0%",
  247. video_frame_height: "100%",
  248. seat_height: "0%",
  249. flatlist_height: "0%",
  250. statusbar_hidden: true,
  251. isFull: true
  252. });
  253. } else {
  254. Orientation.lockToPortrait();
  255. this.setState({
  256. title_height: "6%",
  257. video_frame_height: "32%",
  258. seat_height: "2%",
  259. flatlist_height: "60%",
  260. statusbar_hidden: false,
  261. isFull: false
  262. });
  263. }
  264. }
  265. changeUrl(url) {
  266. //切换视频并且播放
  267. // alert(url);
  268. this.setState({
  269. videoImg_flex: 0,
  270. videoImg_width: "0%",
  271. videoImg_height: "0%",
  272. video_flex: 1,
  273. video_width: "100%",
  274. video_height: "100%",
  275. video_uri: url
  276. });
  277. this.video.refreshVideo();
  278. this.video.start();
  279. }
  280. }