Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gk-online-teacher
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
huanglu
gk-online-teacher
Commits
d2636bf8
Commit
d2636bf8
authored
Dec 16, 2020
by
刘阳
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://dev.jiuaoedu.com/huanglu/gk-online-teacher
# Conflicts: # src/utils/socket.js # src/views/home/index.vue # src/views/paint-screen/index.vue
parents
4ea699c8
776a6ce8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
40 deletions
+57
-40
hwrtc.js
src/utils/hwrtc.js
+13
-8
index.vue
src/views/big-screen/index.vue
+2
-2
index.vue
src/views/online/index.vue
+40
-28
yarn.lock
yarn.lock
+2
-2
No files found.
src/utils/hwrtc.js
View file @
d2636bf8
...
@@ -65,13 +65,13 @@ export default class HWOnline {
...
@@ -65,13 +65,13 @@ export default class HWOnline {
this
.
client
=
client
;
this
.
client
=
client
;
}
}
joinRoom
(
roomId
)
{
joinRoom
(
roomId
,
role
)
{
const
ctimeDst
=
7200000
const
ctimeDst
=
7200000
const
ctime
=
Math
.
floor
((
ctimeDst
+
new
Date
().
getTime
())
/
1000
).
toString
()
const
ctime
=
Math
.
floor
((
ctimeDst
+
new
Date
().
getTime
())
/
1000
).
toString
()
const
message
=
`
${
this
.
appId
}
+
${
roomId
}
+
${
this
.
userId
}
+
${
ctime
}
`
const
message
=
`
${
this
.
appId
}
+
${
roomId
}
+
${
this
.
userId
}
+
${
ctime
}
`
return
this
.
_joinRoom
(
roomId
,
{
return
this
.
_joinRoom
(
roomId
,
{
userId
:
this
.
userId
,
userId
:
this
.
userId
,
role
:
0
,
role
,
ctime
,
ctime
,
userName
:
`
${
this
.
userId
}
`
,
userName
:
`
${
this
.
userId
}
`
,
signature
:
CryptoJS
.
HmacSHA256
(
message
,
this
.
appId
).
toString
(),
signature
:
CryptoJS
.
HmacSHA256
(
message
,
this
.
appId
).
toString
(),
...
@@ -115,14 +115,19 @@ export default class HWOnline {
...
@@ -115,14 +115,19 @@ export default class HWOnline {
video
:
!!
cameraId
,
video
:
!!
cameraId
,
cameraId
,
cameraId
,
});
});
stream
.
setScreenProfile
({
// stream.setVideoProfile({
width
:
1920
,
// height: 1080,
height
:
1080
// width: 1980,
});
// // bitrate: 2400
// });
stream
.
setVideoProfile
(
'720p_1'
);
await
stream
.
initialize
()
await
stream
.
initialize
()
await
this
.
publish
(
stream
)
this
.
localStream
=
stream
;
this
.
localStream
=
stream
;
// stream.play(this.elId,{ muted: false, objectFit: 'contain' }) // 播放本地流
console
.
log
(
'local stream: '
,
stream
);
this
.
streams
.
push
(
stream
)
this
.
subscribedCb
(
this
.
streams
)
return
stream
return
stream
}
}
...
...
src/views/big-screen/index.vue
View file @
d2636bf8
...
@@ -23,10 +23,10 @@ export default {
...
@@ -23,10 +23,10 @@ export default {
async
mounted
()
{
async
mounted
()
{
const
{
userId
,
roomId
}
=
this
.
$route
.
query
const
{
userId
,
roomId
}
=
this
.
$route
.
query
this
.
rtc
=
new
HWRTC
(
userId
||
(
new
Date
().
getTime
()
/
1000
).
toFixed
(
0
));
this
.
rtc
=
new
HWRTC
(
userId
||
(
new
Date
().
getTime
()
/
1000
).
toFixed
(
0
));
await
this
.
rtc
.
joinRoom
(
roomId
)
await
this
.
rtc
.
joinRoom
(
roomId
,
2
)
this
.
rtc
.
subscribedStreamCb
((
streams
)
=>
{
this
.
rtc
.
subscribedStreamCb
((
streams
)
=>
{
console
.
log
(
'subscribedStreamCb: '
,
streams
)
console
.
log
(
'subscribedStreamCb: '
,
streams
)
const
stream
=
streams
.
reverse
().
find
((
itm
)
=>
itm
.
getUserId
().
includes
(
'teacher'
))
const
stream
=
streams
.
find
((
itm
)
=>
itm
.
getUserId
().
includes
(
'teacher'
))
if
(
stream
)
this
.
playStream
=
stream
;
if
(
stream
)
this
.
playStream
=
stream
;
})
})
}
}
...
...
src/views/online/index.vue
View file @
d2636bf8
<
template
>
<
template
>
<div
class=
"home"
>
<div
class=
"home"
>
<div
class=
"player"
>
<div
class=
"player"
>
<RtcPlayer
:stream=
"
local
Stream"
class=
"local-player"
/>
<RtcPlayer
:stream=
"
main
Stream"
class=
"local-player"
/>
<el-button
v-if=
"isJoin"
type=
"primary"
<el-button
v-if=
"isJoin"
type=
"primary"
@
click
.
native=
"fullPlayer"
class=
"full-screen"
>
全屏
</el-button>
@
click
.
native=
"fullPlayer"
class=
"full-screen"
>
全屏
</el-button>
</div>
</div>
...
@@ -38,9 +38,10 @@
...
@@ -38,9 +38,10 @@
<div
class=
"operation"
>
<div
class=
"operation"
>
<el-button
type=
"primary"
@
click=
"play"
>
加入房间
</el-button>
<el-button
type=
"primary"
@
click=
"play"
>
加入房间
</el-button>
</div>
</div>
</div>
<div
class=
"stream-pre"
>
<div
class=
"stream-pre"
>
<RtcPlayer
@
click=
"clickItm(itm)"
<RtcPlayer
class=
"item"
v-for=
"(itm, index) in streams"
:stream=
"itm"
:key=
"index"
/>
class=
"item"
v-for=
"(itm, index) in subStreams"
:stream=
"itm"
:key=
"index"
/>
</div>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
...
@@ -57,14 +58,15 @@ export default {
...
@@ -57,14 +58,15 @@ export default {
show
:
true
,
show
:
true
,
output
:
''
,
output
:
''
,
rtc
:
null
,
rtc
:
null
,
roomId
:
null
,
roomId
:
''
,
micro
:
[],
micro
:
[],
microId
:
'
123
'
,
microId
:
''
,
cameras
:
[],
cameras
:
[],
camerId
:
''
,
camerId
:
''
,
streams
:
[],
streams
:
[],
localStream
:
null
,
localStream
:
null
,
isJoin
:
false
isJoin
:
false
,
mainId
:
''
}
}
},
},
name
:
'Home'
,
name
:
'Home'
,
...
@@ -79,39 +81,51 @@ export default {
...
@@ -79,39 +81,51 @@ export default {
if
(
N
!==
O
&&
this
.
isJoin
)
this
.
localStream
.
switchDevice
(
'video'
,
N
);
if
(
N
!==
O
&&
this
.
isJoin
)
this
.
localStream
.
switchDevice
(
'video'
,
N
);
}
}
},
},
computed
:
{
subStreams
()
{
const
subs
=
(
this
.
streams
||
[]).
filter
((
itm
)
=>
itm
!==
this
.
mainStream
)
console
.
log
(
'subs: **** '
,
subs
)
return
subs
},
mainStream
()
{
const
main
=
(
this
.
streams
||
[]).
find
((
itm
)
=>
itm
.
getId
()
===
this
.
mainId
)
console
.
log
(
'main: **** '
,
main
)
return
main
}
},
methods
:
{
methods
:
{
async
play
()
{
async
play
()
{
try
{
try
{
await
this
.
rtc
.
joinRoom
(
this
.
roomId
)
await
this
.
rtc
.
joinRoom
(
`
${
this
.
roomId
}
`
,
0
)
this
.
localStream
=
await
this
.
rtc
.
createStream
(
this
.
microId
,
this
.
camerId
)
this
.
localStream
=
await
this
.
rtc
.
createStream
(
this
.
microId
,
this
.
camerId
)
// this.localStream.play('player', { muted: false, objectFit: 'contain' }
)
await
this
.
rtc
.
publish
(
this
.
localStream
)
this
.
isJoin
=
true
this
.
isJoin
=
true
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
'创建失败: '
,
error
)
console
.
log
(
'创建失败: '
,
error
)
}
}
},
},
join
()
{
this
.
rtc
.
joinRoom
(
this
.
roomId
)
},
fullPlayer
()
{
fullPlayer
()
{
console
.
log
(
'full'
)
console
.
log
(
'full'
)
document
.
querySelector
(
'#player'
).
requestFullscreen
()
// document.querySelector('#player').requestFullscreen()
},
clickItm
(
itm
)
{
this
.
mainId
=
itm
.
getId
()
}
}
},
},
async
mounted
()
{
async
mounted
()
{
console
.
log
(
'mounted'
)
console
.
log
(
'mounted'
)
const
{
roomId
}
=
this
.
$route
.
query
const
{
roomId
,
userId
}
=
this
.
$route
.
query
this
.
roomId
=
roomId
this
.
roomId
=
roomId
this
.
userId
=
userId
// eslint-disable-next-line no-underscore-dangle
// eslint-disable-next-line no-underscore-dangle
const
ok
=
await
HWRTC
.
getAuthUserMedia
()
const
ok
=
await
HWRTC
.
getAuthUserMedia
()
if
(
!
ok
)
{
if
(
!
ok
)
{
this
.
$alert
(
'无摄像头和和麦克风权限'
);
this
.
$alert
(
'无摄像头和和麦克风权限'
);
return
;
return
;
}
}
this
.
rtc
=
new
HWRTC
((
new
Date
().
getTime
()
/
1000
).
toFixed
(
0
));
this
.
rtc
=
new
HWRTC
(
userId
||
(
new
Date
().
getTime
()
/
1000
).
toFixed
(
0
));
this
.
cameras
=
await
this
.
rtc
.
getCameras
()
this
.
cameras
=
await
this
.
rtc
.
getCameras
()
this
.
micro
=
await
this
.
rtc
.
getMicrophones
()
this
.
micro
=
await
this
.
rtc
.
getMicrophones
()
console
.
log
(
this
.
cameras
,
this
.
micro
)
this
.
rtc
.
subscribedStreamCb
((
streams
)
=>
{
this
.
rtc
.
subscribedStreamCb
((
streams
)
=>
{
this
.
streams
=
streams
this
.
streams
=
streams
})
})
...
@@ -133,19 +147,17 @@ export default {
...
@@ -133,19 +147,17 @@ export default {
position
:
relative
;
position
:
relative
;
.side
{
.side
{
width
:
20vw
;
width
:
20vw
;
}
.stream-pre
{
position
:
absolute
;
top
:
10px
;
left
:
0
;
width
:
calc
(
100%
-
20vw
);
overflow
:
auto
;
display
:
flex
;
display
:
flex
;
flex-flow
:
row
;
flex-flow
:
column
;
.item
{
align-items
:
stretch
;
margin-left
:
10px
;
.stream-pre
{
width
:
300px
;
flex
:
1
;
height
:
220px
;
overflow
:
auto
;
margin-top
:
20px
;
.item
{
width
:
100%
;
height
:
220px
;
}
}
}
}
}
.operation
{
.operation
{
...
...
yarn.lock
View file @
d2636bf8
...
@@ -881,8 +881,8 @@
...
@@ -881,8 +881,8 @@
"@geek/geekui@^1.1.2":
"@geek/geekui@^1.1.2":
version "1.1.2"
version "1.1.2"
resolved "http://git.jksxb.cn:8081/repository/geek/@geek/geekui/-/geekui-1.1.2.tgz#
346611159cc7e8bd37784e5d24310a56adb69434
"
resolved "http://git.jksxb.cn:8081/repository/geek/@geek/geekui/-/geekui-1.1.2.tgz#
bbe448fbefb1487d4b5f16596458d8062b79700f
"
integrity sha512-
wR4K6iz4HG1f937HAvloiS4dHp7GdvWBJnr+C8f7OxmLynDUqZGFAulYhQCwHfPodI3kUpRYkPxxM53oZiMtlg
==
integrity sha512-
TBPYSECTJknnBs7dSNdQLM+rnoMItpC3HBILLr3YuQCUdvmJdRsbaxlMokfEKv6a3sceAPWHCsnqEl7S4N+2yw
==
dependencies:
dependencies:
"@geek/geek-editor" "^1.0.7"
"@geek/geek-editor" "^1.0.7"
cos-js-sdk-v5 "^0.5.27"
cos-js-sdk-v5 "^0.5.27"
...
...
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