Commit 036cb24e authored by liujiaxin's avatar liujiaxin

教师位置挪到第一位

parent 70b53f47
......@@ -38,10 +38,17 @@ const useStyles = makeStyles({
const CourseWareFrame: React.FC = () => {
const classes = useStyles();
// `${ENDPOINT}/airclass_ol?token=${this.userToken}`;
const src = endPoint.getCourseUrl();
let src = endPoint.getCourseUrl();
useEffect(() => {
return () => {
src = 'about:blank'
console.log('iframe to blank');
}
}, []);
return (
<div className={classes.style1}>
<iframe src={src} className={classes.frm}></iframe>
<iframe id="cwFrame" src={src} className={classes.frm}></iframe>
</div>
)
}
......
......@@ -371,7 +371,30 @@ const items = [
useEffect(() => {
if (!rtmState.joined) return;
// debugger
if (!lock.current && !whiteboard.state.room) {
console.log('do join whiteboard room');
lock.current = true;
whiteboard.join({
rid: roomStore.state.course.rid,
uid: roomStore.state.course.boardId, // me.boardId,
userPayload: {
userId: roomStore.state.me.uid,
identity: roomStore.state.me.role === 'teacher' ? 'host' : 'guest'
}
})
.then(() => {
console.log("join whiteboard success");
}).catch(console.warn)
.finally(() => {
lock.current = false;
})
}
/*
if (!lock.current && !whiteboard.state.room) {
console.log('do join whiteboard room');
lock.current = true;
whiteboard.join({
rid: roomStore.state.course.rid,
......@@ -391,6 +414,7 @@ const items = [
if (!lock.current && course.boardId && me.boardId !== course.boardId && whiteboard.state.room) {
lock.current = true;
console.log('do rejoin whiteboard room');
whiteboard.join({
rid: roomStore.state.course.rid,
uid: course.boardId,
......@@ -406,7 +430,7 @@ const items = [
lock.current = false;
})
}
*/
}, [rtmState.joined, me.boardId, course.boardId]);
const [uploadPhase, updateUploadPhase] = useState<string>('');
......
......@@ -179,11 +179,7 @@ useEffect(() => {
}
if (stream.isPlaying()) {
// debugger
try{
stream.stop();
} catch (e) {
// console.log(e);
}
// stream.stop();
}
local && stream && stream.close();
......
......@@ -165,7 +165,8 @@ export const RootProvider: React.FC<any> = ({children}) => {
useEffect(() => {
if (location.pathname === '/') {
GlobalStorage.clear('agora_room');
// alert('clear1')
// GlobalStorage.clear('agora_room');
return;
}
const room = value.roomState;
......
......@@ -158,12 +158,15 @@ export default function useStream () {
const uid = studentIds.find((it: number) => `${ouid}` == `${it}`);
if (uid) {
sids.push(uid);
roomStore.releaseWaitStreamHandle(+uid);
} else {
// find in channel
const usr = userAttrs.get(`${ouid}`)
console.log('channel has ', ouid, usr)
if (usr) {
sids.push(-usr.uid/*+usr.uid*/);
sids.push(-usr.uid);
console.log('add waiting handle', usr.uid)
roomStore.lockWaitStreamHandle(+usr.uid);
} else {
// sids.push(-1);
sids[orderIdx] = 0;
......@@ -190,7 +193,7 @@ export default function useStream () {
// capture all remote streams
for (let studentId of /*studentIds*/sids) {
console.log('*****************', studentId)
// console.log('*****************', studentId)
if (studentId == undefined) {
continue
......
......@@ -158,7 +158,7 @@ export function RoomPage({ children }: any) {
}, [me.role, location.pathname, course.linkId]);
useEffect(() => {
useEffect( () => {
const webClient = roomStore.rtcClient as AgoraWebClient;
if (!rtcJoined) {
webClient.unpublishLocalStream()
......@@ -167,35 +167,43 @@ export function RoomPage({ children }: any) {
if (!rtcJoined || rtc.current) return;
if (platform === 'web') {
// const webClient = roomStore.rtcClient as AgoraWebClient;
const uid = +roomStore.state.me.uid as number;
const video = roomStore.state.studentsOrder.includes(uid) ? 1 : roomStore.state.me.video;
const audio = roomStore.state.studentsOrder.includes(uid) ? 1 : roomStore.state.me.audio;
const streamSpec: AgoraStreamSpec = {
streamID: uid,
video: !!video,
audio: !!audio,
mirror: false,
screen: false,
microphoneId: mediaDevice.microphoneId,
cameraId: mediaDevice.cameraId,
audioOutput: {
volume: mediaDevice.speakerVolume,
deviceId: mediaDevice.speakerId
roomStore.rtmClient.getChannelAttributeBy(roomStore.state.course.rid).then((channelMeta: any) => {
console.log('check user publish stream, channelMeta', channelMeta);
console.log('check user publish stream, user orders', roomStore.state.studentsOrder);
console.log('check user publish stream, user info', roomStore.state.me);
const studentsOrder = channelMeta.studentsOrder || roomStore.state.studentsOrder;
// const webClient = roomStore.rtcClient as AgoraWebClient;
const uid = +roomStore.state.me.uid as number;
const video = studentsOrder.includes(uid) ? 1 : roomStore.state.me.video;
const audio = studentsOrder.includes(uid) ? 1 : roomStore.state.me.audio;
const streamSpec: AgoraStreamSpec = {
streamID: uid,
video: !!video,
audio: !!audio,
mirror: false,
screen: false,
microphoneId: mediaDevice.microphoneId,
cameraId: mediaDevice.cameraId,
audioOutput: {
volume: mediaDevice.speakerVolume,
deviceId: mediaDevice.speakerId
}
}
}
console.log("canPb>>> ", canPublish, roomStore.state.course.linkId, roomStore.state.me.uid);
if (canPublish && !publishLock.current) {
publishLock.current = true;
webClient
.publishLocalStream(streamSpec)
.then(() => {
console.log("[agora-web] publish local stream", roomStore.state.me.uid);
}).catch(console.warn)
.finally(() => {
publishLock.current = false;
})
}
console.log("canPb>>> ", canPublish, roomStore.state.course.linkId, roomStore.state.me.uid);
if (canPublish && !publishLock.current) {
publishLock.current = true;
webClient
.publishLocalStream(streamSpec)
.then(() => {
console.log("[agora-web] publish local stream", roomStore.state.me.uid);
}).catch(console.warn)
.finally(() => {
publishLock.current = false;
})
}
});
}
if (platform === 'electron' && rtcJoined) {
......
This diff is collapsed.
......@@ -256,7 +256,7 @@ class Whiteboard extends EventEmitter {
...this.state,
scale: scale
}
this.commit(this.state);
}
......@@ -284,6 +284,8 @@ class Whiteboard extends EventEmitter {
}
async join({rid, uid, userPayload}: JoinParams) {
console.log(1111111)
console.log(GlobalStorage.read('agora_room'))
await this.leave();
const {uuid, roomToken} = await this.connect(rid, uid);
const identity = userPayload.identity === 'host' ? 'host' : 'guest';
......
......@@ -46,7 +46,7 @@ const clientEvents: string[] = [
export const APP_ID = process.env.REACT_APP_AGORA_APP_ID as string;
export const APP_TOKEN = process.env.REACT_APP_AGORA_APP_TOKEN as string;
export const ENABLE_LOG = process.env.REACT_APP_AGORA_LOG as string === "true";
export const SHARE_ID = 999;
export const SHARE_ID = 9999999999999;
class AgoraRTCClient {
......@@ -178,7 +178,7 @@ class AgoraRTCClient {
}
if (this._localStream ) {
if (this._localStream._enableBeauty) {
this._localStream.setBeautyEffectOptions(false);
// this._localStream.setBeautyEffectOptions(false);
this._localStream._enableBeauty = false
}
}
......@@ -205,12 +205,30 @@ class AgoraRTCClient {
createLocalStream(data: AgoraStreamSpec): Promise<any> {
this._localStream = AgoraRTC.createStream({...data, mirror: false});
this._localStream.setVideoEncoderConfiguration({
// 视频分辨率
resolution: {
width: 160,
height: 120
},
// 视频编码帧率。通常建议是 15 帧,不超过 30 帧
frameRate: {
min: 15,
max: 30
},
// 码率。一般情况下推荐使用标准码率
bitrate: {
min: 100,
max: 150
}
});
return new Promise((resolve, reject) => {
this._localStream.init(async () => {
this.streamID = data.streamID;
this.subscribeLocalStreamEvents();
// debugger
/*if (roomStore.state.me.role == 'teacher') {
/*
if (roomStore.state.me.role == 'teacher') {
const result = await this._localStream.setBeautyEffectOptions(true, {
lighteningContrastLevel: 2,
lighteningLevel: 0.9,
......@@ -221,7 +239,7 @@ class AgoraRTCClient {
// this._enableBeauty = true;
console.log('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%', result)
}*/
this.subscribeLocalStreamEvents();
if (data.audioOutput && data.audioOutput.deviceId) {
this.setAudioOutput(data.audioOutput.deviceId).then(() => {
resolve();
......
......@@ -3,7 +3,7 @@ export class CustomStorage {
private storage: Storage;
constructor() {
this.storage = window.sessionStorage;
this.storage = window.localStorage; // window.sessionStorage;
}
read(key: string): any {
......
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