/********************************************************************* * * MainTask */ void MainTask(void) { GUI_MOVIE_INFO Info; GUI_MOVIE_HANDLE hMovie; int xSize, ySize; #ifdef WIN32 HANDLE hFile; const char acFileName[] = "C:\\Work\\Grafik\\Video\\FFmpeg\\FFmpeg.emf"; #define PARAM &hFile #else FS_FILE * pFile; const char acFileName[] = "\\FFmpeg.emf"; #define PARAM pFile #endif GUI_Init(); // // Get display size // xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); // // Create file handle // #ifdef WIN32 hFile = CreateFile(acFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); #else FS_Init(); pFile = FS_FOpen(acFileName, "r"); #endif // // Get physical size of movie // if (GUI_MOVIE_GetInfoEx(_GetData, PARAM, &Info) == 0) { // // Check if display size fits // if ((Info.xSize <= xSize) && (Info.ySize <= ySize)) { // // Create and play movie // hMovie = GUI_MOVIE_CreateEx(_GetData, PARAM, _cbNotify); if (hMovie) { GUI_MOVIE_Show(hMovie, (xSize - Info.xSize) / 2, (ySize - Info.ySize) / 2, 1); } } else { // // Error message // GUI_SetFont(GUI_FONT_13_ASCII); GUI_DispStringHCenterAt("Video can not be shown.\n\nDisplay size too small.", xSize / 2, (ySize - GUI_GetFontSizeY()) / 2); } } while (1) { GUI_Exec(); GUI_X_Delay(1); } }
/** * @brief Start play * @param filename: pointer to the video file name * @retval None */ static uint8_t _StartPlay(GUI_MOVIE_HANDLE *hmovie, char * filename, FIL * file, uint16_t x0, uint16_t y0) { static char tmp[FILEMGR_FILE_NAME_SIZE]; int ms, frames; uint32_t duration; WM_HWIN hItem; if(f_open(file, filename, FA_OPEN_EXISTING | FA_READ) == FR_OK) { PrevFrameIndex = 0; LostFrames = 0; previous_total = 0; GUI_MOVIE_GetInfoEx(_GetData, file, &Video_Info); *hmovie = GUI_MOVIE_CreateEx(_GetData, file, _cbNotify) ; GUI_MOVIE_SetPeriod (*hmovie, VIDEO_FRAME_TIME); if((Video_Info.xSize == 0) || (Video_Info.ySize == 0) || (Video_Info.xSize > 1024) || (Video_Info.ySize > 768)) { GUI_MOVIE_Delete(*hmovie); return 1; } GUI_MOVIE_Show(*hmovie, ((LCD_GetXSize() - Video_Info.xSize)/2), ((LCD_GetYSize() - Video_Info.ySize)/2), 0); hTimer = WM_CreateTimer(playbackwin, 0, 1000, 0); /* Update video total time */ hItem = WM_GetDialogItem(playbackwin, ID_TIME); ms = Video_Info.msPerFrame; frames = Video_Info.NumFrames; duration = (frames * ms)/1000; sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 ); TEXT_SetText(hItem, tmp); WM_InvalidateWindow(playbackwin); elapsed_time = 0; hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_NAME); FILEMGR_GetFileOnly (tmp, filename); TEXT_SetText(hItem, tmp); hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); WM_InvalidateWindow(hItem); WM_Paint(hItem); } return 0; }
/** * @brief Start play * @param filename: pointer to the video file name * @retval None */ static uint8_t _StartPlay(char * filename) { int XPos, YPos, XSize, YSize, nx, ny, n; if(f_open(&Video_File, filename, FA_OPEN_EXISTING | FA_READ) == FR_OK) { GUI_MOVIE_GetInfoEx(_GetData, &Video_File, &Video_Info); if((Video_Info.xSize == 0) || (Video_Info.ySize == 0) || (Video_Info.xSize > 320) || (Video_Info.ySize > 240)) { return 1; } hMovie = GUI_MOVIE_CreateEx(_GetData, &Video_File, _cbNotify); VideoPlayer_State = VIDEO_PLAY; __GetWindowRect(&XPos, &YPos, &XSize, &YSize); nx = (XSize * 1000) / Video_Info.xSize; ny = (YSize * 1000) / Video_Info.ySize; if (nx < ny) { n = nx; } else { n = ny; } XPos = XPos + (XSize - ((Video_Info.xSize * n) / 1000)) / 2; YPos = YPos + (YSize - ((Video_Info.ySize * n) / 1000)) / 2; GUI_MOVIE_ShowScaled(hMovie, XPos, YPos, n, 1000, 0); } return 0; }