⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iringerusage.c

📁 c++结构的应用程序 其中包含写好的ringer类
💻 C
📖 第 1 页 / 共 2 页
字号:
		{   			  			int NumberOfFormats = -1;   			AEESoundPlayerFile pwFormats[2]; 			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			NumberOfFormats = IRINGERMGR_GetNumberFormats(pMe->m_pIRingerMgr);   						IRINGERMGR_GetFormats(pMe->m_pIRingerMgr, pwFormats, NumberOfFormats);   			CleanInterfaces(pMe);   		}   		break;   	case USAGE_SETRINGER  :   		{   			int ret;			AEERingerID ringerId ;   			CreateRinger(pMe, "abc_1", "fs:/~/AEE_TONE_0.mid", AEE_SOUNDPLAYER_FILE_MIDI);   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			ringerId =  IRINGERMGR_GetRingerID(pMe->m_pIRingerMgr, "ringers/abc_1.mid");   			ret = IRINGERMGR_SetRinger(pMe->m_pIRingerMgr,AEE_RINGER_CATEGORY_ALL, ringerId);   			CleanInterfaces(pMe);   		}   		break;   	case USAGE_ENUMCATEGORYINIT :   	case USAGE_ENUMNEXTCATEGORY :   		{   			AEERingerCat catinfo;   			boolean success = TRUE;   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			IRINGERMGR_EnumCategoryInit(pMe->m_pIRingerMgr);   			while(success)   			{   				success = IRINGERMGR_EnumNextCategory(pMe->m_pIRingerMgr,&catinfo);   			};   		}   		break;   	case USAGE_ENUMRINGERINIT :   	case USAGE_ENUMNEXTRINGER:   		{   			AEERingerInfo ringerinfo[25];   			boolean success = TRUE;   			int i=0;			//            int ringerId;    			//CreateRinger(pMe, "ring6", "AEE_TONE_0.wav", AEE_SOUNDPLAYER_FILE_MIDI);   			//CreateRinger(pMe, "ring7", "AEE_TONE_0.wav", AEE_SOUNDPLAYER_FILE_MIDI);   			//CreateRinger(pMe, "ring8", "AEE_TONE_0.wav", AEE_SOUNDPLAYER_FILE_MIDI);   			//CreateRinger(pMe, "ring9", "AEE_TONE_0.wav", AEE_SOUNDPLAYER_FILE_MIDI);   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			IRINGERMGR_EnumRingerInit(pMe->m_pIRingerMgr);   			while(success)   			{   				success = IRINGERMGR_EnumNextRinger(pMe->m_pIRingerMgr, &ringerinfo[i]);   				i++;			}   		}   		break;   	case USAGE_GETRINGERID:   		{   			AEERingerID ringerId ;   			CreateRinger(pMe, "ring4", "AEE_TONE_0.wav", AEE_SOUNDPLAYER_FILE_MIDI);   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			ringerId =  IRINGERMGR_GetRingerID(pMe->m_pIRingerMgr, "ring4.mid");   			CleanInterfaces(pMe);   		}   		break;   	case USAGE_GETRINGERINFO:   		{   			AEERingerID ringerId ;   			AEERingerInfo  info;   			CreateRinger(pMe, "ring4", "AEE_TONE_0.wav", AEE_SOUNDPLAYER_FILE_MIDI);   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			ringerId =  IRINGERMGR_GetRingerID(pMe->m_pIRingerMgr, "ring4.mid");   			IRINGERMGR_GetRingerInfo(pMe->m_pIRingerMgr, ringerId, &info);   			CleanInterfaces(pMe);   		}   		break;   	case USAGE_BASIC_USAGE:   	case USAGE_PLAYFILE:   		{   			PlayRingerFile(pMe, "AEE_TONE_0.mp3");   		}   		break;   	case USAGE_REGISTERNOTIFY:   		{   			// Create IRingerMgr interface object. This step needs to be done only    			// if the IRingerMgr interface object have not already been created.     			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if (pMe->m_pIRingerMgr)   			{   				// Register the status callback funtion using     				// IRINGERMRG_RegisterNotify().     				IRINGERMGR_RegisterNotify(pMe->m_pIRingerMgr, &RingerMgrCBFn, (void *)pMe);   				// Cancel the callback notification    				IRINGERMGR_RegisterNotify(pMe->m_pIRingerMgr, NULL, NULL);   				// Release the ringer object    				CleanInterfaces(pMe);   			}   		}   		break;   	case USAGE_CREATE:   		{   			CreateRinger(pMe, "ring0", "AEE_TONE_0.mp3", AEE_SOUNDPLAYER_FILE_MP3);   			CreateRinger(pMe, "ring0", "AEE_TONE_0.mp3", AEE_SOUNDPLAYER_FILE_MIDI);   		}   		break;   	case USAGE_REMOVE:   		{   			AEERingerID ringerId ;   			CreateRinger(pMe, "ring1", "AEE_TONE_0.wav", AEE_SOUNDPLAYER_FILE_MIDI);   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			ringerId =  IRINGERMGR_GetRingerID(pMe->m_pIRingerMgr, "ring1.mid");   			IRINGERMGR_Remove(pMe->m_pIRingerMgr, ringerId);   			CleanInterfaces(pMe);   		}   		break;   	case USAGE_PLAYEX:   		{   			AEERingerID ringerId ;   			CreateRinger(pMe, "ring2", "AEE_TONE_0.mp3", AEE_SOUNDPLAYER_FILE_MP3);   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			ringerId =  IRINGERMGR_GetRingerID(pMe->m_pIRingerMgr, "ring2.mp3");   			IRINGERMGR_PlayEx(pMe->m_pIRingerMgr,ringerId,NULL,NULL,2);   		}   		break;   	case USAGE_PLAY:   		{   			AEERingerID ringerId ;   //			CreateRinger(pMe, "ring2", "AEE_TONE_0.mp3", AEE_SOUNDPLAYER_FILE_MP3);   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   //			ringerId =  IRINGERMGR_GetRingerID(pMe->m_pIRingerMgr, "ring2.mp3");   			IRINGERMGR_Play(pMe->m_pIRingerMgr, 4, 2);   		}   		break;   	case USAGE_PLAYSTREAM:   		{   			//At this time , this will not work because the ISoundPlayer does not implement streams yet.    			FileInfo fi;   			// Create IRingerMgr interface object. This step needs to be done only    			// if the IRingerMgr interface object have not already been created.     			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			// Create an instance of IFileMgr so we can access the  file    			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FILEMGR, (void **)(&pMe->m_pIFileMgr));   			if (NULL == pMe->m_pIFileMgr)   			{   				return;   			}   			// Open the browser icon bitmap file for reading    			if (NULL == (pMe->m_pIFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr, "AEE_TONE_0.mp3", _OFM_READ)))   			{   				IFILEMGR_Release(pMe->m_pIFileMgr);   				return;   			}   			// Determine the size of the bitmap file and allocate memory    			// to store its contents    			IFILE_GetInfo(pMe->m_pIFile, &fi);   			if (NULL == (pMe->m_pBuff = (byte *) MALLOC(fi.dwSize)))   			{   				IFILE_Release(pMe->m_pIFile);   				IFILEMGR_Release(pMe->m_pIFileMgr);   				return;   			}   			// Read the contents of the ringer file into the    			// area allocated in memory for it    			if (IFILE_Read(pMe->m_pIFile, (void *)pMe->m_pBuff, fi.dwSize) == 0)   			{   				FREE(pMe->m_pBuff);   				IFILE_Release(pMe->m_pIFile);   				IFILEMGR_Release(pMe->m_pIFileMgr);   				return;   			}   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEMASTREAM, (void **)(&pMe->m_pMemStream));   			if (NULL == pMe->m_pMemStream)   			{   				FREE(pMe->m_pBuff);   				IFILE_Release(pMe->m_pIFile);   				IFILEMGR_Release(pMe->m_pIFileMgr);   				return;   			}   			//  IASTREAM_AddRef((IAStream*)pMe->m_pMemStream);    			//IASTREAM_AddRef((IAStream*)pIFile);    			//  pMe->m_pMemStream =pMemStream;    			//  IFILE_Release(pIFile);    			//  IFILEMGR_Release(pIFileMgr);    			//  pMe->m_pIRingerMgr = pIRingerMgr;    			IMEMASTREAM_Set(pMe->m_pMemStream,pMe->m_pBuff, fi.dwSize, 0, 0);   			IRINGERMGR_PlayStream(pMe->m_pIRingerMgr, (IAStream*)pMe->m_pMemStream, 2);   		}   		break;   	case USAGE_STOP    :    		{   			IRingerMgr *pIRingerMgr = NULL;   			// Create an instance of IRingerMgr    			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)(&pIRingerMgr));   			if (NULL == pIRingerMgr)   			{   				return;   			}   			pMe->m_pIRingerMgr = pIRingerMgr;   			IRINGERMGR_PlayFile(pIRingerMgr,"AEE_TONE_1.wav", 2);   			IRINGERMGR_Stop(pIRingerMgr);   		}   		break;   	}   }   static void BuildMainMenu(CIRingerApp *pMe)   {   	AEERect qrc;   	AEEDeviceInfo di;   	AECHAR szBuf[50];   	if (pMe == NULL || pMe->m_pIMenu == NULL || pMe->a.m_pIShell == NULL)   		return;   	// Set Title    	STR_TO_WSTR("IRingerMgr Examples", szBuf, sizeof(szBuf));   	IMENUCTL_SetTitle(pMe->m_pIMenu, NULL, 0, szBuf);   	//Set the Rectangle for the Menu    	ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&di);   	qrc.x = 0;   	qrc.y = 0;   	qrc.dx = di.cxScreen;   	qrc.dy = di.cyScreen;   	IMENUCTL_SetRect(pMe->m_pIMenu, &qrc);     	//Add invidual entries to the Menu    	// Add Basic Usage to menu    	STR_TO_WSTR("1. Basic Usage", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_BASIC_USAGE, szBuf, 0);   	STR_TO_WSTR("2. Create", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_CREATE, szBuf, 0);   	STR_TO_WSTR("3. Play", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_PLAY, szBuf, 0);   	STR_TO_WSTR("4. PlayEx",szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_PLAYEX, szBuf, 0);   	STR_TO_WSTR("5. PlayFile", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_PLAYFILE, szBuf, 0);   	STR_TO_WSTR("6. PlayStream", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_PLAYSTREAM, szBuf, 0);      	STR_TO_WSTR("7. Stop", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_STOP, szBuf, 0);    	STR_TO_WSTR("8. RegisterNotify", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_REGISTERNOTIFY, szBuf, 0);   	STR_TO_WSTR("9. GetNumberFormats", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_GETNUMBERFORMATS, szBuf, 0);   	STR_TO_WSTR("10. GetFormats.", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_GETFORMATS, szBuf, 0);   	STR_TO_WSTR("11. SetRinger", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_SETRINGER, szBuf, 0);   	STR_TO_WSTR("12. EnumCategoryInit", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_ENUMCATEGORYINIT, szBuf, 0);    	STR_TO_WSTR("13. EnumNextCategory", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_ENUMNEXTCATEGORY, szBuf, 0);    	STR_TO_WSTR("14. EnumRingerInit", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_ENUMRINGERINIT, szBuf, 0);      	STR_TO_WSTR("15. EnumNextRinger", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_ENUMNEXTRINGER, szBuf, 0);      	STR_TO_WSTR("16. GetRingerID", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_GETRINGERID, szBuf, 0);     	STR_TO_WSTR("17. GetRingerInfo", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_GETRINGERINFO, szBuf, 0);       	STR_TO_WSTR("18. Remove", szBuf, sizeof(szBuf));   	IMENUCTL_AddItem(pMe->m_pIMenu, 0, 0, USAGE_REMOVE, szBuf, 0);      	// Activate menu    	IMENUCTL_SetActive(pMe->m_pIMenu,TRUE);   }   int PlayRingerFile(CIRingerApp *pMe, const char * filename)   {   	// Create an instance of IRingerMgr    	ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)(&pMe->m_pIRingerMgr));   	if (NULL == pMe->m_pIRingerMgr)   	{   		return 0;   	}   	IRINGERMGR_PlayFile(pMe->m_pIRingerMgr,filename, 2);   	return 1;   }   int CreateRinger(CIRingerApp *pMe, const char * ringername, const char * inputfile, AEESoundPlayerFile format)   {   		FileInfo fi;   	int ret=0;	AECHAR rngName[15]={0} ;   	if ( ringername )   	{   		STR_TO_WSTR( ringername, rngName, sizeof(rngName) );   	}   	else   		return 0;   	// Create IRingerMgr interface object. This step needs to be done only    	// if the IRingerMgr interface object have not already been created.     	ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    	if(pMe->m_pIRingerMgr == NULL)   	{   		return 0;   	}   	// Create an instance of IFileMgr so we can access the  file    	ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FILEMGR, (void **)(&pMe->m_pIFileMgr));   	if (NULL == pMe->m_pIFileMgr)   	{   		return 0;   	}   	pMe->m_pIFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr, inputfile, _OFM_READ);	if (NULL == pMe->m_pIFile )   	{   		CleanInterfaces(pMe);   		return 0;   	}   	// Determine the size of the bitmap file and allocate memory    	// to store its contents    	IFILE_GetInfo(pMe->m_pIFile, &fi);   	if (NULL == (pMe->m_pBuff = (byte *) MALLOC(fi.dwSize)))   	{   		CleanInterfaces(pMe);   		return 0;   	}   	// Read the contents of the ringer file into the    	// area allocated in memory for it    	if (IFILE_Read(pMe->m_pIFile, (void *)pMe->m_pBuff, fi.dwSize) == 0)   	{   		FREE(pMe->m_pBuff);   		CleanInterfaces(pMe);   		return 0;   	}   	ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEMASTREAM, (void **)(&pMe->m_pMemStream));   	if (NULL == pMe->m_pMemStream)   	{   		FREE(pMe->m_pBuff);   		CleanInterfaces(pMe);   		return 0;   	}   	//  IASTREAM_AddRef((IAStream*)pMe->m_pMemStream);    	//IASTREAM_AddRef((IAStream*)pIFile);    	//  pMe->m_pMemStream =pMemStream;    	//  IFILE_Release(pIFile);    	//  IFILEMGR_Release(pIFileMgr);    	//  pMe->m_pIRingerMgr = pIRingerMgr;    	IMEMASTREAM_Set(pMe->m_pMemStream,pMe->m_pBuff, fi.dwSize, 0, 0);   		ret=IRINGERMGR_Create(pMe->m_pIRingerMgr,rngName,  format, (IAStream*)pMe->m_pMemStream);   	CleanInterfaces(pMe);   	return ret;   }  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -