SchedulePage.js 6.4 KB

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