stm32_radio: Reset the progress bar after song change. Fixed the duration calculation bug.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@395 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
527b55c138
commit
9dfd2fd177
@ -45,8 +45,7 @@ void info_timer_timeout(rtgui_timer_t* timer, void* parameter)
|
|||||||
saved = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view));
|
saved = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view));
|
||||||
|
|
||||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = RTGUI_RGB(206, 231, 255);
|
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = RTGUI_RGB(206, 231, 255);
|
||||||
rtgui_dc_draw_hline(dc, 14, 14 + (tinfo.position * 212)/ tinfo.duration,
|
rtgui_dc_draw_hline(dc, 14, 14 + (tinfo.position * 212) / tinfo.duration, 75);
|
||||||
75);
|
|
||||||
|
|
||||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = saved;
|
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = saved;
|
||||||
rtgui_dc_end_drawing(dc);
|
rtgui_dc_end_drawing(dc);
|
||||||
@ -137,7 +136,7 @@ static void player_update_tag_info(struct rtgui_dc* dc)
|
|||||||
{
|
{
|
||||||
rect.x1 = rect.x2 - 64;
|
rect.x1 = rect.x2 - 64;
|
||||||
rt_snprintf(line, sizeof(line), "%02d:%02d:%02d",
|
rt_snprintf(line, sizeof(line), "%02d:%02d:%02d",
|
||||||
tinfo.duration / 360, tinfo.duration / 60, tinfo.duration % 60);
|
tinfo.duration / 3600, tinfo.duration / 60, tinfo.duration % 60);
|
||||||
rtgui_dc_draw_text(dc, line, &rect);
|
rtgui_dc_draw_text(dc, line, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +146,7 @@ static void player_update_tag_info(struct rtgui_dc* dc)
|
|||||||
void play_mp3_file(const char* fn)
|
void play_mp3_file(const char* fn)
|
||||||
{
|
{
|
||||||
struct rtgui_dc* dc;
|
struct rtgui_dc* dc;
|
||||||
|
rtgui_color_t saved;
|
||||||
|
|
||||||
/* get music tag information */
|
/* get music tag information */
|
||||||
mp3_get_info(fn, &tinfo);
|
mp3_get_info(fn, &tinfo);
|
||||||
@ -165,6 +165,12 @@ void play_mp3_file(const char* fn)
|
|||||||
/* update tag information */
|
/* update tag information */
|
||||||
player_update_tag_info(dc);
|
player_update_tag_info(dc);
|
||||||
|
|
||||||
|
/* reset progress bar */
|
||||||
|
saved = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view));
|
||||||
|
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = RTGUI_RGB(82, 199, 16);
|
||||||
|
rtgui_dc_draw_hline(dc, 14, 226, 75);
|
||||||
|
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = saved;
|
||||||
|
|
||||||
/* update play button */
|
/* update play button */
|
||||||
button = rtgui_image_create_from_mem("hdc",
|
button = rtgui_image_create_from_mem("hdc",
|
||||||
play_hdh, sizeof(play_hdh), RT_FALSE);
|
play_hdh, sizeof(play_hdh), RT_FALSE);
|
||||||
@ -223,26 +229,23 @@ void function_filelist(void* parameter)
|
|||||||
rt_uint32_t length;
|
rt_uint32_t length;
|
||||||
|
|
||||||
length = read_line(fd, line, sizeof(line));
|
length = read_line(fd, line, sizeof(line));
|
||||||
if (strcmp(line, "#EXTM3U") == 0)
|
/* clear old play list */
|
||||||
{
|
play_list_clear();
|
||||||
/* clear old play list */
|
|
||||||
play_list_clear();
|
|
||||||
|
|
||||||
do
|
do
|
||||||
|
{
|
||||||
|
length = read_line(fd, line, sizeof(line));
|
||||||
|
if (length > 0)
|
||||||
{
|
{
|
||||||
length = read_line(fd, line, sizeof(line));
|
if (line[0] != '/')
|
||||||
if (length > 0)
|
|
||||||
{
|
{
|
||||||
if (line[0] != '/')
|
rt_snprintf(fn, sizeof(fn),
|
||||||
{
|
"%s/%s", view->current_directory, line);
|
||||||
rt_snprintf(fn, sizeof(fn),
|
play_list_append(fn);
|
||||||
"%s/%s", view->current_directory, line);
|
|
||||||
play_list_append(fn);
|
|
||||||
}
|
|
||||||
else play_list_append(line);
|
|
||||||
}
|
}
|
||||||
} while (length > 0);
|
else play_list_append(line);
|
||||||
}
|
}
|
||||||
|
} while (length > 0);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@ -376,7 +379,7 @@ static rt_bool_t home_view_event_handler(struct rtgui_widget* widget, struct rtg
|
|||||||
{
|
{
|
||||||
rect.x1 = rect.x2 - 64;
|
rect.x1 = rect.x2 - 64;
|
||||||
rt_snprintf(line, sizeof(line), "%02d:%02d:%02d",
|
rt_snprintf(line, sizeof(line), "%02d:%02d:%02d",
|
||||||
tinfo.duration / 360, tinfo.duration / 60, tinfo.duration % 60);
|
tinfo.duration / 3600, tinfo.duration / 60, tinfo.duration % 60);
|
||||||
rtgui_dc_draw_text(dc, line, &rect);
|
rtgui_dc_draw_text(dc, line, &rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -401,7 +404,7 @@ static rt_bool_t home_view_event_handler(struct rtgui_widget* widget, struct rtg
|
|||||||
|
|
||||||
rect.x1 = rect.x2 - 64;
|
rect.x1 = rect.x2 - 64;
|
||||||
rt_snprintf(line, sizeof(line), "%02d:%02d:%02d",
|
rt_snprintf(line, sizeof(line), "%02d:%02d:%02d",
|
||||||
item->duration / 360,
|
item->duration / 3600,
|
||||||
item->duration / 60,
|
item->duration / 60,
|
||||||
item->duration % 60);
|
item->duration % 60);
|
||||||
rtgui_dc_draw_text(dc, line, &rect);
|
rtgui_dc_draw_text(dc, line, &rect);
|
||||||
@ -490,6 +493,8 @@ static rt_bool_t home_view_event_handler(struct rtgui_widget* widget, struct rtg
|
|||||||
|
|
||||||
player_update_tag_info(dc);
|
player_update_tag_info(dc);
|
||||||
|
|
||||||
|
saved = RTGUI_WIDGET_FOREGROUND(widget);
|
||||||
|
|
||||||
RTGUI_WIDGET_FOREGROUND(widget) = RTGUI_RGB(82, 199, 16);
|
RTGUI_WIDGET_FOREGROUND(widget) = RTGUI_RGB(82, 199, 16);
|
||||||
rtgui_dc_draw_hline(dc, 14, 226, 75);
|
rtgui_dc_draw_hline(dc, 14, 226, 75);
|
||||||
|
|
||||||
@ -523,6 +528,8 @@ static rt_bool_t home_view_event_handler(struct rtgui_widget* widget, struct rtg
|
|||||||
|
|
||||||
player_update_tag_info(dc);
|
player_update_tag_info(dc);
|
||||||
|
|
||||||
|
saved = RTGUI_WIDGET_FOREGROUND(widget);
|
||||||
|
|
||||||
RTGUI_WIDGET_FOREGROUND(widget) = RTGUI_RGB(82, 199, 16);
|
RTGUI_WIDGET_FOREGROUND(widget) = RTGUI_RGB(82, 199, 16);
|
||||||
rtgui_dc_draw_hline(dc, 14, 226, 75);
|
rtgui_dc_draw_hline(dc, 14, 226, 75);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user