Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
eslotsys-game-nuxt
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
毛线
eslotsys-game-nuxt
Commits
cee8066b
Commit
cee8066b
authored
Jul 31, 2023
by
毛线
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
e05d4b28
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
3 deletions
+108
-3
WebRTCPlayer.vue
components/common/WebRTCPlayer.vue
+0
-0
index.vue
components/common/audio/index.vue
+2
-0
index.vue
components/common/video/index.vue
+103
-0
right-player.vue
pages/index/game/components/right-player.vue
+1
-1
index.vue
pages/index/game/index.vue
+2
-2
No files found.
pages/index/game/components
/WebRTCPlayer.vue
→
components/common
/WebRTCPlayer.vue
View file @
cee8066b
File moved
components/common/audio/index.vue
View file @
cee8066b
...
@@ -54,6 +54,8 @@ export default {
...
@@ -54,6 +54,8 @@ export default {
volumeMachine
()
{},
volumeMachine
()
{},
volumeBg
(
value
)
{
volumeBg
(
value
)
{
this
.
bgAudio
.
volume
=
value
/
100
this
.
bgAudio
.
volume
=
value
/
100
this
.
bgAudio
.
volume
=
'0'
alert
(
'背景音乐设置1'
+
value
)
},
},
volumeButton
(
value
)
{
volumeButton
(
value
)
{
this
.
uiClickAudio
.
volume
=
value
/
100
this
.
uiClickAudio
.
volume
=
value
/
100
...
...
components/common/video/index.vue
0 → 100644
View file @
cee8066b
<
template
>
<video
ref=
"jswebrtc"
style=
"width: 100%;height: 100%;object-fit: fill;"
playsinline
@
click=
"(e) => handler().click(e)"
/>
</
template
>
<
script
>
import
JSWebrtc
from
'@/utils/jswebrtc.min.js'
import
{
mapState
}
from
'vuex'
export
default
{
name
:
"WebRTCPlayer"
,
props
:
{
videoSrc
:
{
type
:
String
,
default
:
''
}
},
data
()
{
return
{
player
:
null
}
},
computed
:
{
...
mapState
([
'zoom'
,
]),
...
mapState
(
'audio'
,
[
'volumeMachine'
]),
},
watch
:
{
volumeMachine
(
value
)
{
this
.
$refs
.
jswebrtc
.
volume
=
this
.
volumeMachine
/
100
},
},
mounted
()
{
this
.
$watch
(
'videoSrc'
,
()
=>
{
if
(
this
.
videoSrc
)
{
this
.
initVideo
(
this
.
videoSrc
)
}
},
{
immediate
:
true
})
},
beforeDestroy
()
{
// 播放器存在清除播放器
if
(
this
.
player
)
{
this
.
player
.
destroy
()
}
},
methods
:
{
/**
* 初始化播放器并播放
* 两种调用方式
* 一种通过 watch监听 props 传过来的 src 进行播放
* 一种通过 引用组件上的 ref 直接调用 initVideo 如 this.$refs.webrtc.initVideo('src')
* */
initVideo
(
url
)
{
// 播放器存在 清空重置
if
(
this
.
player
)
{
this
.
player
.
destroy
()
this
.
player
=
null
}
// 获取承载元素dom
this
.
$refs
.
jswebrtc
.
volume
=
this
.
volumeMachine
/
100
const
videoDom
=
this
.
$refs
.
jswebrtc
// 初始化播放器
this
.
player
=
new
JSWebrtc
.
Player
(
url
,
{
video
:
videoDom
,
autoplay
:
true
,
onPlay
:
(
obj
)
=>
{
// 监听video元素状态,可播放时进行播放 。 某些情况下 autoplay 会失效
// mdn https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLMediaElement/canplay_event
// 菜鸟 https://www.runoob.com/tags/av-event-canplay.html
videoDom
.
addEventListener
(
'canplay'
,
function
(
e
)
{
videoDom
.
play
()
})
console
.
log
(
obj
,
'播放器开始播放!'
)
}
})
},
handler
()
{
return
{
click
:
(
e
)
=>
{
const
{
zoom
}
=
this
const
video
=
this
.
$refs
.
jswebrtc
const
{
offsetWidth
,
offsetHeight
}
=
video
// 组件宽高
const
{
offsetX
,
offsetY
}
=
e
// 点击位置
const
clickPercenY
=
(
offsetHeight
*
zoom
-
offsetY
)
/
(
offsetHeight
*
zoom
)
const
clickPercenX
=
(
offsetX
)
/
(
offsetWidth
*
zoom
)
// 计算点击区域对应的十六进制
const
max
=
32639
const
y16
=
(
+
(
max
*
clickPercenY
).
toFixed
(
0
)).
toString
(
16
)
const
x16
=
(
+
(
max
*
clickPercenX
).
toFixed
(
0
)).
toString
(
16
)
this
.
$emit
(
'click'
,
{
x16
,
y16
})
},
}
},
},
}
</
script
>
pages/index/game/components/right-player.vue
View file @
cee8066b
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
WebRTCPlayer
from
'
.
/WebRTCPlayer'
import
WebRTCPlayer
from
'
@/components/common
/WebRTCPlayer'
export
default
{
export
default
{
components
:
{
components
:
{
WebRTCPlayer
,
WebRTCPlayer
,
...
...
pages/index/game/index.vue
View file @
cee8066b
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
</div>
</div>
<!-- 右侧的直播区域 -->
<!-- 右侧的直播区域 -->
<div
v-if=
"device"
class=
"right-player"
>
<div
v-if=
"device"
class=
"right-player"
>
<
RightPlayer
:device=
"device"
/
>
<
!--
<RightPlayer
:device=
"device"
/>
--
>
</div>
</div>
</div>
</div>
<!-- 音量控制,临时 -->
<!-- 音量控制,临时 -->
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
<
script
>
<
script
>
import
Background
from
'@/components/common/bg/index'
import
Background
from
'@/components/common/bg/index'
import
{
mapActions
,
mapState
,
mapMutations
,
mapGetters
,
}
from
'vuex'
import
{
mapActions
,
mapState
,
mapMutations
,
mapGetters
,
}
from
'vuex'
import
WebRTCPlayer
from
'
./components
/WebRTCPlayer'
import
WebRTCPlayer
from
'
@/components/common
/WebRTCPlayer'
import
RightPlayer
from
'./components/right-player'
import
RightPlayer
from
'./components/right-player'
import
Keyboard
from
'./components/keyboard'
import
Keyboard
from
'./components/keyboard'
import
AudioCtrl
from
'./components/audio-ctrl'
import
AudioCtrl
from
'./components/audio-ctrl'
...
...
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