Commit d70f6668 authored by zhangkaixuan11's avatar zhangkaixuan11

上传下

parent 6c2cefb8
......@@ -6,6 +6,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<application
tools:replace="android:allowBackup"
android:name=".MainApplication"
......@@ -34,7 +36,7 @@
<data android:scheme="fhstudents" android:host="fhstudents"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity android:name="com.fa cebook.react.devsupport.DevSettingsActivity" />
<activity android:name="com.ahmedadeltito.photoeditor.PhotoEditorActivity" />
<activity android:name="com.yalantis.ucrop.UCropActivity" />
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -276,15 +276,17 @@ let LiveCSS = StyleSheet.create({
width: Constants.unitWidth * 160
},
videoRow: {
height: Constants.unitWidth * 0,
backgroundColor: '#21232A',
height: Constants.unitWidth * 86,
backgroundColor: '#008A6A',
flexDirection: 'row'
},
wbWrapper: {
backgroundColor: '#0E5C4A',
// background:'black',
width: Constants.height,
height: Constants.width - Constants.statusBarHeight - Constants.unitWidth * 40,
height: Constants.width - Constants.statusBarHeight - Constants.unitWidth * 0,
// height: Constants.width - Constants.statusBarHeight - Constants.unitWidth * s86,
// width: Constants.unitWidth * 400,
// height: Constants.unitWidth * 300,
position: 'absolute',
......@@ -415,7 +417,7 @@ let LiveCSS = StyleSheet.create({
top: Constants.unitWidth * 8,
},
toolbar: {
backgroundColor: '#0E5C4A',
// backgroundColor: '#0E5C4A',
flex: 1,
flexDirection: 'row',
alignItems: 'center',
......
......@@ -54,6 +54,8 @@ var LoginCSS = StyleSheet.create(
fontFamily: 'PingFangSC-Regular',
fontSize: Constants.baseFontSize * 0.933,
height: Constants.unitWidth * 36,
// backgroundColor:'red',
padding:0,
flex: 1,
color: '#333333'
},
......
......@@ -8095,6 +8095,11 @@
"nullthrows": "^1.1.1"
}
},
"react-native-device-info": {
"version": "9.0.2",
"resolved": "https://registry.npmmirror.com/react-native-device-info/-/react-native-device-info-9.0.2.tgz",
"integrity": "sha512-+IfYZ/OuKjnFf7SFfgIzEqynSeFngrIHc5KgHUIfXusLDXIFJ+LhRBCD7skqnraHrfmESUOMjLbNcvy4SVdwSA=="
},
"react-native-document-picker": {
"version": "8.1.0",
"resolved": "https://registry.npmmirror.com/react-native-document-picker/-/react-native-document-picker-8.1.0.tgz",
......
......@@ -175,17 +175,17 @@ export default class Login extends Component {
loginWithPassword = () => {
if (this.state.canSubmit) {
// alert(1)
// if (this.state.rememberPwd) {
// Constants.storeData('loginInfo', JSON.stringify({
// mobile: this.state.mobile,
// password: this.state.password
// }));
// } else {
// Constants.storeData('loginInfo', JSON.stringify({
// mobile: '',
// password: ''
// }));
// }
if (this.state.rememberPwd) {
Constants.storeData('loginInfo', JSON.stringify({
mobile: this.state.mobile,
password: this.state.password
}));
} else {
Constants.storeData('loginInfo', JSON.stringify({
mobile: '',
password: ''
}));
}
Constants.postJSON(Api.loginWithPassword({
userName: this.state.mobile,
password: md5(this.state.password),
......@@ -329,7 +329,7 @@ export default class Login extends Component {
</View>
{/* <Image source={require('../../images/common/jiantouba.png')} style={LoginCSS.jiantou}/> */}
<TextInput maxLength={11} allowFontScaling={false} keyboardType="phone-pad"
placeholderTextColor="#919191" placeholder="请输入手机号"
placeholderTextColor="#919191" placeholder="请输入号"
style={LoginCSS.mobile} onChangeText={(text) => {
this.setState({
mobile: text
......
......@@ -25,11 +25,11 @@ export default class Rush extends Component {
shouldComponentUpdate(nextProps, nextState){
// console.log('hello', nextProps, nextState);
if (this.state.max !== nextProps.rushMax || this.state.rushing !== nextProps.rushing) {
if ( this.state.rushing !== nextProps.rushing) {
this.setState({
max: nextProps.rushMax,
currentSec: nextProps.rushMax,
rushing: nextProps.rushing,
rushing: nextProps.rushing,
answerStu: nextProps.answerStu
});
if (this.timer) {
......
import React, { Component } from 'react';
import React, { Component ,useState, useEffect} from 'react';
import { View, Modal, FlatList, Text, Image, ScrollView, TextInput, TouchableHighlight, Linking, Alert } from 'react-native';
import Button from 'react-native-button';
import Constants from '../../../Constants';
......@@ -17,6 +17,55 @@ import ImageShow from '../imageShow'
let timeer;
import moment from 'moment';
let getStrTime = (totalTime, needHour) => {
// let totalTime = this.state.whoosh.getDuration();
totalTime = Math.ceil(totalTime);
let totalMin = parseInt(totalTime / 60); //总分钟数
let totalSec = totalTime - totalMin * 60; //秒钟数并判断前缀是否 + '0'
totalSec = totalSec > 9 ? totalSec : '0' + totalSec;
if (needHour) {
let hour = parseInt(totalTime / 3600);
totalMin = parseInt((totalTime - hour * 3600) / 60);
hour = hour > 9 ? hour : '0' + hour;
totalMin = totalMin > 9 ? totalMin : '0' + totalMin;
return hour + ':' + totalMin + ':' + totalSec;
}
return totalMin + ':' + totalSec
// this.setState({
// maximumValue: totalTime,
// })
}
function SurplusTime(state) {
const [count, setCount] = useState('00:00:00');
let d1 = new Date(moment(state.workDetailObj.closeTime).format()).getTime();
let d2 ;
useEffect(() => {
let id = setInterval(() => {
// console.log(state.workDetailObj,d1,Date.now(),d1 - Date.now())
// setCount((prevCount) => prevCount + 1); // <= here
d2 = Date.now()
if(d1 > d2 ){
setCount(getStrTime((d1 - d2) / 1000, true))
}else{
setCount('00:00:00')
}
}, 1000);
return () => clearInterval(id);
}, []);
return (
<View>
{state.workDetailObj.sepStatus != 70 &&
<Text style={{ textAlign: 'center', lineHeight: Constants.unitWidth * 40, }}>剩余时间:{count}</Text>
}
</View>
);
}
export default class Index extends Component {
constructor(props) {
......@@ -70,16 +119,16 @@ export default class Index extends Component {
console.log(this.state.workDetailObj.closeTime, d1, d2, 'newDate')
console.log(moment(this.state.workDetailObj.closeTime).format(), 'moment')
if (d1 > d2 && this.state.workDetailObj.sepStatus != 70) {
timeer = setInterval(e => {
this.setState({
surplusTimeStr: this.getStrTime((d1 - Date.now()) / 1000)
})
// this.getStrTime(d1 - d2)
}, 1000)
// timeer = setInterval(e => {
// this.setState({
// surplusTimeStr: this.getStrTime((d1 - Date.now()) / 1000, true)
// })
// // this.getStrTime(d1 - d2)
// }, 1000)
} else {
clearInterval(timeer)
this.setState({
surplusTimeStr: this.getStrTime(0),
// surplusTimeStr: this.getStrTime(0),
canSubMit: false,
})
}
......@@ -124,7 +173,7 @@ export default class Index extends Component {
let detailLinkList = mediaList.filter(e => {
return e.mediaType == 5
})
this.setState({
detailAudioList,
detailImgList,
......@@ -308,18 +357,7 @@ export default class Index extends Component {
})
return res
}
getStrTime = (totalTime) => {
// let totalTime = this.state.whoosh.getDuration();
totalTime = Math.ceil(totalTime);
let totalMin = parseInt(totalTime / 60); //总分钟数
let totalSec = totalTime - totalMin * 60; //秒钟数并判断前缀是否 + '0'
totalSec = totalSec > 9 ? totalSec : '0' + totalSec;
return totalMin + ':' + totalSec
// this.setState({
// maximumValue: totalTime,
// })
}
// 请求录音授权
getAudioAuthorize() {
AudioRecorder.requestAuthorization()
......@@ -411,20 +449,30 @@ export default class Index extends Component {
}
uploadAudio = () => {
let downloadDest = 'file://' + this.state.audioPath
// let pathList = this.state.audioPath
Constants.uploadFile(Api.uploadFile({
file: downloadDest,
folder: 'student',
name: 'acc'
name: `quick_audio_${new Date().getTime()}.aac`,
})).then((response) => {
return response.json()
}).then(data => {
console.log('save uploadAudio', JSON.stringify(data));
// setTimeout(() => {
// this.setState({
// webViewBoard:false
// })
// });
let AudioList = this.state.pushAudioList
data.data.fileList.forEach(item => {
AudioList.push({
mediaUrl: data.data.domain + item.key,
fileSize: item.fileSize,
title: item.fileName,
// 媒体类型 1:图片 2:语音 3:视频 4:文件
mediaType: 2
})
})
this.setState({
pushAudioList: AudioList,
showActionSheet: false
})
}).catch(error => {
console.log('save image error', error)
});
......@@ -528,7 +576,10 @@ export default class Index extends Component {
}
};
submitHomeWork = () => {
if (!this.state.note) return;
if (!this.state.note) {
Alert.alert('请输入回答')
return
};
console.log(
{
sepId: this.state.sepId,
......@@ -570,7 +621,7 @@ export default class Index extends Component {
{!!this.state.workDetailObj &&
<View>
<View style={homeWork.downTime}>
<Text style={{ textAlign: 'center', lineHeight: Constants.unitWidth * 40, }}>剩余时间:{this.state.surplusTimeStr}</Text>
<SurplusTime workDetailObj= {this.state.workDetailObj}></SurplusTime>
</View>
<View style={homeWork.taskMainWarp}>
<View style={homeWork.taskMain}>
......@@ -708,7 +759,7 @@ export default class Index extends Component {
</ScrollView>
</View>{
this.state.canSubMit &&
<View style={{ paddingTop: 10, display: 'flex', flexDirection: 'row', }}>
<View style={{ display: 'flex', flexDirection: 'row', height: Constants.unitWidth * 50, alignItems:'center',justifyContent:'center', }}>
<View style={{ width: '50%', height: Constants.unitWidth * 40, display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<View style={{ height: Constants.unitWidth * 30, width: Constants.unitWidth * 30, marginLeft: 30 }}>
<Button onPress={() => {
......@@ -750,8 +801,11 @@ export default class Index extends Component {
</View>
</View>
<RNModal transparent={true}
statusBarTranslucent={true}
animationType="slide"
visible={this.state.showActionSheet}
onRequestClose={() => this.setState({ showActionSheet: false })}
onBackdropPress={() => { alert(1) }}
style={{
margin: 0, alignItems: 'center',
justifyContent: 'center',
......@@ -759,7 +813,7 @@ export default class Index extends Component {
>
<TouchableHighlight
style={{
backgroundColor: 'rgba(0, 0, 0, 0.5)',
backgroundColor: 'rgba(0, 0, 0, 0.4)',
width: Constants.height,
height: Constants.width,
display: 'flex',
......@@ -771,20 +825,21 @@ export default class Index extends Component {
showActionSheet: false
})
}}
underlayColor="rgba(255, 255, 255, 0)"
underlayColor="rgba(0, 0, 0, 0.4)"
>
<View style={{
width: Constants.unitWidth * 424,
height: Constants.unitWidth * 312,
backgroundColor: '#ffffff',
position:'relative',
zIndex:10,
}} >
{!this.state.recording && !this.state.stop &&
<View style={{
height: Constants.unitWidth * 312, justifyContent: 'space-around',
alignItems: 'center'
}}>
<Text>{this.getStrTime(this.state.currentTime)} / {this.getStrTime(this.state.maxcurrentTime)}</Text>
<Text>{getStrTime(this.state.currentTime)} / {getStrTime(this.state.maxcurrentTime)}</Text>
<Button onPress={() => {
this.getAudioAuthorize()
......@@ -800,7 +855,7 @@ export default class Index extends Component {
height: Constants.unitWidth * 312, justifyContent: 'space-around',
alignItems: 'center'
}}>
<Text>{this.getStrTime(this.state.currentTime)} / {this.getStrTime(this.state.maxcurrentTime)}</Text>
<Text>{getStrTime(this.state.currentTime)} / {getStrTime(this.state.maxcurrentTime)}</Text>
<Button onPress={() => {
this.handleStopAudio()
}}>
......
......@@ -7,6 +7,7 @@ import homeWork from '../../../css/homework.css';
import Api from '../../../Api';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import moment from 'moment';
export default class Index extends Component {
......@@ -59,6 +60,9 @@ export default class Index extends Component {
// })
}
componentWillUnmount() {
Picker.hide()
}
pinkeState = () => {
Picker.isPickerShow(status => {
if (status) {
......@@ -185,11 +189,6 @@ export default class Index extends Component {
});
}
componentWillUnmount() {
// this.setState({
// uri:false,
// })
}
getListHomework = () => {
Constants.postJSONWithToken(Api.studentListHomework(this.state.par))
.then((response) => {
......@@ -209,7 +208,6 @@ export default class Index extends Component {
})
}
}
console.log(this.listHomework)
// if (data.memo === '成功') {
// this.setState(data.data);
// setTimeout(this.init, 100);
......@@ -230,6 +228,14 @@ export default class Index extends Component {
return '题库堂测'
}
}
compareTime(time){
let d1 = new Date(moment(time).format()).getTime()
let d2 = Date.now()
if(d1 > d2){
return true
}
return false
}
sepStatus(type) {
let day;
switch (type) {
......@@ -280,7 +286,7 @@ export default class Index extends Component {
<Text style={{ lineHeight: Constants.unitWidth * 32 }}>提交截止时间:{item.closeTime}</Text>
</View>
</View>
{(item.sepStatus == 20 || item.sepStatus == 10 || item.sepStatus == 30 || item.sepStatus == 60 || item.sepStatus == 25 || item.sepStatus == 50 || item.sepStatus == 70) &&
{this.compareTime(item.closeTime) && (item.sepStatus == 20 || item.sepStatus == 10 || item.sepStatus == 30 || item.sepStatus == 60 || item.sepStatus == 25 || item.sepStatus == 50 || item.sepStatus == 70) &&
<View style={homeWork.taskListBtn}>
<Button onPress={() => {
this.props.navigation.navigate('doHomeworkWithImg', {
......@@ -327,7 +333,7 @@ export default class Index extends Component {
})
}
}} value={this.state.note}
multiline={true} placeholder="请输入作业关键字" placeholderTextColor="#727272" />
placeholder="请输入作业关键字" placeholderTextColor="#727272" />
<Button onPress={() => { this.getListHomework() }} >
<Icon name="text-search" size={30} color="#333333" />
</Button>
......
import React, { Component } from 'react';
import {
Image, View, Text, StatusBar, TextInput, ActionSheetIOS, Keyboard, FlatList, Modal, Platform, Animated,
DeviceEventEmitter, ScrollView, ImageBackground, TouchableHighlight, NativeEventEmitter, NativeModules
DeviceEventEmitter, ScrollView, ImageBackground, TouchableHighlight, NativeEventEmitter, NativeModules,
PermissionsAndroid
} from 'react-native';
import DeviceInfo from 'react-native-device-info';
import { WebView } from 'react-native-webview';
import CameraRoll from "@react-native-community/cameraroll";
......@@ -40,10 +44,7 @@ import Rush from '../components/Rush';
import ImagePicker from 'react-native-image-crop-picker';
import IdleTimerManager from 'react-native-idle-timer';
import Switch from 'react-native-switch-pro';
const movingWidth = Constants.height;
const movingHeight = Constants.width - Constants.statusBarHeight - Constants.unitWidth * 104;
const movingInitX = Constants.height * 0.5 - Constants.unitWidth * 75;
const movingInitY = (Constants.width - Constants.statusBarHeight - Constants.unitWidth * 124) * 0.5 - Constants.unitWidth * 43;
import { KeyboardAccessoryView } from 'react-native-keyboard-accessory';
import CourseCSS from "../../css/Course.css";
......@@ -77,8 +78,22 @@ import AddNote from "../components/AddNote";
import EditNote from "../components/EditNote";
// import { RNLockScreen } from 'react-native-lock-screen';
let webViewUrl = (Platform.OS === 'android' ? 'file:///android_asset/' : '') + `Static.bundle/dd.html`;
let webViewUrl = (Platform.OS === 'android' ? 'file:///android_asset/' : '') + `Static.bundle/dd.html`;
webViewUrl = `file:///android_asset/Static.bundle/index.html`
let model = DeviceInfo.getModel();
const isFhPad = model.indexOf('BZC-W00') > -1 ;
// alert(isFhPad + model)
const movingWidth = Constants.height;
let movingHeight = Constants.width - Constants.statusBarHeight - Constants.unitWidth * 60;
const movingInitX = Constants.height * 0.5 - Constants.unitWidth * 75;
const movingInitY = (Constants.width - Constants.statusBarHeight - Constants.unitWidth * 124) * 0.5 - Constants.unitWidth * 43;
if(!isFhPad){
movingHeight = Constants.width - Constants.statusBarHeight - Constants.unitWidth * 146;
}
export default class Index extends Component<Props, State, HomeState, AppContextType> {
_engine?: RtcEngine;
......@@ -98,6 +113,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
channelId: '',
joinSucceed: false,
peerIds: [],
videoIds:[],
movingIds: [],
movingPositions: [],
movingSizes: [],
......@@ -189,7 +205,8 @@ export default class Index extends Component<Props, State, HomeState, AppContext
showLook: false,
group: '',
webViewBoard: false,
permissionsAndroid:false,
};
this.msgList = null;
this.timer = null;
......@@ -217,9 +234,36 @@ export default class Index extends Component<Props, State, HomeState, AppContext
componentDidUpdate() {
}
requestCameraAndAudioPermission = async () => {
try {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
])
if (
granted['android.permission.RECORD_AUDIO'] === PermissionsAndroid.RESULTS.GRANTED
&& granted['android.permission.CAMERA'] === PermissionsAndroid.RESULTS.GRANTED
) {
console.log('You can use the cameras & mic');
this.setState({
permissionsAndroid: true
});
this.startCall();
} else {
console.log('Permission denied')
this.props.navigation.goBack();
}
} catch (err) {
console.warn(err)
}
}
componentDidMount() {
StatusBar.setBarStyle('light-content');
// console.log(DeviceInfo)
// const model = DeviceInfo.getModel()
// alert(model)
// const whBoard = new NativeEventEmitter(NativeModules.TICBridgeManager);
WhiteBoardEngine.addListener('joinRoomSuccess', (data) => {
console.log('joinRoomSuccess', data);
......@@ -245,6 +289,9 @@ export default class Index extends Component<Props, State, HomeState, AppContext
teacherUid = this.props.route.params.teachers[0].liveRoomUid;
teacherName = this.props.route.params.teachers[0].tchName;
}
// alert(teacherUid)
// alert(teacherName)
this.props.route.params.teacherUid = teacherUid;
this.props.route.params.teacherName = teacherName;
this.setState(this.props.route.params);
......@@ -330,7 +377,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
console.log(res, '保存成功')
Constants.uploadFile(Api.uploadFile({
file: downloadDest,
folder:'lesson',
folder: 'lesson',
})).then((response) => {
return response.json()
}).then(data => {
......@@ -343,13 +390,13 @@ export default class Index extends Component<Props, State, HomeState, AppContext
uid: this.state.liveRoomUid,
stuId: this.props.route.params.stuScheduleId,
time: timestamp,
boardUrl:data.data.domain + data.data.fileList[0].key
boardUrl: data.data.domain + data.data.fileList[0].key
})
})
setTimeout(() => {
this.setState({
webViewBoard:false
})
this.setState({
webViewBoard: false
})
});
}).catch(error => {
console.log('save image error', error)
......@@ -373,7 +420,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
uploadScreenShot = (uri) => {
Constants.uploadFile(Api.uploadFile({
file: uri,
folder:'lesson',
folder: 'lesson',
})).then((response) => {
return response.json()
})
......@@ -460,7 +507,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
clearTimeout(this.timer);
}
this.context.client.removeAllListeners()
// await this.context.client.leave(this.state.channelId);
await this.context.client.leave(this.state.channelId);
this.sendLessonActivityInOut('out')
await this.logout();
......@@ -473,7 +520,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
// console.log('leave room ok', e);
// WhiteBoardEngine.unInitEngine().then(() => {});
});
// await this.endCall();
await this.endCall();
}
getAgoraConfig = () => {
......@@ -514,22 +561,66 @@ export default class Index extends Component<Props, State, HomeState, AppContext
this.getNetlessToken();
// this.getRTMToken();
});
// this.startCall();
return;
// return;
if (!isFhPad) {
this.requestCameraAndAudioPermission();
return
}
this.getRTMToken();
// if (isFhPad) return;
// this.checkConnection();
//
// console.log('this._engine', this._engine);
// this.joinRTCChannel();
};
checkConnection = () => {
console.log('checkConnection');
if (this.state.joinSucceed) {
this._engine.startLastmileProbeTest({
probeUplink: true,
probeDownlink: true,
expectedUplinkBitrate: 1000001,
expectedDownlinkBitrate: 1000001,
}).then((e, e2) => {
console.log(e, e2, 'ok22222');
}).catch((e) => {
console.log(e, 'rejected')
})
}
setTimeout(this.checkConnection, 3000);
}
/**
* @name startCall
* @description Function to start the call
*/
startCall = async () => {
const { appId } = this.state;
console.log('appid = ', appId);
this._engine = await RtcEngine.create(appId);
await this._engine.enableVideo();
// this._engine.addListener('Warning', (warn) => {
// console.log('Warning', warn);
// });
this._engine.addListener('Warning', (warn) => {
console.log('Warning', warn);
});
// this._engine.addListener('Error', (err) => {
// console.log('Error2222', err);
// });
this._engine.addListener('Error', (err) => {
console.log('Error2222', err);
});
this._engine.addListener('LocalAudioStateChanged', (err) => {
console.log('LocalAudioStateChanged', err);
});
await this._engine.enableVideo();
await this._engine.startPreview();
this._engine.addListener('UserJoined', (uid, elapsed) => {
console.log('UserJoined--000000', uid, elapsed);
......@@ -542,6 +633,16 @@ export default class Index extends Component<Props, State, HomeState, AppContext
peerIds: [...peerIds, uid],
});
}
const { videoIds } = this.state;
// If new user
if (videoIds.indexOf(uid) === -1) {
this.setState({
// Add peer ID to state array
videoIds: [...videoIds, uid],
});
}
});
this._engine.addListener('UserOffline', (uid, reason) => {
......@@ -551,11 +652,16 @@ export default class Index extends Component<Props, State, HomeState, AppContext
// Remove peer ID from state array
peerIds: peerIds.filter((id) => id !== uid),
});
const { videoIds } = this.state;
this.setState({
// Remove peer ID from state array
videoIds: videoIds.filter((id) => id !== uid),
});
});
// If Local user joins RTC channel
this._engine.addListener('JoinChannelSuccess', (channel, uid, elapsed) => {
// console.log('JoinChannelSuccess', channel, uid, elapsed);
console.log('JoinChannelSuccess', channel, uid, elapsed);
// 加入直播成功 把 自己的视频视图加入到videoList
const { peerIds } = this.state;
if (peerIds.indexOf(uid) === -1) {
......@@ -565,6 +671,15 @@ export default class Index extends Component<Props, State, HomeState, AppContext
// movingIds: [uid], //测试
});
}
const { videoIds } = this.state;
if (videoIds.indexOf(uid) === -1) {
this.setState({
joinSucceed: true,
videoIds: [...videoIds, uid],
// movingIds: [uid], //测试
});
}
});
this._engine.addListener('NetworkQuality', (uid, data) => {
......@@ -602,38 +717,6 @@ export default class Index extends Component<Props, State, HomeState, AppContext
this.setState(stats);
});
// this.checkConnection();
//
// console.log('this._engine', this._engine);
// this.joinRTCChannel();
};
checkConnection = () => {
console.log('checkConnection');
if (this.state.joinSucceed) {
this._engine.startLastmileProbeTest({
probeUplink: true,
probeDownlink: true,
expectedUplinkBitrate: 1000001,
expectedDownlinkBitrate: 1000001,
}).then((e, e2) => {
console.log(e, e2, 'ok22222');
}).catch((e) => {
console.log(e, 'rejected')
})
}
setTimeout(this.checkConnection, 3000);
}
/**
* @name startCall
* @description Function to start the call
*/
startCall = () => {
Constants.get(Api.getRTCToken({
channelId: this.state.channelId,
userId: this.state.liveRoomUid
......@@ -668,7 +751,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
null,
parseInt(this.state.liveRoomUid)
).then((data) => {
// console.log('start call hahah', data);
console.log('start call hahah', data);
this.getRTMToken();
}).catch((err) => {
console.log('start call errro 22 ', err)
......@@ -680,8 +763,9 @@ export default class Index extends Component<Props, State, HomeState, AppContext
* @description Function to end the call
*/
endCall = async () => {
await this._engine?.removeAllListeners();
await this._engine?.leaveChannel();
this.setState({ peerIds: [], joinSucceed: false });
this.setState({ peerIds: [],videoIds:[], joinSucceed: false });
};
sendLessonActivityInOut = async (type) => {
await Constants.postJSONWithToken(Api.sendLessonActivityInOut({
......@@ -731,7 +815,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
rtmToken: data.data,
gettingRTMToken: false
});
setTimeout(this.rtmLogin, 100);
setTimeout(this.rtmLogin);
}
})
.catch(error => {
......@@ -878,6 +962,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}
if ('closeLocalVideo' in value) {
if(isFhPad) return;
let closeVideos = this.state.closeVideos;
if (value.closeLocalVideo) {
//关闭 视频
......@@ -924,7 +1009,8 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}
} else if (item.key === "AAAGroupState") {
let value = JSON.parse(item.value)
if (value.gpList && value.gpList.length && !this.state.group) {
console.log(value,'AAAGroupStateAAAGroupState')
if (value.gpList && value.gpList.length) {
let gp = '';
value.gpList.forEach((item, index) => {
item.gpStu.forEach(stu => {
......@@ -934,7 +1020,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}
})
});
if (gp) {
if (gp && gp.gpName != this.state.group.gpName) {
this.setState({
group: gp,
// canEditWB: true,
......@@ -943,12 +1029,17 @@ export default class Index extends Component<Props, State, HomeState, AppContext
tipsIcon: require('../../images/common/success.png')
});
}
}else{
this.setState({
group:'',
})
}
} else if (item.key === "muteUser") {
if(isFhPad) return;
let value = JSON.parse(item.value);
if (value.includes(parseInt(this.state.liveRoomUid))) {
if (!this.state.microphoneDisabled) {
this._engine.enableLocalAudio(false).then((result) => {
this._engine?.muteLocalAudioStream (true).then((result) => {
console.log('disableLocalAudio 001 ok', result);
this.setState({
microphoneDisabled: true,
......@@ -965,7 +1056,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}
} else {
if (this.state.microphoneDisabled) {
this._engine.enableLocalAudio(true).then((result) => {
this._engine?.muteLocalAudioStream (false).then((result) => {
// console.log('enableLocalAudio 001 ok', result);
this.setState({
microphoneDisabled: false,
......@@ -1051,9 +1142,9 @@ export default class Index extends Component<Props, State, HomeState, AppContext
// selectedIndex = (value.rand) % students.length;
// console.log(selectedIndex, 'selectedIndex')
// }
// console.log('randomStuState', students, selectedIndex, value);
console.log('randomStuStateSS', students, value);
this.setState({
showRandom: value.showModules,
showRandom: (value.showModules && !!value.selNumList.length) ,
selNum: value.selNum,
selScope: value.selScope,
// isAnstype: value.isAnstype,
......@@ -1068,14 +1159,17 @@ export default class Index extends Component<Props, State, HomeState, AppContext
this.setState({
webViewBoard: 'randomBoard'
});
}, 300);
}, 200);
// console.log(
// `http://192.168.0.102:8082?token=${Constants.token}&type=${this.state.webViewBoard}&host=${Api.uploadFile().host}`
// )
} else {
this.setState({
webViewBoard: false
});
if(this.state.webViewBoard == 'randomBoard'){
this.setState({
webViewBoard: false
});
}
}
} else if (item.key === "rushToAnswerState") {
// 抢答器
......@@ -1118,17 +1212,19 @@ export default class Index extends Component<Props, State, HomeState, AppContext
this.setState({
webViewBoard: 'rushBoard'
});
}, 300);
}, 200);
} else {
this.setState({
webViewBoard: false
});
if(this.state.webViewBoard == 'rushBoard'){
this.setState({
webViewBoard: false
});
}
}
} else if (item.key === "AnswerState") {
let value = JSON.parse(item.value);
console.log('AnswerState', value);
// alert(this.state.group.index)
if (this.state.group && value.selScope.length && value.selScope.indexOf (this.state.group.index) == -1 ) {
if (this.state.group && value.selScope.length && value.selScope.indexOf(this.state.group.index) == -1) {
value.showModules = false
}
let _times = value.timeString.split(':');
......@@ -1562,7 +1658,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
this.setState({
showNetless: true
});
this.getRTMToken();
// this.getRTMToken();
setTimeout(() => {
//加入白板成功
// WhiteBoardEngine.setViewMode('follower');
......@@ -1578,11 +1674,12 @@ export default class Index extends Component<Props, State, HomeState, AppContext
_renderVideos = () => {
// console.log('uids2222', this.state.peerIds, this.state.channelId);
if(!this.state.permissionsAndroid) return [];
let result = [];
/*1 先获取 老师*/
for (let i = 0; i < this.state.peerIds.length; i++) {
if (parseInt(this.state.peerIds[i]) === parseInt(this.state.teacherUid) && !this.state.movingIds.includes(parseInt(this.state.teacherUid))) {
result.push(<ImageBackground imageStyle={LiveCSS.videoBg} source={require('../../images/common/camera.png')} style={LiveCSS.myVideoWrapper}>
for (let i = 0; i < this.state.videoIds.length; i++) {
if (parseInt(this.state.videoIds[i]) === parseInt(this.state.teacherUid) && !this.state.movingIds.includes(parseInt(this.state.teacherUid))) {
result.push(<ImageBackground key={this.state.teacherUid} imageStyle={LiveCSS.videoBg} source={require('../../images/common/camera.png')} style={LiveCSS.myVideoWrapper}>
<RtcRemoteView.SurfaceView
style={LiveCSS.max}
uid={parseInt(this.state.teacherUid)}
......@@ -1595,7 +1692,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
<View style={LiveCSS.videoInfoRight}>
</View>
</View>
{this.state.closeVideos.includes(String(this.state.peerIds[i])) && <View style={{
{this.state.closeVideos.includes(String(this.state.videoIds[i])) && <View style={{
position: 'absolute',
width: Constants.unitWidth * 150,
height: Constants.unitWidth * 86,
......@@ -1613,7 +1710,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}
}
/*2 在获取学生*/
this.state.peerIds.map((item, index) => {
this.state.videoIds.map((item, index) => {
// console.log(item, index, this.state.liveRoomUid, parseInt(this.state.liveRoomUid) === parseInt(item));
// console.log('attributesUpdated moveingids', item, this.state.movingIds, this.state.movingIds.includes(item));
if (parseInt(item) !== parseInt(this.state.teacherUid) && !this.state.movingIds.includes(item)) {
......@@ -1626,7 +1723,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}
}
if (parseInt(this.state.liveRoomUid) === parseInt(item)) {
result.push(<ImageBackground key={index} imageStyle={LiveCSS.videoBg} source={require('../../images/common/camera.png')} style={LiveCSS.myVideoWrapper}>
result.push(<ImageBackground key={parseInt(item)} imageStyle={LiveCSS.videoBg} source={require('../../images/common/camera.png')} style={LiveCSS.myVideoWrapper}>
{this.state.videoEnabled && <RtcLocalView.SurfaceView
style={LiveCSS.max}
uid={item}
......@@ -1656,7 +1753,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
</View>}
</ImageBackground>)
} else {
result.push(<ImageBackground key={index} imageStyle={LiveCSS.videoBg} source={require('../../images/common/camera.png')} style={LiveCSS.myVideoWrapper}>
result.push(<ImageBackground key={parseInt(item)} imageStyle={LiveCSS.videoBg} source={require('../../images/common/camera.png')} style={LiveCSS.myVideoWrapper}>
<RtcRemoteView.SurfaceView
style={LiveCSS.max}
uid={item}
......@@ -2096,7 +2193,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}
toggleSwitchVideo = () => {
this._engine.enableLocalVideo(!this.state.videoEnabled);
this._engine?.enableLocalVideo(!this.state.videoEnabled);
this.setState({
videoEnabled: !this.state.videoEnabled
})
......@@ -2203,7 +2300,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}]}>
<StatusBar
hidden={false}
backgroundColor="#0E5C4A"
backgroundColor="#30323D"
barStyle="light-content"
/>
<View style={{
......@@ -2225,9 +2322,9 @@ export default class Index extends Component<Props, State, HomeState, AppContext
width: Constants.height,
height: Constants.width - Constants.statusBarHeight,
}}>
<View style={LiveCSS.headerRow}>
{/* <View style={LiveCSS.headerRow}>
<View style={LiveCSS.headerRowLeft}>
{/* {this.getSignal()} */}
{this.getSignal()}
</View>
<View style={{
flex: 1,
......@@ -2235,21 +2332,26 @@ export default class Index extends Component<Props, State, HomeState, AppContext
justifyContent: 'center',
}}>
<Text allowFontScaling={false} style={LiveCSS.courseTitle}>{this.state.courseName}</Text>
{/* <View style={LiveCSS.courseTitleRight}>
<View style={LiveCSS.courseTitleRight}>
<View style={LiveCSS.courseTitleRight1}></View>
<Text allowFontScaling={false} style={LiveCSS.courseTitleRight2}>上课中:{this.getFormattedDuration()}</Text>
</View> */}
</View>
</View>
</View>
<View style={[LiveCSS.videoRow, PublicCSS.centerAll]}>
{/* {this._renderVideos()} */}
</View>
</View> */}
{
!isFhPad &&
<View style={[LiveCSS.videoRow, PublicCSS.centerAll]}>
{this._renderVideos()}
</View>
}
<View style={{
flexDirection: 'row',
width: movingWidth,
height: movingHeight,
position: 'relative',
backgroundColor: '#0E5C4A'
backgroundColor: '#0E5C4A',
warp: 'renderMovingVideo',
}}>
{/*{this.renderMovingVideo()}*/}
{
......@@ -2358,8 +2460,8 @@ export default class Index extends Component<Props, State, HomeState, AppContext
{
this.state.showNetless && <RCTTICBridgeView styleBox={[LiveCSS.wbWrapper, {
display: this.state.showNetless2 ? 'flex' : 'none',
zIndex: this.state.canEditWB && this.state.wbTool !== '' ? 100 : -1
}]} />
zIndex: this.state.canEditWB && this.state.wbTool !== '' ? 100 : -1,
},!isFhPad?{height:Constants.width - Constants.statusBarHeight - Constants.unitWidth * 86}:'']} />
}
......@@ -2996,7 +3098,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
{
this.state.showAlarm && <Alarm max={this.state.max} start={this.state.start} />
}
{this.state.showRandom && <Random uid={this.state.liveRoomUid} selNumList={this.state.selNumList} random={this.state.random} students={this.state.students} selectedIndex={this.state.selectedIndex} randNum={this.state.randNum} />}
{this.state.showRandom && <Random uid={this.state.liveRoomUid} selNumList={this.state.selNumList} random={this.state.random} students={this.state.students} selectedIndex={this.state.selectedIndex} randNum={this.state.randNum} />}
{this.state.showRush && <Rush rushing={this.state.rushing} rushMax={this.state.rushMax} answerStu={this.state.answerStu} />}
{this.state.showQA && <QA max={this.state.qaMax} currentMax={this.state.qaCurrentSec} answerState={this.state.answerState}
selectButton={this.state.selectButton} answerList={this.state.answerList}
......@@ -3086,18 +3188,18 @@ export default class Index extends Component<Props, State, HomeState, AppContext
const { nativeEvent } = syntheticEvent;
console.log('onLoadEnd error: ', nativeEvent);
// this.isLoading = nativeEvent.loading;
}}
onHttpError={(syntheticEvent) => {
}}
onHttpError={(syntheticEvent) => {
const { nativeEvent } = syntheticEvent;
console.warn(
'WebView received error status code: ',
nativeEvent.statusCode,
'WebView received error status code: ',
nativeEvent.statusCode,
);
}}
}}
onError={(syntheticEvent) => {
const { nativeEvent } = syntheticEvent;
console.warn('WebView error: ', nativeEvent);
}}
}}
// onLoad={this.onLoad}
// renderError={(e) => {
// if (e === 'WebKitErrorDomain') {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment