From 4adad0bc1f508360999de176048f89025ce84b3e Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Tue, 30 Oct 2018 09:45:26 -0400 Subject: FS#6323: Speech for ID3 viewer, playlist catalog and playlist viewer Modified from original ticket, Taken from Igor Poretsky's tree, and further modified by myself to incorporate feedback. Change-Id: Ibc2180e52af76890b1448d23f79386fd0f88f709 --- apps/tree.c | 63 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'apps/tree.c') diff --git a/apps/tree.c b/apps/tree.c index b5c9ddc11d..ddaf955ce6 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -102,7 +102,7 @@ static int curr_context = false;/* id3db or tree*/ static int dirbrowse(void); static int ft_play_dirname(char* name); -static void ft_play_filename(char *dir, char *file); +static int ft_play_filename(char *dir, char *file, int attr); static void say_filetype(int attr); struct entry* tree_get_entries(struct tree_context *t) @@ -238,7 +238,7 @@ static int tree_voice_cb(int selected_item, void * data) if(global_settings.talk_dir_clip) { did_clip = true; - if(ft_play_dirname(name) <0) + if (ft_play_dirname(name) <= 0) /* failed, not existing */ did_clip = false; } @@ -246,7 +246,9 @@ static int tree_voice_cb(int selected_item, void * data) if (global_settings.talk_file_clip && (attr & FILE_ATTR_THUMBNAIL)) { did_clip = true; - ft_play_filename(local_tc->currdir, name); + if (ft_play_filename(local_tc->currdir, name, attr) <= 0) + /* failed, not existing */ + did_clip = false; } } if(!did_clip) @@ -1175,17 +1177,25 @@ bool bookmark_play(char *resume_file, int index, unsigned long elapsed, return started; } -static void say_filetype(int attr) +static long filetype_voiceclip(int attr) { - /* try to find a voice ID for the extension, if known */ int j; - attr &= FILE_ATTR_MASK; /* file type */ - for (j=0; j= strlen(file_thumbnail_ext) && strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)], file_thumbnail_ext)) /* file has no .talk extension */ - talk_file(dir, NULL, file, file_thumbnail_ext, - NULL, false); - else - /* it already is a .talk file, play this directly, but prefix it. */ - talk_file(dir, NULL, file, NULL, - TALK_IDARRAY(LANG_VOICE_DIR_HOVER), false); + return talk_file(dir, NULL, file, file_thumbnail_ext, + TALK_IDARRAY(filetype_voiceclip(attr)), false); + + /* it already is a .talk file, play this directly, but prefix it. */ + return talk_file(dir, NULL, file, NULL, + TALK_IDARRAY(LANG_VOICE_DIR_HOVER), false); } /* These two functions are called by the USB and shutdown handlers */ -- cgit v1.2.3