SchedulePage.js 7.3 KB

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