Skip to content

Commit 889e173

Browse files
committed
Add /jump_forward and /jump_backward to Web API
1 parent 8106022 commit 889e173

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/utils/clArgs.js

+32
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,36 @@ function startWebApi(el) {
116116
} else err(res)
117117
})
118118

119+
app.get('/jump_forward', (req, res) => {
120+
if (req.query.value && ((player || {}).wcjs || {}).time && player.wcjs.length) {
121+
const jumpTime = parseInt(req.query.value)
122+
123+
const newTime = player.wcjs.time + jumpTime
124+
125+
if (newTime < player.wcjs.length)
126+
player.wcjs.time = newTime
127+
else
128+
player.wcjs.time = player.wcjs.length - 1000
129+
130+
res.send('success')
131+
} else err(res)
132+
})
133+
134+
app.get('/jump_backward', (req, res) => {
135+
if (req.query.value && ((player || {}).wcjs || {}).time && player.wcjs.length) {
136+
const jumpTime = parseInt(req.query.value)
137+
138+
const newTime = player.wcjs.time - jumpTime
139+
140+
if (newTime > 0)
141+
player.wcjs.time = newTime
142+
else
143+
player.wcjs.time = 0
144+
145+
res.send('success')
146+
} else err(res)
147+
})
148+
119149
app.get('/duration', (req, res) => {
120150
if (((player || {}).wcjs || {}).length) {
121151
res.setHeader('Content-Type', 'application/json; charset=utf-8')
@@ -211,6 +241,8 @@ function startWebApi(el) {
211241
})
212242
}
213243

244+
startWebApi('--web-api')
245+
214246
module.exports = {
215247
process: (args) => {
216248
if (args.length) {

0 commit comments

Comments
 (0)