MP3 Playback

      MP3 Playback

      Source Code

      1. #include <dshow.h>
      2. IGraphBuilder *g_pGraphBuilder = NULL;
      3. IMediaEventEx *g_pMediaEvent = NULL;
      4. IMediaControl *g_pMediaCtrl = NULL;
      5. int _tmain(int argc, _TCHAR* argv[])
      6. {
      7. CoInitialize(NULL);
      8. RETAILMSG(1,(L"after CoInitialize: GetLasterror = 0x%x\r\n",GetLastError()));
      9. HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&g_pGraphBuilder);
      10. RETAILMSG(1,(L"after CoCreateInstance: CLSID_FilterGraph: GetLasterror = 0x%x hr = 0x%x\r\n",GetLastError(),hr));
      11. hr = g_pGraphBuilder->RenderFile(L"\\FFSDISK\\10 Be healthy.mp3",0);
      12. RETAILMSG(1,(L"after RenderFile: CLSID_FilterGraph: GetLasterror = 0x%x hr = 0x%x\r\n",GetLastError(),hr));
      13. hr = g_pGraphBuilder->QueryInterface(IID_IMediaControl,(void**)&g_pMediaCtrl);
      14. hr = g_pGraphBuilder->QueryInterface(IID_IMediaEvent,(void**)&g_pMediaEvent);
      15. hr = g_pMediaCtrl->Run();
      16. RETAILMSG(1,(L"after Run: CLSID_FilterGraph: GetLasterror = 0x%x hr = 0x%x\r\n",GetLastError(),hr));
      17. long evCode;
      18. hr = g_pMediaEvent->WaitForCompletion(INFINITE,&evCode);
      19. /* PERFORM CLEANUP */
      20. return 0;
      21. }


      Link against Strmiids.lib
      F&amp;S Elektronik Systeme GmbH
      As this is an international forum, please try to post in English.
      Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.