-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from ZyqGitHub1/dev
add direct video player
- Loading branch information
Showing
4 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<template> | ||
<q-page | ||
class="video-warp" | ||
padding | ||
> | ||
<hls-player | ||
:source="normalizeUrl(videoUrl)" | ||
:options="options" | ||
@hls-error="errorHandler" | ||
ref="player" | ||
></hls-player> | ||
</q-page> | ||
</template> | ||
|
||
<script> | ||
import HlsPlayer from 'components/HlsPlayer'; | ||
import normalizeUrl from 'normalize-url'; | ||
export default { | ||
name: 'MiniVideo', | ||
data() { | ||
return { | ||
options: { | ||
controls: [ | ||
'play-large', | ||
'play', | ||
'progress', | ||
'current-time', | ||
'mute', | ||
'volume', | ||
'captions', | ||
'settings', | ||
'airplay', | ||
'fullscreen', | ||
], | ||
}, | ||
videoUrl: '', | ||
}; | ||
}, | ||
components: { | ||
HlsPlayer, | ||
}, | ||
created() { | ||
const videoInfo = JSON.parse(this.$route.query.video); | ||
this.videoUrl = videoInfo.url; | ||
document.querySelector('title').text = videoInfo.url; | ||
}, | ||
methods: { | ||
normalizeUrl(url) { | ||
const pureUrl = url.replace(/(.*?)\$/, '').replace(/\$(.*)/, ''); | ||
return normalizeUrl(pureUrl); | ||
}, | ||
errorHandler(event, data) { | ||
if (data.details && data.details === 'manifestLoadError') { | ||
this.$q.dialog({ | ||
title: '错误', | ||
message: '播放失败,点击关闭窗口', | ||
persistent: true, | ||
}).onOk(() => { | ||
const { getCurrentWindow } = this.$q.electron.remote; | ||
const window = getCurrentWindow(); | ||
window.close(); | ||
}); | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style> | ||
.video-warp { | ||
height: 100vh; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters