/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from "react";
import {
Platform,
StyleSheet,
Text,
View,
Image,
TouchableOpacity,
ImageBackground,
FlatList,
StatusBar,
Button,
DeviceEventEmitter
} from "react-native";
import Orientation from "react-native-orientation";
import AndroidUtil from "../../util/AndroidUtil";
import BasePage from "../BasePage";
import CourseTitle from "./CourseTitle";
import ScheduleFlatItem from "./ScheduleFlatItem";
import CusVideo from "./CusVideo";
const instructions = Platform.select({
ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
android:
"Double tap R on your keyboard to reload,\n" +
"Shake or press menu button for dev menu"
});
type Props = {};
export default class SchedulePage extends BasePage {
constructor(props) {
super(props);
this.state = {
statusbar_hidden: false,
videoImg_flex: 1,
videoImg_width: "100%",
videoImg_height: "100%",
video_flex: 0,
video_width: "0%",
video_height: "0%",
video_uri:
"http://efunvideo.ai160.com/vs2m/056/05602002/05602002001/05602002001.m3u8",
title_height: "6%",
video_frame_height: "32%",
seat_height: "2%",
flatlist_height: "60%",
isFull: false
};
}
render() {
return (
this.goBack()}
backPress={() => alert("左侧按钮")}
rightPress={() => alert("右侧按钮")}
/>
(this.video = view)}
needback={false}
videofullScreenPlayer={this.fullScreenPlayer.bind(this)}
style={{
flex: this.state.video_flex,
width: this.state.video_width,
height: this.state.video_height
}}
/>
(
)}
ListFooterComponent={() => (
)}
renderItem={({ item }) => {
return this.loadFlatItem(item);
}}
keyExtractor={(item, index) => item.key.toString()}
horizontal={false}
data={[
{
key: 1,
typecolor: "#74E0FF",
typename: "习惯养成",
videoname: "碗里不剩一粒米",
videourl: "碗里不剩一粒米xxxx"
},
{
key: 2,
typecolor: "#FB5B76",
typename: "品格礼仪",
videoname: "我有很多朋友",
videourl: "我有很多朋友xxxx"
},
{
key: 3,
typecolor: "#EC48E1",
typename: "自我保护",
videoname: "小猫喵喵叫",
videourl: "小猫喵喵叫xxxx"
},
{
key: 4,
typecolor: "#39D6B9",
typename: "亲子游戏",
videoname: "安静的睡前游戏-全家人都睡了",
videourl: "安静的睡前游戏xxxx"
},
{
key: 5,
typecolor: "#3397F0",
typename: "欢乐音乐",
videoname: "小鸡捉虫子",
videourl: "小鸡捉虫子xxxx"
},
{
key: 11,
typecolor: "#74E0FF",
typename: "习惯养成",
videoname: "碗里不剩一粒米",
videourl: "碗里不剩一粒米xxxx"
},
{
key: 12,
typecolor: "#FB5B76",
typename: "品格礼仪",
videoname: "我有很多朋友",
videourl: "我有很多朋友xxxx"
},
{
key: 13,
typecolor: "#EC48E1",
typename: "自我保护",
videoname: "小猫喵喵叫",
videourl: "小猫喵喵叫xxxx"
},
{
key: 14,
typecolor: "#39D6B9",
typename: "亲子游戏",
videoname: "安静的睡前游戏-全家人都睡了",
videourl:
"https://www.apple.com/105/media/cn/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-cn-20170912_1280x720h.mp4"
},
{
key: 15,
typecolor: "#3397F0",
typename: "欢乐音乐",
videoname: "小鸡捉虫子",
videourl:
"http://efunvideo.ai160.com/vs2m/056/05602002/05602002001/05602002001.m3u8"
}
]}
/>
);
}
loadFlatItem(data) {
return (
this.changeUrl(data.videourl)}
/>
);
}
fullScreenPlayer() {
if (!this.state.isFull) {
Orientation.lockToLandscape();
this.setState({
title_height: "0%",
video_frame_height: "100%",
seat_height: "0%",
flatlist_height: "0%",
statusbar_hidden: true,
isFull: true
});
} else {
Orientation.lockToPortrait();
this.setState({
title_height: "6%",
video_frame_height: "32%",
seat_height: "2%",
flatlist_height: "60%",
statusbar_hidden: false,
isFull: false
});
}
}
changeUrl(url) {
//切换视频并且播放
// alert(url);
this.setState({
videoImg_flex: 0,
videoImg_width: "0%",
videoImg_height: "0%",
video_flex: 1,
video_width: "100%",
video_height: "100%",
video_uri: url
});
this.video.refreshVideo();
this.video.start();
}
}