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));
|
||||
|
||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = RTGUI_RGB(206, 231, 255);
|
||||
rtgui_dc_draw_hline(dc, 14, 14 + (tinfo.position * 212)/ tinfo.duration,
|
||||
75);
|
||||
rtgui_dc_draw_hline(dc, 14, 14 + (tinfo.position * 212) / tinfo.duration, 75);
|
||||
|
||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = saved;
|
||||
rtgui_dc_end_drawing(dc);
|
||||
|
@ -137,7 +136,7 @@ static void player_update_tag_info(struct rtgui_dc* dc)
|
|||
{
|
||||
rect.x1 = rect.x2 - 64;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -147,6 +146,7 @@ static void player_update_tag_info(struct rtgui_dc* dc)
|
|||
void play_mp3_file(const char* fn)
|
||||
{
|
||||
struct rtgui_dc* dc;
|
||||
rtgui_color_t saved;
|
||||
|
||||
/* get music tag information */
|
||||
mp3_get_info(fn, &tinfo);
|
||||
|
@ -165,6 +165,12 @@ void play_mp3_file(const char* fn)
|
|||
/* update tag information */
|
||||
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 */
|
||||
button = rtgui_image_create_from_mem("hdc",
|
||||
play_hdh, sizeof(play_hdh), RT_FALSE);
|
||||
|
@ -223,8 +229,6 @@ void function_filelist(void* parameter)
|
|||
rt_uint32_t length;
|
||||
|
||||
length = read_line(fd, line, sizeof(line));
|
||||
if (strcmp(line, "#EXTM3U") == 0)
|
||||
{
|
||||
/* clear old play list */
|
||||
play_list_clear();
|
||||
|
||||
|
@ -242,7 +246,6 @@ void function_filelist(void* parameter)
|
|||
else play_list_append(line);
|
||||
}
|
||||
} while (length > 0);
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +404,7 @@ static rt_bool_t home_view_event_handler(struct rtgui_widget* widget, struct rtg
|
|||
|
||||
rect.x1 = rect.x2 - 64;
|
||||
rt_snprintf(line, sizeof(line), "%02d:%02d:%02d",
|
||||
item->duration / 360,
|
||||
item->duration / 3600,
|
||||
item->duration / 60,
|
||||
item->duration % 60);
|
||||
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);
|
||||
|
||||
saved = RTGUI_WIDGET_FOREGROUND(widget);
|
||||
|
||||
RTGUI_WIDGET_FOREGROUND(widget) = RTGUI_RGB(82, 199, 16);
|
||||
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);
|
||||
|
||||
saved = RTGUI_WIDGET_FOREGROUND(widget);
|
||||
|
||||
RTGUI_WIDGET_FOREGROUND(widget) = RTGUI_RGB(82, 199, 16);
|
||||
rtgui_dc_draw_hline(dc, 14, 226, 75);
|
||||
|
||||
|
|
Loading…
Reference in New Issue