📄 audioplayerdisplaylyric.c
字号:
//gui_fill_rectangle(x1, y1, x2, y2,gui_color(0,0,0));
gdi_draw_solid_rect(x1,y1,x2,y2,GDI_COLOR_TRANSPARENT);
//dyj modify 20061208
#else
gui_fill_rectangle(x1, y1, x2, y2,gui_color(0,71,114));
#endif
#endif
// wangbei del end
gui_pop_clip();
#if(UI_DOUBLE_BUFFER_SUPPORT)
gui_unlock_double_buffer();
gui_BLT_double_buffer( x1, y1, x2, y2 );
#endif
}
U16 lyric_MixCodeToUnicode2String(U8 *pOutBuffer, U8 *pInBuffer )
{
S16 count = -1;
S16 source = 0;
U8 arrOut[2];
while( pInBuffer[source] != '\0')
{
if(pInBuffer[source]==0x92)
{
pOutBuffer[++count] = 0x27;
pOutBuffer[++count] = 0x0;
}
else
{
pOutBuffer[++count] = pInBuffer[source];
pOutBuffer[++count] = 0x0;
}
source++;
}
pOutBuffer[++count] = '\0';
pOutBuffer[++count] = '\0';
return count + 1;
}
//NicoLin modify for lyric synchronize display use app based memory 20070525
// BOOL lyric_mmi_reader_lyric()
void lyric_mmi_reader_lyric(void)
//NicoLin modify end
{
FS_HANDLE fh;
S32 nBytes; /*每行歌词的长度*/
S32 CurPos=0;
S32 nMinutes,nSeconds,n10ms;
S8 RowNum=0;
S32 character_height, w,w1;
S32 i=0;
S32 Position=0;
S32 PrevPos=0;
S32 StrLen=0;
S32 TotalLen=0;
S16 LyricIndex=0;
S16 DisplayLineIndex=0;
S32 Numof10ms=0;
S8 inBuff[LYRIC_MaxRealNum];
S16 DestBuf[LYRIC_MaxRealNum];
S8 tempBuff[LYRIC_MaxRealNum];
S8 *tempAddress;
Lyric TempLyric;
S16 Index=0;
S16 TempValue=0;
UI_character_type filefullnameWithoutExt[FMGR_MAX_PATH_LEN+1];
UI_character_type ext[FMGR_MAX_EXT_LEN+1];
UI_character_type lyricname[FMGR_MAX_PATH_LEN+4];
LyricFlag = FALSE; //add by liuxn 20070510
memset(inBuff,0,LYRIC_MaxRealNum);
memset(DestBuf,0,LYRIC_MaxRealNum);
memset(tempBuff,0,LYRIC_MaxRealNum);
//NicoLin add for lyric synchronize display use app based memory 20070525
#ifdef __LYRIC_USE_APP_ASM__
if ((NULL == MyLyric) ||( NULL== Lyric_Info) ||(NULL==Lyric_List))
{
if (!mmi_lyric_alloc_app_asm())
{
mmi_lyric_free_app_asm();
// kal_prompt_trace(MOD_MED, "Lyric debug:mmi_lyric_alloc_app_asm() = FALSE");
return;
}
}
#endif /* __LYRIC_USE_APP_ASM__ */
if(MyLyric!=NULL)
{
memset(MyLyric,0,(LYRIC_MaxRealNum)*sizeof(Lyric));
//kal_prompt_trace(MOD_MED, "Lyric debug:memset(MyLyric,0,.......)");
}
if(Lyric_Info!=NULL)
{
memset(Lyric_Info,0,(LYRIC_MaxDisplayLine+3)*sizeof(LyricInfo));
//kal_prompt_trace(MOD_MED, "Lyric debug:memset(Lyric_Info,0,.....)");
}
if(Lyric_List!=NULL)
{
memset(Lyric_List,0,LYRIC_MaxLyricNum*LYRIC_MaxLen);
//kal_prompt_trace(MOD_MED, "Lyric debug:memset(Lyric_List,0,.....)");
}
//memset(MyLyric,0,sizeof(MyLyric));
//NicoLin add end
mmi_audply_split_filename_ext(g_audply.filefullname,filefullnameWithoutExt,ext);
pfnUnicodeStrcat((S8 *)filefullnameWithoutExt,(S8*) L".lrc");
pfnUnicodeStrcpy((S8 *)lyricname,(S8 *)filefullnameWithoutExt);
fh = FS_Open((U16 *)lyricname, FS_READ_ONLY);
if(fh>0)
{
LyricFlag=TRUE;
gui_hide_animations();
//lrj add begin 20060829
#ifdef __MMI_AUDIO_SPECTRUM_DISPLAY__
if( g_audply.spectrum_style != 0 )
mmi_audply_spectrum_display_stop();
#endif // __MMI_AUDIO_SPECTRUM_DISPLAY__
//lrj add end
/* 在切换歌曲时还没有来得及读歌词的情况下切换皮肤时可能导致歌词
和动画效果同时显示*/
nTimersNum=0;
while((nBytes=lyric_mmi_get_one_line_lyric(inBuff, fh)) != 0)
{
// kal_prompt_trace(MOD_MED,"AAAAAAAAAAA %s",inBuff);
// kal_prompt_trace(MOD_MED,"AAAAAAAAAAA nbytes=%d",nBytes);
//lrj add beign 20061110
/*如果没有找到换行符,则认为无效的歌词*/
if(nBytes==LYRIC_MaxLen)
{
LyricFlag=FALSE;
//NicoLin modify for lyric synchronize display use app based memory 20070525
//return FALSE;
return ;
//NicoLin modify end
}
//lrj add end
i=0;
CurPos=0;
tempAddress=(S8 *)tempBuff;
while(i<(nBytes-6))
{
if(i<nBytes-9)
{
if((inBuff[i]=='[')&&(inBuff[i+9]==']'))
{
if((inBuff[i+3]==':')&&(inBuff[i+6]=='.'))
{
if(((inBuff[i+1]>='0')&&(inBuff[i+1]<='9'))
&&((inBuff[i+2]>='0')&&(inBuff[i+2]<='9'))
&&((inBuff[i+4]>='0')&&(inBuff[i+4]<='9'))
&&((inBuff[i+5]>='0')&&(inBuff[i+5]<='9'))
&&((inBuff[i+7]>='0')&&(inBuff[i+7]<='9'))
&&((inBuff[i+8]>='0')&&(inBuff[i+8]<='9')))
{
nMinutes=(inBuff[i+1]-'0')*10+inBuff[i+2]-'0';
nSeconds=(inBuff[i+4]-'0')*10+inBuff[i+5]-'0';
n10ms=(inBuff[i+7]-'0')*10+inBuff[i+8]-'0';
Numof10ms=nMinutes*60*100+nSeconds*100+n10ms; /*歌词播放的时间,10ms为单位*/
TempLyric.Timer=Numof10ms;
TempLyric.LyricIndex=LyricIndex;
// kal_prompt_trace(MOD_MED,"CCCCCCCC Timer=%d,LyricIndex=%d",Numof10ms,LyricIndex);
nTimersNum++;
lyric_InsertMyLyric(TempLyric); /*把歌词的时间信息添加到歌词列表中*/
// kal_prompt_trace(MOD_MED,"CCCCCCCC i=%d,CurPos=%d",i,CurPos);
if((i-CurPos)>0)
{
strncpy((S8 *)tempAddress,(S8 *)(&inBuff[CurPos]),i-CurPos);
}
tempAddress=tempAddress+i-CurPos;
// kal_prompt_trace(MOD_MED,"CCCCCCCC tempAddress=%d",tempAddress);
CurPos=i+10;
}
}
}
}
if((inBuff[i]=='[')&&(inBuff[i+6]==']'))
{
if((inBuff[i+3]==':'))
{
if(((inBuff[i+1]>='0')&&(inBuff[i+1]<='9'))
&&((inBuff[i+2]>='0')&&(inBuff[i+2]<='9'))
&&((inBuff[i+4]>='0')&&(inBuff[i+4]<='9'))
&&((inBuff[i+5]>='0')&&(inBuff[i+5]<='9')))
{
nMinutes=(inBuff[i+1]-'0')*10+inBuff[i+2]-'0';
nSeconds=(inBuff[i+4]-'0')*10+inBuff[i+5]-'0';
// n10ms=(inBuff[i+7]-'0')*10+inBuff[i+8]-'0';
Numof10ms=nMinutes*60*100+nSeconds*100;//+n10ms; /*歌词播放的时间,10ms为单位*/
TempLyric.Timer=Numof10ms;
TempLyric.LyricIndex=LyricIndex;
nTimersNum++;
lyric_InsertMyLyric(TempLyric); /*把歌词的时间信息添加到歌词列表中*/
// kal_prompt_trace(MOD_MED,"CCCCCCCC i=%d,CurPos=%d",i,CurPos);
if((i-CurPos)>0)
{
strncpy((S8 *)tempAddress,(S8 *)(&inBuff[CurPos]),i-CurPos);
}
tempAddress=tempAddress+i-CurPos;
// kal_prompt_trace(MOD_MED,"CCCCCCCC tempAddress=%d",tempAddress);
CurPos=i+7;
}
}
}
i++;
}
strcpy((S8 *)tempAddress,(S8 *)&inBuff[CurPos]);
#if defined(__MMI_CHSET_BIG5__)||defined(__MMI_CHSET_GB2312__)
mmi_chset_convert(MMI_CHSET_GB2312,MMI_CHSET_UCS2,tempBuff,(S8 *)DestBuf,LYRIC_MaxRealNum);
#else
lyric_MixCodeToUnicode2String((U8 *)DestBuf,(U8 *)tempBuff);
#endif
pfnUnicodeStrcpy((S8 *)Lyric_List[LyricIndex],(S8 *)DestBuf);
LyricIndex++;
}
TempValue=nTimersNum;
memset(Lyric_Info,0,sizeof(Lyric_Info));
/*对排序好的歌词列表根据显示的需要重新排序*/
while((TempValue--)>0)
{
/*获取整个要显示的一句歌词的长度*/
// kal_prompt_trace(MOD_MED,"AAAA Index=%d ",Index);
// kal_prompt_trace(MOD_MED,"AAAA DisplayLineIndex=%d ",DisplayLineIndex);
gui_measure_string((UI_string_type)Lyric_List[MyLyric[Index].LyricIndex], &w, &character_height );
StrLen=pfnUnicodeStrlen((S8 *)Lyric_List[MyLyric[Index].LyricIndex]);
StrLen=StrLen*2;/*转换成实际字节长度*/
TotalLen=StrLen;
while(StrLen>0)
{
for(i=PrevPos;i<=TotalLen;i+=2)
{
gui_measure_string((UI_string_type)(&(Lyric_List[MyLyric[Index].LyricIndex][i])),&w1,&character_height );
if((w-w1)>audply_main_music_wave.w)
{
Position=i-2;
gui_measure_string((UI_string_type)(&(Lyric_List[MyLyric[Index].LyricIndex][Position])),&w,&character_height );
break;
}
else
{
Position=i;
}
}
if (i==TotalLen)
Position+= 2;
// kal_prompt_trace(MOD_MED,"Position=%d,PrevPos=%d,StrLen=%d,w=%d",Position,PrevPos,StrLen,w);
pfnUnicodeStrncpy((S8 *)Lyric_Info[DisplayLineIndex++].Lyric_OnDispaly,(S8 *)(&Lyric_List[MyLyric[Index].LyricIndex][PrevPos]),(Position-PrevPos)/2);
StrLen =StrLen-(Position-PrevPos);
PrevPos=Position;
RowNum++;
}
Lyric_Info[DisplayLineIndex-RowNum].TimeInfo=MyLyric[Index].Timer;
Lyric_Info[DisplayLineIndex-RowNum].LineNum=RowNum;
PrevPos=0;
Position=0;
RowNum=0;
Index++;
}
DisplayLineNum=DisplayLineIndex;
FS_Close(fh);
//NicoLin modify for lyric synchronize display use app based memory 20070525
//return TRUE;
return ;
//NicoLin modify end
}
else
{
LyricFlag=FALSE;
//NicoLin modify for lyric synchronize display use app based memory 20070525
//return FALSE;
return ;
//NicoLin modify end
}
}
void lyric_DisplayLyric(void)
{
S32 x_begin = audply_main_music_wave.x;
S32 y_begin = audply_main_music_wave.y;
S32 x_end = audply_main_music_wave.x + audply_main_music_wave.w -1;
S32 y_end =audply_main_music_wave.y+ audply_main_music_wave.h - 1;
S32 character_height;
//wangbei add start 20071010
#ifdef __NEW_AUDIO_SKIN_UI_STYLE__
color c =gui_color (205, 197, 29);
#endif
//wangbei add end
if( g_audply.in_main_screen )
{
#if(UI_DOUBLE_BUFFER_SUPPORT)
gui_lock_double_buffer();
#endif
gui_push_clip();
gui_set_clip( x_begin, y_begin, x_end, y_end );
gui_push_text_clip();
gui_set_text_clip( x_begin, y_begin, x_end, y_end);
gui_set_font( &MMI_medium_font );
// background
lyric_mmi_audply_redraw_main_lrc_background();
// 第一行
if(LyricCount>=1)
{
//wangbei modify start 20071010
#ifndef __NEW_AUDIO_SKIN_UI_STYLE__
gui_set_text_color( text_fg_color );
#else
gui_set_text_color( c );
#endif
//wangbei modify end
gui_move_text_cursor( x_begin , y_firt_row );
gui_print_text((UI_string_type)Lyric_Info[LyricCount-1].Lyric_OnDispaly);
}
//第二行
//wangbei modify start 20071010
#ifndef __NEW_AUDIO_SKIN_UI_STYLE__
gui_set_text_color( text_fg_color );
#else
gui_set_text_color( c );
#endif
//wangbei modify end
gui_move_text_cursor( x_begin , y_sencond_row);
gui_print_text( (UI_string_type)Lyric_Info[LyricCount].Lyric_OnDispaly);
//第三行
//wangbei modify start 20071010
#ifndef __NEW_AUDIO_SKIN_UI_STYLE__
gui_set_text_color( text_fg_color );
#else
gui_set_text_color( c );
#endif
// wangbei modify end
gui_move_text_cursor( x_begin , y_third_row);
gui_print_text((UI_string_type)Lyric_Info[LyricCount+1].Lyric_OnDispaly);
//第四行
//wangbei modify start 20071010
#ifndef __NEW_AUDIO_SKIN_UI_STYLE__
gui_set_text_color( text_fg_color );
#else
gui_set_text_color( c );
#endif
//wangbei modify end
gui_move_text_cursor( x_begin , y_fourth_row);
gui_print_text((UI_string_type)Lyric_Info[LyricCount+2].Lyric_OnDispaly);
gui_pop_text_clip();
gui_pop_clip();
#if(UI_DOUBLE_BUFFER_SUPPORT)
gui_unlock_double_buffer();
gui_BLT_double_buffer( x_begin, y_begin, x_end, y_end );
#endif
}
}
void lyric_Lyric_Scrolling_Display()
{
if(Scrolling_Index<ScrollingNum)
{
StartTimer(LYRIC_SCROLLING_TIMER,Scrolling_Freq,lyric_Lyric_Scrolling_Display);
Scrolling_Index++;
}
else
{
return;
}
lyric_DisplayLyric();
y_firt_row -=Pixtel_EveryTime;
y_sencond_row -=Pixtel_EveryTime;
y_third_row -=Pixtel_EveryTime;
y_fourth_row -=Pixtel_EveryTime;
if(y_firt_row<=(audply_main_music_wave.y-audply_main_title.h+Pixtel_EveryTime))
{
LyricCount++;
y_firt_row=y_firt_row+audply_main_title.h+6;
y_sencond_row=y_firt_row+audply_main_title.h+6;
y_third_row=y_sencond_row+audply_main_title.h+6;
y_fourth_row=y_third_row+audply_main_title.h+6;
}
}
void lyric_mmi_audply_redraw_main_title( void )
{
S32 character_height, w;
S32 x1 = audply_main_title.x;
S32 y1 = audply_main_title.y;
S32 x2 = audply_main_title.x + audply_main_title.w - 1;
S32 y2 = audply_main_title.y + audply_main_title.h - 1;
if( !init_scrolling_done )
{
gui_create_scrolling_text( &audply_main_scrolling_title,
x1, y1, audply_main_title.w, audply_main_title.h, g_audply.title,
mmi_audply_scroll_main_title_handler, mmi_audply_redraw_main_title_background,
/*gui_color(0,9,255),*//*gui_color(2,211,255), *//*gui_color(255,255,255),*/
gui_color(213,188,53),// wangbei add 20070416
// wangbei del start 20070416
#if 0
#ifdef __MT160_MP3PLAYER_FONT_COLOR__ //add by liuxn 20070510
gui_color(213,188,53),
//add by liuxn begin 20070510
#else
gui_color(2,211,255),
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -