diff --git a/package.json b/package.json index 4542526..7b80620 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "media_player_client", - "version": "1.0.3", + "version": "1.2.0", "description": "A Quasar Framework app", "productName": "MediaPlayerClient", "author": "fangxiang ", diff --git a/src/components/PlaylistDialog.vue b/src/components/PlaylistDialog.vue index b6bd827..3e44e2e 100644 --- a/src/components/PlaylistDialog.vue +++ b/src/components/PlaylistDialog.vue @@ -82,6 +82,7 @@ ref="accept" flat :label="$t('close and save')" + :disable="play_list.length == 0" :loading="loading" type="submit" color="primary" @@ -130,68 +131,47 @@ export default defineComponent({ let _resolove: any = null; - const initialize_properties = (options: any) => { + const initialize_properties = (playlist: string) => { play_list.value = []; const prefix = ( GlobalData.getInstance().applicationConfig?.application_data_dir ?? "" ).replace(/\\/g, "/"); - if (typeof options == "string") { - for (let item of options.split(";")) { - if (!item || item.length == 0) { - continue; - } - try { - /* try { - const url = new URL(item); - - if (url.host == "media" && url.pathname.startsWith("/usb")) { - const usb_index = parseInt(url.pathname.substr("/usb".length, 1)); - if (!isNaN(usb_index)) { - const target_path = decodeURI(url.pathname); - item = - "/usb" + - (usb_index + 1).toString() + - target_path.substr("/usb0".length); - } else { - console.error("url:", item); - console.error("url:", url); - console.error( - "usb_index:", - url.pathname.substr("/usb".length, 1) - ); - console.error("usb_index:", usb_index); - } - } else if ( - url.host == "userdata" && - url.pathname.startsWith("/media_player_datas") - ) { - item = decodeURI(url.pathname).substr( - "/media_player_datas/".length - ); - } - } catch {}*/ - - let temp_str = decodeURI(new URL(item).pathname).replace( - /\\/g, - "/" - ); - if ( - (GlobalData.getInstance().applicationConfig?.runtime_os ?? - "UNKNOW") == "WINDOWS" - ) { - temp_str = temp_str.substr(1); - } - - if (temp_str.startsWith(prefix)) { - temp_str = temp_str.substr(prefix.length + 1); - } - play_list.value.push(temp_str); - } catch (e) { - console.warn(e); + + console.log(playlist); + const temp_play_list = []; + try { + const temp_parse = JSON.parse(playlist); + if (Array.isArray(temp_parse)) { + for (const item of temp_parse) { + temp_play_list.push(item.toString()); } + } else { + temp_play_list.push(temp_parse.toString()); + } + } catch (e) { + temp_play_list.push(playlist.toString()); + } + + for (let item of temp_play_list) { + if (!item || item.length == 0) { + continue; + } + try { + let temp_str = decodeURI(new URL(item).pathname).replace(/\\/g, "/"); + if ( + (GlobalData.getInstance().applicationConfig?.runtime_os ?? + "UNKNOW") == "WINDOWS" + ) { + temp_str = temp_str.substr(1); + } + + if (temp_str.startsWith(prefix)) { + temp_str = temp_str.substr(prefix.length + 1); + } + play_list.value.push(temp_str); + } catch (e) { + console.warn(e); } - } else { - console.error("options type error!", options); } }; @@ -259,13 +239,12 @@ export default defineComponent({ try { if (_resolove) { if (play_list.value.length == 0) { - _resolove(""); + _resolove(); } else { const temp = GlobalData.getInstance().applicationConfig ?.application_data_dir ?? ""; - console.log(temp); - let str = ""; + let temp_play_list = []; for (const item of play_list.value) { try { if ( @@ -274,22 +253,24 @@ export default defineComponent({ ) { /** windows */ if (item.startsWith("/")) { - str += item + ";"; + temp_play_list.push(item); } else if (item[1] == ":") { // windows 盘符 - str += "file:///" + (item + ";"); + temp_play_list.push("file:///" + item); } else { - str += new URL(temp + "/" + item).toString() + ";"; + temp_play_list.push( + new URL(temp + "/" + item).toString() + ); } } else { /** linux */ - str += item + ";"; + temp_play_list.push(item); } } catch (e) { console.log(e); } } - _resolove(str); + _resolove(temp_play_list); } } show_dialog.value = false; diff --git a/src/components/SignalSourceDialog.vue b/src/components/SignalSourceDialog.vue index 0219a8e..c62c1d9 100644 --- a/src/components/SignalSourceDialog.vue +++ b/src/components/SignalSourceDialog.vue @@ -378,6 +378,7 @@ export default defineComponent({ const requestAddSignalSource = async () => { item_data.group_uuid = selected.value; + let response = await GlobalData.getInstance() .getCurrentClient() ?.addSignalSource(item_data); @@ -471,11 +472,36 @@ export default defineComponent({ loading.value = false; }, async showPlaylistDialog() { + if (item_data.window_type != "EwindowType::Multimedia") { + return; + } const result = await playlist_dialog.value.showDialogAsync( item_data.media_url ); - if (result) { - item_data.media_url = decodeURI(result); + if (Array.isArray(result)) { + if (result.length) { + if ( + !item_data.name || + item_data.name.trim() == "" || + item_data.name.trim() == $t.t("new signal source") + ) { + try { + const temp_item = decodeURI(result[0].toString()); + let index = temp_item.lastIndexOf("\\"); + if (index == -1) { + index = temp_item.lastIndexOf("/"); + } + if (index + 1 == temp_item.length) { + item_data.name = temp_item.substr(index); + } else if (index + 1 < temp_item.length) { + item_data.name = temp_item.substr(index + 1); + } + } catch (e) { + console.log(e); + } + } + item_data.media_url = decodeURI(JSON.stringify(result)); + } } }, async doSelectFile() { @@ -492,7 +518,11 @@ export default defineComponent({ if (path && file) { item_data.media_url = path + "/" + file.name; - if (item_data.name.trim() == "") { + if ( + !item_data.name || + item_data.name.trim() == "" || + item_data.name.trim() == $t.t("new signal source") + ) { nextTick(() => { item_data.name = file.name; }); diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index b0df841..01befd7 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -293,7 +293,7 @@ export default { "close and reset": "放弃修改并关闭", operator_signal_source: "信号源", "play prev": "上一曲", - "play next": "上一曲", + "play next": "下一曲", play: "播放", pause: "暂停", "volume up": "音量加", diff --git a/src/pages/MediaControlPage.vue b/src/pages/MediaControlPage.vue index ab837db..ad5bedc 100644 --- a/src/pages/MediaControlPage.vue +++ b/src/pages/MediaControlPage.vue @@ -187,9 +187,7 @@ export default defineComponent({ type == "EwindowType::Multimedia" || type == "EwindowType::Rtsp"; can_pause_window.value = type == "EwindowType::Multimedia"; - console.log(type); can_next_prev_window.value = type == "EwindowType::Multimedia"; - console.log(can_next_prev_window.value); } } else { selected_window.value = null;