From da7dfed5bad3074fa593e6ba5ead52b2206839bb Mon Sep 17 00:00:00 2001 From: Hunlongyu Date: Mon, 19 Oct 2020 17:28:17 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=81=20=E4=BF=AE=E5=A4=8D=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E5=81=9C=E6=AD=A2=E6=92=AD=E6=94=BE=E5=90=8E,=20?= =?UTF-8?q?=E4=B8=8B=E6=AC=A1=E7=82=B9=E5=87=BB=E6=8C=89=E9=92=AE=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Play.vue | 74 +++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/src/components/Play.vue b/src/components/Play.vue index e125d29..d058d22 100644 --- a/src/components/Play.vue +++ b/src/components/Play.vue @@ -293,11 +293,10 @@ export default { clearInterval(this.timer) this.timer = null } - if (this.xg) { - if (this.xg.hasStart) { - this.xg.pause() - } + if (this.xg && this.xg.hasStart) { + this.xg.pause() } + if (this.video.iptv) { // 是直播源,直接播放 this.playUrl(this.video.iptv.url) @@ -1019,25 +1018,59 @@ export default { }) }, videoStop () { + if (this.xg.fullscreen) { + this.xg.exitFullscreen() + } this.xg.destroy() this.config.src = '' this.name = '' this.right.list = [] this.showNext = false - this.xg = new Hls(this.config) + setTimeout(() => { + this.playerInstall() + this.xg = new Hls(this.config) + this.bindEvent() + }, 500) }, minMaxEvent () { const win = remote.getCurrentWindow() win.on('minimize', () => { - if (this.xg) { + if (this.xg && this.xg.hasStart) { this.xg.pause() } }) win.on('restore', () => { - if (this.xg) { + if (this.xg && this.config.src) { this.xg.play() } }) + }, + playerInstall () { + Player.install('playPrev', function () { + addPlayerBtn.bind(this, 'playPrev', '', { title: '上一集' })() + }) + Player.install('playNextOne', function () { + addPlayerBtn.bind(this, 'playNextOne', '', { title: '下一集' })() + }) + Player.install('videoStop', function () { + addPlayerBtn.bind(this, 'videoStop', '', { title: '停止播放' })() + }) + Player.install('showList', function () { + addPlayerBtn.bind(this, 'showList', '', { title: '播放列表' })() + }) + Player.install('showHistory', function () { + addPlayerBtn.bind(this, 'showHistory', '', { title: '播放历史' })() + }) + const that = this + Player.install('videoTitle', function () { + let title + if (that.right.list.length > 1) { + title = `『第 ${that.video.info.index + 1} 集』${that.name}` + } else { + title = `${that.name}` + } + addPlayerView.bind(this, 'videoTitle', `${title}`, {})() + }) } }, created () { @@ -1045,32 +1078,7 @@ export default { this.mtEvent() }, mounted () { - Player.install('playPrev', function () { - addPlayerBtn.bind(this, 'playPrev', '', { title: '上一集' })() - }) - Player.install('playNextOne', function () { - addPlayerBtn.bind(this, 'playNextOne', '', { title: '下一集' })() - }) - Player.install('videoStop', function () { - addPlayerBtn.bind(this, 'videoStop', '', { title: '停止播放' })() - }) - Player.install('showList', function () { - addPlayerBtn.bind(this, 'showList', '', { title: '播放列表' })() - }) - Player.install('showHistory', function () { - addPlayerBtn.bind(this, 'showHistory', '', { title: '播放历史' })() - }) - const that = this - Player.install('videoTitle', function () { - let title - if (that.right.list.length > 1) { - title = `『第 ${that.video.info.index + 1} 集』${that.name}` - } else { - title = `${that.name}` - } - addPlayerView.bind(this, 'videoTitle', `${title}`, {})() - }) - + this.playerInstall() this.xg = new Hls(this.config) ipcRenderer.on('miniClosed', () => { history.find({ site: this.video.key, ids: this.video.info.id }).then(res => {