Commit 036cb24e authored by liujiaxin's avatar liujiaxin

教师位置挪到第一位

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