Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
live
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liujiaxin
live
Commits
036cb24e
Commit
036cb24e
authored
Mar 12, 2020
by
liujiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
教师位置挪到第一位
parent
70b53f47
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
318 additions
and
140 deletions
+318
-140
courseware-frame.tsx
src/components/courseware-frame.tsx
+9
-2
mediaboard.tsx
src/components/mediaboard.tsx
+25
-1
video-player.tsx
src/components/video-player.tsx
+0
-4
root-container.tsx
src/containers/root-container.tsx
+2
-1
use-streams.ts
src/hooks/use-streams.ts
+5
-2
index.tsx
src/pages/classroom/index.tsx
+37
-29
room.ts
src/stores/room.ts
+213
-94
whiteboard.ts
src/stores/whiteboard.ts
+3
-1
agora-rtc-client.ts
src/utils/agora-rtc-client.ts
+23
-5
custom-storage.ts
src/utils/custom-storage.ts
+1
-1
No files found.
src/components/courseware-frame.tsx
View file @
036cb24e
...
@@ -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
>
)
)
}
}
...
...
src/components/mediaboard.tsx
View file @
036cb24e
...
@@ -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
>
(
''
);
...
...
src/components/video-player.tsx
View file @
036cb24e
...
@@ -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
();
...
...
src/containers/root-container.tsx
View file @
036cb24e
...
@@ -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
;
...
...
src/hooks/use-streams.ts
View file @
036cb24e
...
@@ -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
...
...
src/pages/classroom/index.tsx
View file @
036cb24e
...
@@ -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,10 +167,16 @@ export function RoomPage({ children }: any) {
...
@@ -167,10 +167,16 @@ export function RoomPage({ children }: any) {
if
(
!
rtcJoined
||
rtc
.
current
)
return
;
if
(
!
rtcJoined
||
rtc
.
current
)
return
;
if
(
platform
===
'
web
'
)
{
if
(
platform
===
'
web
'
)
{
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 webClient = roomStore.rtcClient as AgoraWebClient;
const
uid
=
+
roomStore
.
state
.
me
.
uid
as
number
;
const
uid
=
+
roomStore
.
state
.
me
.
uid
as
number
;
const
video
=
roomStore
.
state
.
studentsOrder
.
includes
(
uid
)
?
1
:
roomStore
.
state
.
me
.
video
;
const
video
=
studentsOrder
.
includes
(
uid
)
?
1
:
roomStore
.
state
.
me
.
video
;
const
audio
=
roomStore
.
state
.
studentsOrder
.
includes
(
uid
)
?
1
:
roomStore
.
state
.
me
.
audio
;
const
audio
=
studentsOrder
.
includes
(
uid
)
?
1
:
roomStore
.
state
.
me
.
audio
;
const
streamSpec
:
AgoraStreamSpec
=
{
const
streamSpec
:
AgoraStreamSpec
=
{
streamID
:
uid
,
streamID
:
uid
,
video
:
!!
video
,
video
:
!!
video
,
...
@@ -196,6 +202,8 @@ export function RoomPage({ children }: any) {
...
@@ -196,6 +202,8 @@ export function RoomPage({ children }: any) {
publishLock
.
current
=
false
;
publishLock
.
current
=
false
;
})
})
}
}
});
}
}
if
(
platform
===
'
electron
'
&&
rtcJoined
)
{
if
(
platform
===
'
electron
'
&&
rtcJoined
)
{
...
...
src/stores/room.ts
View file @
036cb24e
This diff is collapsed.
Click to expand it.
src/stores/whiteboard.ts
View file @
036cb24e
...
@@ -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
'
;
...
...
src/utils/agora-rtc-client.ts
View file @
036cb24e
...
@@ -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
=
999
9999999999
;
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
();
...
...
src/utils/custom-storage.ts
View file @
036cb24e
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment