3778cb3399
- DiscoveryMountain: new UI optimized for episode list (not player anymore) - Shows episodes for current season, indicates if on SD card (green=On SD, gray=Not DL) - Per-episode action: download single via SdDownloader or play via Mp3Player - DL Missing button for missing eps in season (currently single first missing, batch reverted) - Season selector screen with cached/total counts - Top-right X close button - Seasons/episodes cached to cache.json to avoid network fetch every launch - Fixes: overlay deletion race (deferred timer), ui_timer leak causing crash on close, season selection overwritten by fetch task - Fixes: unicode ellipsis squares - SdDownloader: revert to stable single-file mode (batch array caused crashes) - Remove batch fields and array allocation, keep single url/path download - Result bundle simple success/path/bytes - Mp3Player: add resume position support (pos_sec from bundle, total_sec estimate, total_decoded_samples), return position on exit via bundle for DM to save Tested on 192.168.68.133: opens, shows S10 2/6, Play/DL buttons, close works, no crash on open/close cycles, cache shows 'Loaded from cache, refreshing...'
100 lines
2.3 KiB
C
100 lines
2.3 KiB
C
#pragma once
|
|
|
|
#include <tt_lvgl.h>
|
|
#include <tt_lvgl_toolbar.h>
|
|
#include <lvgl.h>
|
|
#include <tactility/lvgl_fonts.h>
|
|
#include <tactility/device.h>
|
|
#include <tactility/drivers/audio_stream.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define TAG "DM"
|
|
#define PB "http://192.168.68.110:8095"
|
|
#define DM_DIR "/sdcard/dm"
|
|
#define STATE_PATH "/sdcard/apps/one.tactility.discoverymountain/userdata/state.json"
|
|
#define CACHE_PATH "/sdcard/apps/one.tactility.discoverymountain/userdata/cache.json"
|
|
#define MAX_SEASONS 40
|
|
#define MAX_EPS 250
|
|
#define MP3_BUF 4096
|
|
|
|
typedef struct { int num; } SeasonInfo;
|
|
typedef struct {
|
|
char title[64];
|
|
char slug[96];
|
|
int season;
|
|
int ep_num;
|
|
char audio_url[128];
|
|
bool seen;
|
|
} EpInfo;
|
|
|
|
typedef struct { char slug[96]; int pos; } SavedPos;
|
|
|
|
typedef struct {
|
|
SeasonInfo seasons[MAX_SEASONS];
|
|
int season_cnt;
|
|
EpInfo eps[MAX_EPS];
|
|
int ep_cnt;
|
|
int cur_season;
|
|
int cur_ep_idx;
|
|
struct Device* stream_dev;
|
|
AudioStreamHandle stream_handle;
|
|
bool is_playing;
|
|
bool is_paused;
|
|
bool need_stop;
|
|
TaskHandle_t play_handle;
|
|
TaskHandle_t fetch_handle;
|
|
TaskHandle_t dl_handle;
|
|
int pos_sec;
|
|
int total_sec;
|
|
int volume;
|
|
int last_pct;
|
|
lv_obj_t *root;
|
|
lv_obj_t *lbl_title, *lbl_meta, *bar, *lbl_time, *lbl_status, *btn_play;
|
|
lv_obj_t *lbl_season;
|
|
lv_obj_t *ep_list_cont;
|
|
lv_obj_t *btn_seasons;
|
|
lv_obj_t *btn_dl_missing;
|
|
lv_obj_t *overlay, *dropdown;
|
|
lv_obj_t *season_list_cont;
|
|
lv_timer_t *ui_timer_handle;
|
|
// Download UI
|
|
lv_obj_t *dl_overlay;
|
|
lv_obj_t *dl_bar;
|
|
lv_obj_t *dl_lbl_pct;
|
|
lv_obj_t *dl_lbl_detail;
|
|
lv_obj_t *dl_lbl_title;
|
|
lv_obj_t *dl_lbl_sub;
|
|
char cur_title[128];
|
|
char last_slug[96];
|
|
bool fetching;
|
|
bool downloading;
|
|
volatile int dl_total;
|
|
int dl_expected;
|
|
int dl_last_ui_update;
|
|
volatile bool dl_cancel_req;
|
|
volatile bool fetch_cancel_req;
|
|
char dl_ep_title[128];
|
|
char dl_slug[96];
|
|
int dl_season;
|
|
int dl_ep_num;
|
|
int dl_last_pct;
|
|
// Per-episode resume
|
|
SavedPos saved_pos[MAX_EPS];
|
|
int saved_pos_cnt;
|
|
int last_save_tick;
|
|
|
|
// External downloader integration (SdDownloader)
|
|
int pending_dl_idx;
|
|
} AppCtx;
|
|
|
|
extern AppCtx G;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|