#include "ui.h" #include "storage.h" #include "player.h" #include "download.h" #include #include #include #include #include "esp_log.h" void close_overlay(){ if(G.overlay){ lv_obj_delete(G.overlay); G.overlay=NULL; G.dropdown=NULL; } } void dropdown_cb(lv_event_t* e){ if(lv_event_get_code(e)!=LV_EVENT_VALUE_CHANGED) return; lv_obj_t* dd = (lv_obj_t*)lv_event_get_target(e); int sel=lv_dropdown_get_selected(dd); if(sel<0||sel>=G.season_cnt) return; int sn=G.seasons[sel].num; close_overlay(); int first=-1, first_unseen=-1; for(int i=0;i0){ int pct=G.pos_sec*100/G.total_sec; if(pct>100) pct=100; if(pct!=G.last_pct){ G.last_pct=pct; lv_bar_set_value(G.bar,pct,LV_ANIM_OFF); } } else if(G.is_playing){ int pct=(G.pos_sec%10)*10; if(pct!=G.last_pct){ G.last_pct=pct; lv_bar_set_value(G.bar,pct,LV_ANIM_OFF); } } } if(G.lbl_time){ char a[16],b[16]; fmt_time(a,G.pos_sec); if(G.total_sec>0) fmt_time(b,G.total_sec); else snprintf(b,sizeof(b),"--:--"); char buf[40]; snprintf(buf,sizeof(buf),"%s / %s",a,b); lv_label_set_text(G.lbl_time,buf); } if(G.is_playing && G.lbl_status && !G.downloading){ const char* cur = lv_label_get_text(G.lbl_status); if(!cur || strcmp(cur,"Playing")!=0) lv_label_set_text(G.lbl_status,"Playing"); } if(G.is_playing && !G.is_paused && !G.downloading){ G.last_save_tick++; if(G.last_save_tick >= 25){ G.last_save_tick=0; save_current_ep_pos(); save_state(); } } } void btn_play_cb(lv_event_t* e){ (void)e; if(G.downloading){ return; } if(G.is_playing && !G.is_paused){ G.is_paused=true; save_current_ep_pos(); save_state(); tt_lvgl_lock(portMAX_DELAY); if(G.lbl_status) lv_label_set_text(G.lbl_status,"Paused"); if(G.btn_play){ lv_obj_t* ch=lv_obj_get_child(G.btn_play,0); if(ch) lv_label_set_text(ch,LV_SYMBOL_PLAY); } tt_lvgl_unlock(); } else if(G.is_paused){ G.is_paused=false; tt_lvgl_lock(portMAX_DELAY); if(G.btn_play){ lv_obj_t* ch=lv_obj_get_child(G.btn_play,0); if(ch) lv_label_set_text(ch,LV_SYMBOL_PAUSE); } tt_lvgl_unlock(); } else { start_idx(G.cur_ep_idx); tt_lvgl_lock(portMAX_DELAY); if(G.btn_play){ lv_obj_t* ch=lv_obj_get_child(G.btn_play,0); if(ch) lv_label_set_text(ch,LV_SYMBOL_PAUSE); } tt_lvgl_unlock(); } } void btn_prev_cb(lv_event_t* e){ (void)e; if(G.downloading) return; go_prev(); } void btn_next_cb(lv_event_t* e){ (void)e; if(G.downloading) return; go_next(); }