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

📄 mp3player.cpp

📁 EP9315开发板的Wince6.0的BSP包文件
💻 CPP
字号:
/**********************************************************************
#                                                                      
# Filename: mp3player.cpp
#                                                                      
# Description:
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
# ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
# PARTICULAR PURPOSE.
#
# Use of this source code is subject to the terms of the Cirrus end-user
# license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
# If you did not accept the terms of the EULA, you are not authorized to 
# use this source code. For a copy of the EULA, please see the 
# EULA.RTF on your install media.
#
# Copyright(c) Cirrus Logic Corporation 2005, All Rights Reserved                       
#                                                                      
#**********************************************************************/

#include "stdafx.h"
//#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <streams.h>



//****************************************************************************
// main
//****************************************************************************
// Plays an mp3
// 
//
int WINAPI WinMain
(
  HINSTANCE hInstance, 
  HINSTANCE hPrevInstance, 
  LPWSTR lpCmdLine, 
  int nShowCmd 
)
{
    int iReturn = 0;
    DWORD   dwRet;

    IGraphBuilder *pGraph = 0;
    IMediaControl *pMediaControl = 0;
	IMediaEvent   *pMediaEvent  = 0;
//    HRESULT hResult;
//    OAFilterState state;
//    HANDLE hFile;
//	HANDLE hEvent;
	LONG	EvCode;

    printf("mp3player.exe:  Command line mp3 player using ActiveX\r\n");
    printf("Cirrus Logic Copyright 2004, All Rights Reserved.\r\n");

    //
    // Get file attributes.
    //
    dwRet = GetFileAttributes( lpCmdLine);
    
    if(dwRet == 0xFFFFFFFF)
    {
        wprintf(L"    Error: Could not find file %s\r\n",  lpCmdLine);
        exit(0);
    }
    
    CoInitialize(NULL);

    
    // Create the filter graph manager.
    CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, 
                        IID_IGraphBuilder, (void **)&pGraph);

    pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
    if(pMediaControl == 0)
    {
        wprintf(L" Failed in query interface IMediaControl.\r\n");
		iReturn = 1;
    }

	if(!iReturn)
	{
		pGraph->QueryInterface(IID_IMediaEvent, (void **)&pMediaEvent);
		if(pMediaEvent == 0)
		{
			wprintf(L" Failed in query interface IMediaEvent.\r\n");
			iReturn = 1;
		}
	}

	//if(!iReturn)
	//{
	//	hResult = pMediaEvent->GetEventHandle((OAEVENT *)&hEvent);
	//}



    //
    // Build the graph. (IMPORTANT: Change string to a file on your system.)
    //
    if(!iReturn)
    {
        pGraph->RenderFile(lpCmdLine, NULL);
    }



    //
    // Run the graph.
    //
    if(!iReturn)
    {           
        pMediaControl->Run();
    }


    //
    // Block until the user clicks the OK button. 
    // The filter graph runs on a separate thread.
    // MessageBox(NULL, "Click me to end playback.", "DirectShow", MB_OK);
    //
    //if(!iReturn)
    //{
    //    for(;;)
    //    {
    //        Sleep(1000);
    //        hResult = pMediaControl->GetState(1000, &state);
    //        if(state != State_Running)
    //        {
    //            break;           
    //        }
    //    }
    // }
	wprintf(L"Block until play back finishs.\r\n");
	pMediaEvent->WaitForCompletion(INFINITE, &EvCode);


    //
    // Clean up.
    //
    if(pMediaControl)
    {           
        pMediaControl->Release();
    }

    if(pMediaEvent)
    {           
        pMediaEvent->Release();
    }


    if(pGraph)
    {
        pGraph->Release();
    }

    CoUninitialize();

	wprintf(L"Play back finishs.\r\n");

	return 0;
}

⌨️ 快捷键说明

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