完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在ucos和ucgui中加入音乐播放后 音乐播放一段后就从头开始播放 找不到原因
这是代码 #include "musicplay.h" FIL* fmp3; u8 MusicPlayBuffer[520]; char musicbuf[30]; char musicbuf1[38] = {"0:/MUSIC/"}; _MusicInfo musicinfo= { 1, 0, "???????è?ú", }; TEXT_Handle hText_MusicPlay; OS_STK PlaySong_Task_Stk[PLAYSONG_TASK_STK_SIZE]; void PlaySong_TaskInit(void *pdata); u8 mp3_play_song(u8 *pname); static const GUI_WIDGET_CREATE_INFO MusicListCreate[] = { { FRAMEWIN_CreateIndirect, "??????±í", 0, 0, 0, 240,320,FRAMEWIN_CF_MOVEABLE,0}, { BUTTON_CreateIndirect, "??·?", GUI_ID_BUTTON0, 43, 268,55, 25, 0,0}, { BUTTON_CreateIndirect, "????", GUI_ID_BUTTON1, 138,268,55, 25, 0,0}, { LISTBOX_CreateIndirect, NULL, GUI_ID_LISTBOX0, -3, -3, 237,265,0,0} }; void MusicListPaintDialog(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; } void MusicListInitDialog(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; // //FRAMEWIN // FRAMEWIN_SetFont(hWin,&GUI_FontHZ_MicrosoftFont_13); // FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0); FRAMEWIN_AddMaxButton(hWin, FRAMEWIN_BUTTON_RIGHT, 1); FRAMEWIN_AddMinButton(hWin, FRAMEWIN_BUTTON_RIGHT, 2); FRAMEWIN_SetTitleHeight(hWin,20); // //GUI_ID_BUTTON0 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON0),&GUI_FontHZ_MicrosoftFont_13); // //GUI_ID_BUTTON1 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON1),&GUI_FontHZ_MicrosoftFont_13); // //GUI_ID_LISTBOX0 // LISTBOX_SetFont(WM_GetDialogItem(hWin,GUI_ID_LISTBOX0),&GUI_FontHZ_MicrosoftFont_13); LISTBOX_SetAutoScrollV(WM_GetDialogItem(hWin,GUI_ID_LISTBOX0),1); // LISTBOX_SetAutoScrollH(WM_GetDialogItem(hWin,GUI_ID_LISTBOX0),1); } /********************************************************************************************************** ** ????????: ThemecolorsCallback ** ????: ?÷?????????÷???? ** ????: pMsg ** ????: ?? ** ·?????: ?? **********************************************************************************************************/ static void MusicListCallback(WM_MESSAGE * pMsg) { int NCode, Id; //u8 res; WM_HWIN hWin = pMsg->hWin; LISTBOX_Handle hMusicPlayList; hMusicPlayList = WM_GetDialogItem(hWin,GUI_ID_LISTBOX0); switch (pMsg->MsgId) { case WM_PAINT: MusicListPaintDialog(pMsg); break; case WM_INIT_DIALOG: MenuDisnable++; MusicListInitDialog(pMsg); exfuns_scan("0:/MUSIC"); for(Id=0;Id LISTBOX_AddString(hMusicPlayList, (char*)FileList[Id]); } break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hWin, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (NCode) { case WM_NOTIFICATION_RELEASED: if(Id==GUI_ID_BUTTON0) { musicinfo.PlaySongFlag=0; // f_close(fmp3); //??±????? musicinfo.PlaySongNowNum = LISTBOX_GetSel(hMusicPlayList);//·????????????????ù???????? LISTBOX_GetItemText(hMusicPlayList,musicinfo.PlaySongNowNum,(char *)musicbuf,30); strcpy(musicinfo.MusicName,musicbuf); strcat(musicbuf1,musicbuf); // VS_Reset_DecodeTime();// // f_open(fmp3, musicbuf1, FA_OPEN_EXISTING | FA_READ); musicinfo.PlaySongFlag=1; // mp3_play_song(buf1); // GUI_EndDialog(hWin, 0); // MenuDisnable--; } else if(Id==GUI_ID_BUTTON1) { GUI_EndDialog(hWin, 1); MenuDisnable--; } break; default: break; } break; default: WM_DefaultProc(pMsg); break; } } void MusicPlay_TaskInit(void *pdata) { u8 i; WM_HWIN hMusicPlay; BUTTON_Handle hButton_MusicPlay[5]; PROGBAR_Handle ahMusicPlay; MenuList pos=NULL; (void)pdata; Menu_ID=MusicPlayeMenu_ID; OtherMenu_pHead=MenuListNodeCreate();//???¨???ò??±í pos=OtherMenu_pHead;//??????±í?·?á?? exfuns_scan("0:/MUSIC"); hText_MusicPlay=TEXT_Create(5,20, 200, 25,5, WM_CF_SHOW,(const char*)musicinfo.MusicName,TEXT_CF_LEFT); TEXT_SetTextAlign(hText_MusicPlay,GUI_TA_CENTER); TEXT_SetTextColor(hText_MusicPlay,ThemeColor); TEXT_SetFont(hText_MusicPlay,&GUI_FontHZ_MicrosoftFont_13); pos=MenuListInsert(OtherMenu_pHead,pos,hText_MusicPlay); ahMusicPlay=PROGBAR_Create(5,185,235,6,WM_CF_SHOW); PROGBAR_SetBarColor(ahMusicPlay,0,ThemeColor); PROGBAR_SetValue(ahMusicPlay,0); pos=MenuListInsert(OtherMenu_pHead,pos,ahMusicPlay); hButton_MusicPlay[0]=BUTTON_Create(5, 200, 60, 30, Button_ID0, WM_CF_SHOW); hButton_MusicPlay[1]=BUTTON_Create(80, 200, 80, 30, Button_ID1, WM_CF_SHOW); hButton_MusicPlay[2]=BUTTON_Create(175, 200, 60, 30, Button_ID2, WM_CF_SHOW); hButton_MusicPlay[3]=BUTTON_Create(5, 235, 60, 30, Button_ID3, WM_CF_SHOW); hButton_MusicPlay[4]=BUTTON_Create(5, 270, 60, 30, Button_ID4, WM_CF_SHOW); BUTTON_SetText(hButton_MusicPlay[0],"?????ú"); BUTTON_SetText(hButton_MusicPlay[1],"??·?/????"); BUTTON_SetText(hButton_MusicPlay[2],"?????ú"); BUTTON_SetText(hButton_MusicPlay[3],"??·???±í"); BUTTON_SetText(hButton_MusicPlay[4],"???÷????"); for(i=0;i<5;i++) //??°??ü??????±í { BUTTON_SetFont(hButton_MusicPlay,&GUI_FontHZ_MicrosoftFont_13); BUTTON_SetTextAlign(hButton_MusicPlay,GUI_TA_CENTER|GUI_TA_VERTICAL); BUTTON_SetTextColor(hButton_MusicPlay,0,GUI_WHITE); BUTTON_SetBkColor(hButton_MusicPlay,0,ThemeColor); pos=MenuListInsert(OtherMenu_pHead,pos,hButton_MusicPlay); } OtherMenu_Info.FirstHandle =hText_MusicPlay; OtherMenu_Info.EndHandle =hButton_MusicPlay[4]; ViscousWM(OtherMenu_pHead);//???????????????§?? OSTaskCreate(PlaySong_TaskInit,(void*)0,&laySong_Task_Stk[PLAYSONG_TASK_STK_SIZE-1],PLAYSONG_TASK_PRIO); while(1) { if(TouchCmd == 1) { TouchCmd=0; switch(GUI_GetKey()) { case Button_ID0: break; case Button_ID1: break; case Button_ID2: break; case Button_ID3: exfuns_scan("0:/MUSIC"); hMusicPlay=GUI_CreateDialogBox(MusicListCreate, GUI_COUNTOF(MusicListCreate), &MusicListCallback, 0, 0, 0); // MyCreatDialog(0,0,hMusicPlay); break; case Button_ID4: Out_OtherMenu(); //?????è?????? Go_MainMenu(); //?????÷???? OSTaskDel(OS_PRIO_SELF); //????×??? break; default : TouchCmd = 1; break; } } OSTimeDlyHMSM(0, 0, 0, 15); } } void PlaySong_TaskInit(void *pdata) { VS_HD_Reset(); VS_Soft_Reset(); vsset.mvol=220; while(1) { while(musicinfo.PlaySongFlag==1) { mp3_play_song((u8*)musicbuf1); } OSTimeDlyHMSM(0, 0, 0, 6); } } u8 mp3_play_song(u8 *pname) { OS_CPU_SR cpu_sr; u16 br; u8 res,rval; u8 *databuf; u16 i=0,j; //u8 key; rval=0; fmp3=(FIL*)mymalloc(SRAMIN,sizeof(FIL));//?ê?????? databuf=(u8*)mymalloc(SRAMIN,512); //??±?4096×????????????ò if(databuf==NULL||fmp3==NULL)rval=0XFF ;//?????ê???§°?. VS_Restart_Play(); //??????·? VS_Set_All(); //?è???????????? VS_Reset_DecodeTime(); //?????????±?? // res=f_typetell(pname); //?????????ó×? OS_ENTER_CRITICAL(); res=f_open(fmp3,(const TCHAR*)pname,FA_READ);//?ò????? OS_EXIT_CRITICAL(); if(res==0)//?ò??????. { // VS_SPI_SpeedHigh();//???? while(1) { res=f_read(fmp3,SD_Buffer,512,(UINT*)&br);//????4096??×??? i=0; if(br<512) { f_close(fmp3); break; } VS_XDCS=0; while(i<500) { while(VS_DQ==0) OSTimeDlyHMSM(0, 0, 0, 2); for(j=i;j!=i+32;j++) SPI1_ReadWriteByte(SD_Buffer[j]); i+=32; } // if(res!=0) } } myfree(SRAMIN,databuf); myfree(SRAMIN,fmp3); return rval; } |
|
相关推荐
7个回答
|
|
解决了 换了ucos和ucgui之后就行了
|
|
|
|
没人遇到过类似问题嘛 搞了几天了 找不到问题出在哪啊啊啊啊啊啊
|
|
|
|
音乐播放时最高级任务 不可能被打断啊 可是将播放音乐的代码进入临界区就可以完整播放 这是怎么回事?
|
|
|
|
帮顶。。。。。
|
|
|
|
|
|
|
|
|
|
|
|
应该不是堆栈的问题 进入临界区是可以正常播放的
|
|
|
|
只有小组成员才能发言,加入小组>>
791 浏览 0 评论
1151 浏览 1 评论
2527 浏览 5 评论
2860 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2710 浏览 6 评论
keil5中manage run-time environment怎么是灰色,不可以操作吗?
1070浏览 3评论
193浏览 2评论
455浏览 2评论
368浏览 2评论
M0518 PWM的电压输出只有2V左右,没有3.3V是怎么回事?
453浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 01:37 , Processed in 1.366963 second(s), Total 93, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号