From b243d25ef53d6a0b8be8c69ede68983a6258a03d Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Wed, 26 May 2021 13:06:49 +0800 Subject: [PATCH] =?UTF-8?q?raw=20=E7=94=B1=E6=92=AD=E6=94=BE=E5=99=A8?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/index.js | 70 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/web/index.js b/web/index.js index 521c454..05dbf95 100644 --- a/web/index.js +++ b/web/index.js @@ -246,7 +246,7 @@ const component_manage= {

关于本站

一只随处可见的 葱厨&车万人 想听 TA 屯在硬盘里的音乐。

-

一点点说明:下方播放器的 Prepare 模式,勾选后以 stream 模式播放的文件将提前在服务器端转码,服务器将保留临时文件10分钟,如果你的网络不稳定,经常播放到一半就中断,可以尝试勾选 prepare。

+

一点点说明:下方播放器的 Raw 模式即不转码直接播放源文件,支持断点续传;Prepare 模式:勾选后播放的文件将提前在服务器端转码,然后以支持断点续传的方式提供,如果你的网络不稳定,经常播放到一半就中断,可以尝试勾选 Prepare。

站内音乐来自公开网络,仅供个人使用,如有侵权或建议请提交反馈

@@ -568,21 +564,45 @@ const component_audio_player = { this.prepared_filesize = response.data.filesize this.is_preparing = false var file = this.file - file.play_back_type = 'cached_stream' this.playing_file = file + this.set_playing_url() + console.log('axios done', this.playing_file) }) }, + set_playing_url() { + if (this.raw) { + console.log('computed raw rul') + this.playing_url = '/api/v1/get_file_direct?id=' + this.playing_file.id + } else { + if (this.prepare) { + console.log('empty playing_file, start prepare') + this.playing_url = '/api/v1/get_file_stream_direct?id=' + this.playing_file.id + '&config=' + this.ffmpeg_config.name + } else { + console.log('computed stream url') + this.playing_url = '/api/v1/get_file_stream?id=' + this.playing_file.id + '&config=' + this.ffmpeg_config.name + } + } + }, }, watch: { file() { // 如果没有勾选 prepare 则直接播放 // 否则进入 prepare 流程 - if (this.prepare && this.file.play_back_type === 'stream') { + this.playing_file = {} + if (this.prepare && !this.raw) { this.prepare_func() } else { this.playing_file = this.file + this.set_playing_url() } }, + raw() { + this.set_playing_url() + }, + prepare() { + this.playing_file = {} + this.prepare_func() + }, ffmpeg_config() { if (this.prepare) { this.playing_file = {} @@ -599,7 +619,7 @@ const component_audio_player = { if (this.prepare) { filesize = this.prepared_filesize } - if (this.playing_file.play_back_type === 'raw') { + if (this.raw) { filesize = this.playing_file.filesize } if (filesize < 1024 * 1024 * 1024) { @@ -611,21 +631,11 @@ const component_audio_player = { // add separater to number return filesize.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") }, - computed_playing_audio_file_url() { - if (this.playing_file.play_back_type === 'raw') { - return '/api/v1/get_file_direct?id=' + this.playing_file.id - } else if (this.playing_file.play_back_type === 'stream') { - if (this.prepare) { - this.prepare_func() - } else { - return '/api/v1/get_file_stream?id=' + this.playing_file.id + '&config=' + this.ffmpeg_config.name - } - } else if (this.playing_file.play_back_type === 'cached_stream') { - return '/api/v1/get_file_stream_direct?id=' + this.playing_file.id + '&config=' + this.ffmpeg_config.name - } - }, computed_video_show() { - return this.playing_file.id ? true : false + if (this.playing_file.id && this.playing_url) { + return true + } + return false }, computed_show() { return this.file.id ? true : false