mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-02-15 00:16:26 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8a6fa2185 | ||
|
|
0e571efd6f |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "zy",
|
||||
"version": "1.0.14",
|
||||
"version": "1.0.16",
|
||||
"private": true,
|
||||
"author": {
|
||||
"name": "Hunlongyu",
|
||||
|
||||
@@ -191,71 +191,81 @@ export default {
|
||||
this.right.show = false
|
||||
this.right.type = ''
|
||||
},
|
||||
'video.index' () {
|
||||
this.getUrls()
|
||||
video: {
|
||||
handler () {
|
||||
this.getUrls()
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE']),
|
||||
getUrls () {
|
||||
this.name = ''
|
||||
this.mask = true
|
||||
if (this.timer !== null) {
|
||||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
|
||||
if (this.xg) {
|
||||
this.xg.pause()
|
||||
if (this.xg.hasStart) {
|
||||
this.xg.pause()
|
||||
}
|
||||
}
|
||||
this.changeVideo()
|
||||
|
||||
const index = this.video.index
|
||||
let time = 0
|
||||
|
||||
history.find({ detail: this.video.detail }).then(item => {
|
||||
let index = 0
|
||||
let time = 0
|
||||
if (item) {
|
||||
index = item.index
|
||||
if (this.video.index === index) {
|
||||
if (item.index === index) {
|
||||
time = item.currentTime
|
||||
}
|
||||
}
|
||||
tools.detail_get(this.video.site, this.video.detail).then(res => {
|
||||
this.name = this.video.name
|
||||
this.right.listData = res.m3u8_urls
|
||||
this.playVideo(index, time)
|
||||
})
|
||||
},
|
||||
playVideo (index, time) {
|
||||
tools.detail_get(this.video.site, this.video.detail).then(res => {
|
||||
console.log(res, 'res paly video')
|
||||
this.name = res.name
|
||||
this.right.listData = res.m3u8_urls
|
||||
|
||||
const m = res.m3u8_urls
|
||||
const arr = []
|
||||
for (const i of m) {
|
||||
arr.push(i.split('$')[1])
|
||||
}
|
||||
this.length = arr.length
|
||||
this.xg.src = arr[index]
|
||||
this.showNext = this.length > 1
|
||||
const m = res.m3u8_urls
|
||||
const arr = []
|
||||
for (const i of m) {
|
||||
arr.push(i.split('$')[1])
|
||||
}
|
||||
this.length = arr.length
|
||||
console.log(index, 'play index')
|
||||
this.xg.src = arr[index]
|
||||
this.showNext = this.length > 1
|
||||
|
||||
const currentTime = time
|
||||
if (currentTime !== 0) {
|
||||
this.xg.play()
|
||||
this.xg.once('playing', () => {
|
||||
this.xg.currentTime = currentTime
|
||||
})
|
||||
} else {
|
||||
this.xg.play()
|
||||
if (time !== 0) {
|
||||
this.xg.play()
|
||||
this.xg.once('playing', () => {
|
||||
this.xg.currentTime = time
|
||||
})
|
||||
} else {
|
||||
this.xg.play()
|
||||
}
|
||||
this.xg.once('play', () => {
|
||||
this.mask = false
|
||||
})
|
||||
this.onPlayVideo()
|
||||
this.xg.once('ended', () => {
|
||||
if (res.m3u8_urls.length > 1 && (res.m3u8_urls.length - 1 > this.video.index)) {
|
||||
this.video.currentTime = 0
|
||||
this.video.index++
|
||||
}
|
||||
this.xg.once('play', () => {
|
||||
this.mask = false
|
||||
})
|
||||
this.onPlayVideo()
|
||||
this.xg.once('ended', () => {
|
||||
if (res.m3u8_urls.length > 1 && (res.m3u8_urls.length - 1 > this.video.index)) {
|
||||
this.video.currentTime = 0
|
||||
this.video.index++
|
||||
}
|
||||
this.xg.off('ended')
|
||||
})
|
||||
this.xg.off('ended')
|
||||
})
|
||||
})
|
||||
},
|
||||
changeVideo () {
|
||||
this.checkStar()
|
||||
this.checkTop()
|
||||
this.name = ''
|
||||
},
|
||||
checkStar () {
|
||||
video.find({ detail: this.video.detail }).then(res => {
|
||||
@@ -274,6 +284,7 @@ export default {
|
||||
},
|
||||
onPlayVideo () {
|
||||
this.more = true
|
||||
this.changeVideo()
|
||||
const h = { ...this.video }
|
||||
history.find({ detail: h.detail }).then(res => {
|
||||
if (res) {
|
||||
@@ -312,24 +323,20 @@ export default {
|
||||
this.right.type = ''
|
||||
},
|
||||
nextEvent () {
|
||||
console.log(this.video.index, 'inex 1')
|
||||
if (this.video.index < this.right.listData.length - 1) {
|
||||
this.video.index++
|
||||
this.video.currentTime = 0
|
||||
} else {
|
||||
this.$m.warning(this.$t('last_video'))
|
||||
}
|
||||
console.log(this.video.index, 'inex 2')
|
||||
},
|
||||
prevEvent () {
|
||||
console.log(this.video.index, 'inex 3')
|
||||
if (this.video.index > 0) {
|
||||
this.video.index--
|
||||
this.video.currentTime = 0
|
||||
} else {
|
||||
this.$m.warning(this.$t('first_video'))
|
||||
}
|
||||
console.log(this.video.index, 'inex 4')
|
||||
},
|
||||
listEvent () {
|
||||
if (this.right.type === 'list') {
|
||||
@@ -404,10 +411,16 @@ export default {
|
||||
})
|
||||
},
|
||||
listItemEvent (n) {
|
||||
this.video.currentTime = 0
|
||||
this.video.index = n
|
||||
this.right.show = false
|
||||
this.right.type = ''
|
||||
history.find({ detail: this.video.detail }).then(item => {
|
||||
if (item) {
|
||||
item.currentTime = 0
|
||||
item.index = n
|
||||
history.update(item.id, item)
|
||||
}
|
||||
this.video.index = n
|
||||
this.right.show = false
|
||||
this.right.type = ''
|
||||
})
|
||||
},
|
||||
historyItemEvent (e) {
|
||||
this.video = e
|
||||
|
||||
Reference in New Issue
Block a user