修改播放列表为JSON数组

This commit is contained in:
fangxiang 2022-01-21 10:20:26 +08:00
parent 0da2e1993f
commit e839e830a7
5 changed files with 80 additions and 71 deletions

View File

@ -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 <fangxiang@cloudview.work>",

View File

@ -82,6 +82,7 @@
ref="accept"
flat
:label="$t('close and save')"
:disable="play_list.length == 0"
:loading="loading"
type="submit"
color="primary"
@ -130,51 +131,33 @@ 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(";")) {
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 {
/* 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,
"/"
);
let temp_str = decodeURI(new URL(item).pathname).replace(/\\/g, "/");
if (
(GlobalData.getInstance().applicationConfig?.runtime_os ??
"UNKNOW") == "WINDOWS"
@ -190,9 +173,6 @@ export default defineComponent({
console.warn(e);
}
}
} else {
console.error("options type error!", options);
}
};
const doSelectFile = async () => {
@ -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;

View File

@ -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;
});

View File

@ -293,7 +293,7 @@ export default {
"close and reset": "放弃修改并关闭",
operator_signal_source: "信号源",
"play prev": "上一曲",
"play next": "一曲",
"play next": "一曲",
play: "播放",
pause: "暂停",
"volume up": "音量加",

View File

@ -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;