Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete selected clip #175

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/ui/page_playback.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ static lv_obj_t *page_playback_create(lv_obj_t *parent, panel_arr_t *arr) {
}

lv_obj_t *label = lv_label_create(cont);
lv_label_set_text(label, "*Long press left button to exit");
lv_label_set_text(label, "*Long press left button to exit\n**Long press right button to delete");
lv_obj_set_style_text_font(label, &lv_font_montserrat_16, 0);
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_set_style_text_color(label, lv_color_make(255, 255, 255), 0);
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(label, 160, 700);
lv_obj_set_pos(label, 10, 700);

return page;
}
Expand Down Expand Up @@ -308,6 +308,26 @@ static void mark_video_file(int seq) {
update_page();
}

static void delete_video_file(int seq) {
media_file_node_t *pnode = get_list(seq);
if (!pnode) {
LOGE("delete_video_file failed. (PNODE ERROR)");
return;
}

char cmd[128];
sprintf(cmd, "rm %s/%s.*", MEDIA_FILES_DIR, pnode->label);

if (system(cmd) != -1) {
walk_sdcard();
media_db.cur_sel = constrain(seq, 0, (media_db.count - 1));
update_page();
LOGD("delete_video_file successful.");
} else {
LOGE("delete_video_file failed.");
}
}

static void page_playback_exit() {
clear_videofile_cnt();
update_page();
Expand Down Expand Up @@ -373,6 +393,10 @@ void pb_key(uint8_t key) {
case RIGHT_KEY_CLICK:
mark_video_file(media_db.cur_sel);
break;

case RIGHT_KEY_PRESS:
delete_video_file(media_db.cur_sel);
break;
}
done = true;
}
Expand Down