Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

IFlip sample code, part 7

Definitions and implemntations of the c_iflipapp_DrawNotice() and c_iflipapp_PlayAudio() and c_iflipapp_MediaNotify() and c_iflipapp_ackBGapp() functions.

/*===========================================================================
FUNCTION c_iflipapp_DrawNotice

DESCRIPTION
This function displays a notice on screen when application launches to give some formal 
information.

PROTOTYPE:
static void c_iflipapp_DrawNotice(c_iflipapp* pMe)

PARAMETERS:
pMe: Pointer to the c_iflipapp structure.
DEPENDENCIES
none

RETURN VALUE
none

SIDE EFFECTS
none
===========================================================================*/

static void c_iflipapp_DrawNotice(c_iflipapp* pMe)
{
   IDISPLAY_ClearScreen(pMe->pIDisplay);
   ISTATIC_SetTextEx(pMe->pIStatic, 
            "Please rotate/swivel to see the events on the screen.
            For flip phone, if audio is disabled, display 'enable the audio'", 
            NULL, FALSE);
   ISTATIC_Redraw(pMe->pIStatic);
}

/*===========================================================================
FUNCTION c_iflipapp_PlayAudio

DESCRIPTION
This function plays the audio.

PROTOTYPE:
static void c_iflipapp_PlayAudio(c_iflipapp* pMe, char * pszFile)

PARAMETERS:
pMe: Pointer to the c_iflipapp structure.
pszFile: stores the file to be played.
DEPENDENCIES
none

RETURN VALUE
none

SIDE EFFECTS
none
===========================================================================*/

static void c_iflipapp_PlayAudio(c_iflipapp* pMe, char * pszFile)
{
   AEEMediaData   md; 
   // Stop if any other file is playing
   if(pMe->pIMedia)
   {
      if (SUCCESS != IMEDIA_Stop(pMe->pIMedia))
	  {
	     DBGPRINTF("Stop failed");
	  }
   }

   if(pMe->pIMedia)
   {
      IMEDIA_Release(pMe->pIMedia);
	  pMe->pIMedia = NULL;
   }
   md.clsData = MMD_FILE_NAME;
   md.pData = (void *)pszFile;
   md.dwSize = 0;

   if(AEEMediaUtil_CreateMedia(pMe->pIShell, &md, &pMe->pIMedia) != SUCCESS)
   {
      DBGPRINTF("Create media failure");
   }
	   
   if (pMe->pIMedia)
   {
   // register to get notifications
   IMEDIA_RegisterNotify(pMe->pIMedia, c_iflipapp_MediaNotify, pMe);
   }
   if(pMe->pIMedia)
   {
      if (SUCCESS !=IMEDIA_Play(pMe->pIMedia))
	  {
	     DBGPRINTF("Play failed");
	  }
   }

}

/*===========================================================================
FUNCTION c_iflipapp_MediaNotify

DESCRIPTION
   Callback function for sound playback notifications

PROTOTYPE:
   static void c_iflipapp_MediaNotify(void * pUser, AEEMediaCmdNotify * pCmdNotify)

PARAMETERS:
	pUser: void pointer, need to be typecast with c_iflipapp
	pCmdNotify: pointer to AEEMediaCmdNotify, getting filled pointer with IMedia playback 
 notification.
DEPENDENCIES
  none

RETURN VALUE
  none

SIDE EFFECTS
  none
===========================================================================*/
// 
static void c_iflipapp_MediaNotify(void * pUser, AEEMediaCmdNotify * pCmdNotify)
{
   if (pCmdNotify->nCmd == MM_CMD_PLAY)
   { 
      switch (pCmdNotify->nStatus)
      {
         case MM_STATUS_START:
		    DBGPRINTF("Got MM_STATUS_START");
         break;
         case MM_STATUS_MEDIA_SPEC:
			DBGPRINTF("Got MM_STATUS_MEDIA_SPEC");
         break;
         case MM_STATUS_TICK_UPDATE:
		    DBGPRINTF("Got MM_STATUS_TICK_UPDATE");
         break; 
         case MM_STATUS_SEEK:
			DBGPRINTF("Got MM_STATUS_SEEK");
         break;
         case MM_STATUS_PAUSE:
			DBGPRINTF("Got MM_STATUS_PAUSE");
         break;
         case MM_STATUS_RESUME:
			DBGPRINTF("Got MM_STATUS_RESUME");
         break;
         case MM_STATUS_DONE:    
			DBGPRINTF("Got MM_STATUS_DONE");
		 break;
         case MM_STATUS_ABORT:
			DBGPRINTF("Got MM_STATUS_ABORT");
		 break;
      }
   }
}

/*===========================================================================
FUNCTION c_iflipapp_ackBGapp

DESCRIPTION
This function stores the background application notification to the buffer

PROTOTYPE:
static	void c_iflipapp_ackBGapp(c_iflipapp * pMe, uint16 wParam)


PARAMETERS:
pMe: Pointer to the c_iflipapp structure.
wParam: stores the event recieved from background application.
DEPENDENCIES
none

RETURN VALUE
none

SIDE EFFECTS
none
===========================================================================*/

static void c_iflipapp_ackBGapp(c_iflipapp * pMe, uint16 wParam)
{
   if(BGAPP_FLIP_EVENT_RECEIVED == wParam)
   {
      STRCAT(pMe->pAckFromBGapp, "FLIP EVENT\n");
   }
   else if(EVT_BGAPP_KEYGAURD_EVENT_RECEIVED == wParam)
   {
   	  STRCAT(pMe->pAckFromBGapp, "KEYGUARD\n");			  
   }
   else if(EVT_BGAPP_SCREENROTATE_RECEIVED == wParam)
   {
   	  STRCAT(pMe->pAckFromBGapp, "SCREEN ROTATE\n");
   }
}