Ejemplo n.º 1
0
/**
  * @brief  Callback function of the MJPEG frame
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbVideoWindow(WM_MESSAGE * pMsg) 
{
  char temp[20];
  static WM_HTIMER hTimerTime;
  WM_HWIN hItem;  
  const GUI_PID_STATE * pState;
  
  GUI_RECT r;
  WM_GetInsideRect(&r);
  
  switch (pMsg->MsgId) 
  {
    
  case  WM_TOUCH:
    if(VideoPlayer_State == VIDEO_PLAY)
    {
      pState = (const GUI_PID_STATE *)pMsg->Data.p;
      if (pState) {
        if (pState->Pressed == 1) {
          VIDEO_Enlarge ^= 1;
          if(VIDEO_Enlarge)
          {
            GUI_SetOrientation(GUI_SWAP_XY | GUI_MIRROR_Y);
            TS_Orientation = 1;
            WM_AttachWindowAt(pMsg->hWin, WM_HBKWIN, 0, 0);
            WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize());
          }
          else
          {
            WM_AttachWindow(pMsg->hWin, bkparent);
            GUI_SetOrientation(0);
            TS_Orientation = 0;
            WM_InvalidateWindow(bkparent);    
            
            WM_AttachWindowAt(pMsg->hWin, VIDEO_hWin, 5, 16);
            WM_SetSize(pMsg->hWin,230, 170);
            do_clear = 1;
          }
        }
      }
    }
    break;
    
    
  case WM_CREATE:
    /* Create timer */
    hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 50, 0);        
    break;
    
  case WM_TIMER:
    WM_InvalidateWindow(pMsg->hWin);
    WM_RestartTimer(pMsg->Data.v, 0);
    
    break; 
    
  case WM_DELETE:
    WM_DeleteTimer(hTimerTime);
    break;

    
  case WM_PAINT:
    
    if(do_clear)
    {
      GUI_ClearRectEx(&r);
      do_clear = 0;
    } 
    
    if(VideoPlayer_State == VIDEO_PLAY)
    {
      if(_PlayMJPEG(&Video_File) < 0)
      {
        VideoPlayer_State = VIDEO_PLAY;
        ImageOffset = 0; 
        time_start = GUI_GetTime();    
        f_close(&Video_File);
        goto_next_file();      
        hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_FILE);
        TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line);        
      }
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_PROGRESS);
      
      if (progress_bar == 0)
      {
        SLIDER_SetValue(hItem, (ImageOffset * 100 )/ Video_File.fsize);
      }
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_DURATION);
      
      duration = (GUI_GetTime() - time_start )/1000;
      if(duration < 0) duration = 0;
      sprintf(temp,"%02d:%02d", duration/60, duration%60); 
      TEXT_SetText(hItem, temp);  
    }
    else if(VideoPlayer_State == VIDEO_IDLE)
    {
      GUI_ClearRectEx(&r);
    }
    
    break;
    
  default:
    WM_DefaultProc(pMsg);
  }
  
}
Ejemplo n.º 2
0
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem, hClient;
  GUI_RECT r;
  int Id, NCode, offset;
  
  switch (pMsg->MsgId) 
  {
  case WM_INIT_DIALOG:
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_DURATION);   
    TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII);
    TEXT_SetTextColor(hItem, 0x00804000);   
    
    hClient = WM_GetClientWindow(pMsg->hWin);
    WM_GetClientRectEx(hClient, &r);
    hVideoScreen = WM_CreateWindowAsChild(r.x0 + 2, r.y0 + 2, r.x1 - 2, r.y1 - 118, hClient, WM_CF_SHOW, _cbVideoWindow , 0);
    hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO);
    
    BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlayPauseOn, 16, 6);
    BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6);
    
    hItem = WM_GetDialogItem(pMsg->hWin, PREV_BUTTON_VIDEO);     
    BUTTON_SetBitmapEx(hItem, 0, &bmButtonPreviousOn, 16, 6);
    BUTTON_SetBitmapEx(hItem, 1, &bmButtonPreviousOff,16, 6);
    
    hItem = WM_GetDialogItem(pMsg->hWin, NEXT_BUTTON_VIDEO);     
    BUTTON_SetBitmapEx(hItem, 0, &bmButtonNextOn, 16, 6);
    BUTTON_SetBitmapEx(hItem, 1, &bmButtonNextOff,16, 6); 
    
    hItem = WM_GetDialogItem(pMsg->hWin, STOP_BUTTON_VIDEO);     
    BUTTON_SetBitmapEx(hItem, 0, &bmButtonStopOn, 16, 6);
    BUTTON_SetBitmapEx(hItem, 1, &bmButtonStopOff,16, 6); 
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_PROGRESS);       
    SLIDER_SetRange(hItem, 0, 100);
    SLIDER_SetWidth( hItem, 5);
    VideoPlayer_State = VIDEO_IDLE;
    
    _GetMJPEGFileList("0:");
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE);   
    if (FILEMGR_FileList.ptr == 0)
    {
      TEXT_SetFont(hItem, GUI_FONT_20B_ASCII);
      TEXT_SetTextColor(hItem, GUI_BROWN);
    }
    else
    {
      TEXT_SetFont(hItem, GUI_FONT_13B_ASCII);
      TEXT_SetTextColor(hItem, 0x00804000);
    }
    
    do_clear = 1;
    
    if (FILEMGR_FileList.ptr > 0)
    {
      if(f_open(&Video_File, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line, FA_OPEN_EXISTING | FA_READ) == FR_OK)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE);
        TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line);            
        VideoPlayer_State = VIDEO_PLAY;
        ImageOffset = 0;
        time_start = GUI_GetTime();
        hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO);
        BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6);
        BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6);
      }
      else
      {
        /* error */
      }
    }
    break;
    
  case WM_PAINT: 
    break;
   
  case  WM_NOTIFY_CHILD_HAS_FOCUS:
    do_clear = 1;
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    
    if(NCode == WM_NOTIFICATION_CHILD_DELETED)
    {
      f_close(&Video_File);
      WM_NotifyParent(WM_GetParent(pMsg->hWin), 0x500);      
      break; 
    }   
    
    switch(Id) {
      
    case PLAY_BUTTON_VIDEO: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if(VideoPlayer_State == VIDEO_IDLE)
        {
          if (FILEMGR_FileList.ptr > 0)
          {
            if(f_open(&Video_File, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line, FA_OPEN_EXISTING | FA_READ) == FR_OK)
            {
              hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE);
              TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line);            
              VideoPlayer_State = VIDEO_PLAY;
              ImageOffset = 0;
              time_start = GUI_GetTime();
              hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO);
              BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6);
              BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6);
            }
            else
            {
              /* error */
            }
          }
          else
          {
            /* No file */
          }
        }
        else if(VideoPlayer_State == VIDEO_PLAY)
        {
          time_pause = GUI_GetTime();
          hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO);
          BUTTON_SetBitmapEx(hItem, 0, &bmButtonPause, 16, 6);
          BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6);
          VideoPlayer_State = VIDEO_PAUSE;
        }
        else if(VideoPlayer_State == VIDEO_PAUSE)
        {
          time_start = GUI_GetTime()+ time_start - time_pause ;
          hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO);
          BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6);
          BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6);
          VideoPlayer_State = VIDEO_PLAY;
        }        
        break;
      }
      break;
    case PREV_BUTTON_VIDEO: /* Notifications sent by 'Button' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          ImageOffset = 0;  
          time_start = GUI_GetTime();
          VideoPlayer_State = VIDEO_PLAY;
          f_close(&Video_File);
          goto_previous_file();
          hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE);
          TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line);   
          hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO);
          BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6);
          BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,6, 6);
        }
        break;
      }
      break;
      
      
    case ID_VIDEO_EXIT:
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        {
          GUI_EndDialog(pMsg->hWin, 0);
        }
        break;        
      }
      break;
      
    case ID_VIDEO_PROGRESS: /* Notifications sent by 'Progress Bar' */
      switch(NCode) {
        
      case WM_NOTIFICATION_CLICKED:
        {
          progress_bar = 1;
          hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_PROGRESS);
          ImageOffset = (Video_File.fsize * SLIDER_GetValue(hItem))/100;
          offset =ImageOffset - Video_File.fptr;
          time_start -= (offset / frame_speed);
          
          
        }
        break;
        
      case WM_NOTIFICATION_RELEASED:
        progress_bar = 0;
        break;
      }
      break;
      
      
    case NEXT_BUTTON_VIDEO: /* Notifications sent by 'Button' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if(VideoPlayer_State != VIDEO_IDLE)
        {       
          ImageOffset = 0; 
          VideoPlayer_State = VIDEO_PLAY;          
          time_start = GUI_GetTime();
          f_close(&Video_File);
          goto_next_file();      
          hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE);
          TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line);
          hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO);
          BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6);
          BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6);   
        }     
        break;
      }
      break;
    case STOP_BUTTON_VIDEO: /* Notifications sent by 'Button' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        VideoPlayer_State = VIDEO_IDLE;
        hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO);
        BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlayPauseOn, 16, 6);
        BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6);     
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Ejemplo n.º 3
0
/*********************************************************************
*
*       SCROLLBAR__InvalidatePartner
*/
void SCROLLBAR__InvalidatePartner(SCROLLBAR_Handle hObj) {     /* Invalidate the partner, since it is also affected */
  WM_InvalidateWindow(WM_GetScrollPartner(hObj));
  WM_SendMessageNoPara(WM_GetParent(hObj), WM_NOTIFY_CLIENTCHANGE);   /* Client area may have changed */
}