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

📄 voicelist.c

📁 好记星的控件,包括button,list,对文件操作
💻 C
📖 第 1 页 / 共 2 页
字号:
        return FALSE;

    //做随机播放记录
    g_VoiceListRandomStatus[g_VoiceListPlayParam.wPlayCur] = 1;
    
    if (hVoiceListPlayHandle < 0 && !__VoiceListOpen()) {
        return FALSE;
    }

    if(__VoicePlay(hVoiceListPlayHandle) == TRUE)
    {
        g_VoiceListPlayParam.wPlayStatus = VOICE_LIST_DEVICE_PLAY;
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}


BOOL __VoiceListPause(VOID)
{
    if( g_VoiceListPlayParam.wPlayStatus != VOICE_LIST_DEVICE_PLAY )
        return FALSE;

    if(__VoicePause(hVoiceListPlayHandle) == TRUE)
    {
        g_VoiceListPlayParam.wPlayStatus = VOICE_LIST_DEVICE_PAUSE;
        return TRUE;
    }
    else
        return FALSE;
}

BOOL __VoiceListResume(VOID)
{
    if( g_VoiceListPlayParam.wPlayStatus != VOICE_LIST_DEVICE_PAUSE )
        return FALSE;

    if(__VoiceResume(hVoiceListPlayHandle) == TRUE)
    {
        g_VoiceListPlayParam.wPlayStatus = VOICE_LIST_DEVICE_PLAY;
        return TRUE;
    }
    else
        return FALSE;
}

BOOL __VoiceListStop(VOID)
{
	//关闭播放设备
    __VoicePlayStop(hVoiceListPlayHandle);

    g_VoiceListPlayParam.wPlayStatus = VOICE_LIST_DEVICE_STOP;

	g_VoiceListPlayParam.voicePlayParam.dwPlayOffset = g_VoiceListPlayParam.voicePlayParam.dwPlayStart;
	VoiceSetParam(hVoiceListPlayHandle, &g_VoiceListPlayParam.voicePlayParam);
    
    return TRUE;
}


BOOL __VoiceListClose(VOID)
{
	//关闭播放设备
    __VoiceClose(hVoiceListPlayHandle);

    hVoiceListPlayHandle = -1;
    g_VoiceListPlayParam.wPlayStatus = VOICE_LIST_DEVICE_STOP;
    
    return TRUE;
}


BOOL __VoiceListPlayChange(UINT32 dwMsgType)
{
	BOOL	bPlaying;
	UINT32	dwChange;

	if(g_VoiceListPlayParam.wPlayStatus == VOICE_LIST_DEVICE_PLAY)
		bPlaying = TRUE;
	else
		bPlaying = FALSE; 

    __VoiceListClose();
    //清除随机播放记录
    if (g_VoiceListPlayParam.wPlaySel == VOICE_LIST_PLAYSEL_RANDOM) {
		memset(g_VoiceListRandomStatus, 0, g_VoiceList.wFileNum);
    }

	if(dwMsgType >= VOICE_LIST_COMMAND_PLAYPREV && 
		dwMsgType < VOICE_LIST_COMMAND_PLAYPREV + VOICE_LIST_SKIP_MAX)
    {
		dwChange = dwMsgType - VOICE_LIST_COMMAND_PLAYPREV + 1;
		if(g_VoiceListPlayParam.wPlayCur >= dwChange)
			g_VoiceListPlayParam.wPlayCur -= dwChange;
		else if(g_VoiceListPlayParam.wPlayCur == 0)
			g_VoiceListPlayParam.wPlayCur = g_VoiceList.wFileNum - 1;
		else
			g_VoiceListPlayParam.wPlayCur = 0;
	}
	else if(dwMsgType >= VOICE_LIST_COMMAND_PLAYNEXT && 
		dwMsgType < VOICE_LIST_COMMAND_PLAYNEXT + VOICE_LIST_SKIP_MAX)
	{
		dwChange = dwMsgType - VOICE_LIST_COMMAND_PLAYNEXT + 1;
		if(g_VoiceListPlayParam.wPlayCur + dwChange < g_VoiceList.wFileNum)
			g_VoiceListPlayParam.wPlayCur += dwChange;
		else if(g_VoiceListPlayParam.wPlayCur == g_VoiceList.wFileNum - 1)
			g_VoiceListPlayParam.wPlayCur = 0;
		else
            g_VoiceListPlayParam.wPlayCur = g_VoiceList.wFileNum - 1;
	}
    
    if (__VoiceListOpen())
    {
        if (bPlaying) __VoiceListPlay();
        return TRUE;
    }
	return FALSE;
}

BOOL __VoiceListPlayCycle()
{
    UINT16  wRand;
    UINT    i;
    
    __VoiceListClose();
    g_VoiceListPlayParam.voicePlayParam.dwPlayOffset = 0;

    if (g_VoiceListPlayParam.wPlaySel == VOICE_LIST_PLAYSEL_ORDER)
    {   //顺序播放
        for (i = 0; i < g_VoiceList.wFileNum; ++ i)
        {
            g_VoiceListPlayParam.wPlayCur++;
            if (g_VoiceListPlayParam.wPlayMode == VOICE_LIST_PLAYMODE_NOCYCLE)
            {
                if (g_VoiceListPlayParam.wPlayCur >= (UINT16)g_VoiceList.wFileNum)
                {   //已经播放完所有文件
                    g_VoiceListPlayParam.wPlayCur = 0;
                    if (g_VoiceListPlayParam.pCallBackFunc)
                        ((VOICECALLBACKPROC)g_VoiceListPlayParam.pCallBackFunc)(VOICELIST_NOTIFY_PLAYEND, 0);
                    return TRUE;
                }
            }
            else if (g_VoiceListPlayParam.wPlayMode == VOICE_LIST_PLAYMODE_CYCLE)
            {
                g_VoiceListPlayParam.wPlayCur %= g_VoiceList.wFileNum;
            }
            if (__VoiceListOpen())
            {
                if (__VoiceListPlay()) {
                    if (g_VoiceListPlayParam.pCallBackFunc)
                        ((VOICECALLBACKPROC)g_VoiceListPlayParam.pCallBackFunc)
                        (VOICE_NOTIFY_REFRESH, 0);
                    return TRUE;
                }
                __VoiceListClose();
            }
        }
    }
    else if (g_VoiceListPlayParam.wPlaySel == VOICE_LIST_PLAYSEL_RANDOM)
    {   //随机播放
        wRand = rand();
        wRand %= g_VoiceList.wFileNum;
        g_VoiceListPlayParam.wPlayCur = wRand;
        for (i = 0; i < g_VoiceList.wFileNum; ++ i)
        {
            if (g_VoiceListRandomStatus[g_VoiceListPlayParam.wPlayCur] == 0)
            {
                if (__VoiceListOpen())
                {
                    if (__VoiceListPlay()) {
                        if (g_VoiceListPlayParam.wPlayMode
                            == VOICE_LIST_PLAYMODE_CYCLE)
                        {
                            for (i = 0; i < g_VoiceList.wFileNum; ++ i)
                            {
                                if (g_VoiceListRandomStatus[i] == 2) {
                                    g_VoiceListRandomStatus[i] = 1;
                                }
                            }
                        }
                        if (g_VoiceListPlayParam.pCallBackFunc)
                            ((VOICECALLBACKPROC)g_VoiceListPlayParam.pCallBackFunc)
                            (VOICE_NOTIFY_REFRESH, 0);
                        return TRUE;
                    }
                    __VoiceListClose();
                }
                g_VoiceListRandomStatus[g_VoiceListPlayParam.wPlayCur] = 2;
            }
            
            if (g_VoiceListPlayParam.wPlayCur >= g_VoiceList.wFileNum - 1)
            {
                g_VoiceListPlayParam.wPlayCur = 0;
            }
            else
                g_VoiceListPlayParam.wPlayCur ++;
        }
        
        if (g_VoiceListPlayParam.wPlayMode == VOICE_LIST_PLAYMODE_CYCLE) {
            BOOL bPlayed = FALSE;
            for (i = 0; i < g_VoiceList.wFileNum; ++ i) {
                if (g_VoiceListRandomStatus[i] == 1) {
                    g_VoiceListRandomStatus[i] = 0;
                    bPlayed = TRUE;
                }
            }
            if (bPlayed) {
                return __VoiceListPlayCycle();
            }
        }
        memset(g_VoiceListRandomStatus, 0, g_VoiceList.wFileNum);
    }

    if (g_VoiceListPlayParam.wPlayMode == VOICE_LIST_PLAYMODE_NOCYCLE
        && g_VoiceListPlayParam.pCallBackFunc)
        ((VOICECALLBACKPROC)g_VoiceListPlayParam.pCallBackFunc)(VOICELIST_NOTIFY_PLAYEND, 0);
    return FALSE;
}

BOOL __VoiceListSuspend()
{
	UINT16	wSuspendStatus;

    if(VoiceGetParam(hVoiceListPlayHandle, &g_VoiceListPlayParam.voicePlayParam) == FALSE)
        return FALSE;

    if(g_VoiceListPlayParam.wPlayStatus == VOICE_LIST_DEVICE_PLAY)
		wSuspendStatus = VOICE_LIST_DEVICE_PLAY | VOICE_LIST_DEVICE_SUSPEND;
	else
		wSuspendStatus = VOICE_LIST_DEVICE_STOP | VOICE_LIST_DEVICE_SUSPEND;

	__VoiceListClose();
	
	g_VoiceListPlayParam.wPlayStatus = wSuspendStatus;
	return TRUE;
}

BOOL __VoiceListContinue()
{
	if((g_VoiceListPlayParam.wPlayStatus & VOICE_LIST_DEVICE_SUSPEND) == 0)
		return FALSE;

    if(__VoiceListOpen() == FALSE)
        return FALSE;

	//VoiceListPlayParamSet(&g_VoiceListPlayParam, VOICE_LIST_SET_PLAYOFFSET);

	if(g_VoiceListPlayParam.wPlayStatus == (VOICE_LIST_DEVICE_PLAY | VOICE_LIST_DEVICE_SUSPEND))
		return __VoiceListPlay();
	else
	{
		g_VoiceListPlayParam.wPlayStatus &= ~VOICE_LIST_DEVICE_SUSPEND;
		return TRUE;
	}
}

BOOL __VoiceListProcess(UINT32 dwMsgType)
{
	switch(dwMsgType)
	{
        case VOICE_LIST_COMMAND_PLAYBACK:
            if (!__VoiceListPlay()) {
                __VoiceListPlayCycle();
            }
            break;
		case VOICE_LIST_COMMAND_OPEN:
			__VoiceListOpen();
			break;
        case VOICE_LIST_COMMAND_PLAY:
            __VoiceListPlay();
            break;
        case VOICE_LIST_COMMAND_PAUSE:
            __VoiceListPause();
            break;
        case VOICE_LIST_COMMAND_RESUME:
            __VoiceListResume();
            break;
        case VOICE_LIST_COMMAND_STOP:
            __VoiceListStop();
            break;
        case VOICE_LIST_COMMAND_CLOSE:
            __VoiceListClose();
            break;
//        case VOICE_LIST_COMMAND_PLAYPREV:
//        case VOICE_LIST_COMMAND_PLAYNEXT:
//            __VoiceListPlayChange(dwMsgType);
            break;
        case VOICE_LIST_COMMAND_SUSPEND:
            __VoiceListSuspend();
            break;
        case VOICE_LIST_COMMAND_CONTINUE:
            __VoiceListContinue();
            break;
        case VOICE_LIST_COMMAND_PLAYCYCLE:   
			__VoiceListPlayCycle();
			break;
		default:
			if(__VoiceListPlayChange(dwMsgType) == TRUE)
				break;

			return FALSE;
	}
	return TRUE;
}



BOOL	VoiceListCommand(UINT32	dwMsgType)
{
    __VoiceSendCommand(NULL, dwMsgType, 0, 0);

	switch(dwMsgType)
	{
	case VOICE_LIST_COMMAND_OPEN:
		if(hVoiceListPlayHandle == -1)
		{
//			MsgBoxRun(NULL, 0, "文件打开失败,可能是文件格式错误!", NULL, MT_OK);
			return FALSE;
		}
		else
			return TRUE;
		break;

	case VOICE_LIST_COMMAND_PLAY:
	case VOICE_LIST_COMMAND_RESUME:
	    if(g_VoiceListPlayParam.wPlayStatus != VOICE_LIST_DEVICE_PLAY)
		{
//			MsgBoxRun(NULL, 0x101, "文件播放失败,可能是文件格式错误!", NULL, MT_OK);
			return FALSE;
		}
		else
			return TRUE;
		break;

	default:
		return TRUE;
	}

	return TRUE;
}

/*BOOL	VoiceListOpen()
{
    __VoiceSendCommand(NULL, VOICE_LIST_COMMAND_OPEN, 0, 0);

	if(hVoiceListPlayHandle == -1)
	{
		MsgBoxRun(NULL, 0, "文件打开失败,可能是文件格式错误!", NULL, MT_OK);
		return FALSE;
	}
	else
		return TRUE;
}

BOOL	VoiceListPlay()
{
    __VoiceSendCommand(NULL, VOICE_LIST_COMMAND_PLAY, 0, 0);

	if(g_VoiceListPlayParam.wPlayStatus != VOICE_LIST_DEVICE_PLAY)
	{
		MsgBoxRun(NULL, 0x101, "文件播放失败,可能是文件格式错误!", NULL, MT_OK);
		return FALSE;
	}
	else
		return TRUE;
}

BOOL	VoiceListPause()
{
    __VoiceSendCommand(NULL, VOICE_LIST_COMMAND_PAUSE, 0, 0);

	return TRUE;
}

BOOL	VoiceListResume()
{
    __VoiceSendCommand(NULL, VOICE_LIST_COMMAND_RESUME, 0, 0);

	if(g_VoiceListPlayParam.wPlayStatus != VOICE_LIST_DEVICE_PLAY)
	{
		MsgBoxRun(NULL, 0x101, "文件播放失败,可能是文件格式错误!", NULL, MT_OK);
		return FALSE;
	}
	else
		return TRUE;
}

BOOL	VoiceListStop()
{
    __VoiceSendCommand(NULL, VOICE_LIST_COMMAND_STOP, 0, 0);

	return TRUE;
}

BOOL	VoiceListClose()
{
    __VoiceSendCommand(NULL, VOICE_LIST_COMMAND_CLOSE, 0, 0);

	return TRUE;
}

BOOL	VoiceListPlayPrev()
{
    __VoiceSendCommand(NULL, VOICE_LIST_COMMAND_PLAYPREV, 0, 0);

	return TRUE;
}

BOOL	VoiceListPlayNext()
{
    __VoiceSendCommand(NULL, VOICE_LIST_COMMAND_PLAYNEXT, 0, 0);

	return TRUE;
}

BOOL VoiceListSuspend()
{
	__VoiceSendCommand(voiceHandle, VOICE_LIST_COMMAND_SUSPEND, 0, 0);

	return TRUE;
}

BOOL VoiceListContinue()
{
	__VoiceSendCommand(voiceHandle, VOICE_LIST_COMMAND_CONTINUE, 0, 0);

	return TRUE;
}
*/

⌨️ 快捷键说明

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