directshow RenderFile 问题
#include <windows.h>
#include <streams.h>
#include <stdio.h>
#include <urlmon.h>
#include <commctrl.h>
#include <string.h>
#include "dshow_play.h"
int main()
{
WCHAR file[255]={0};
HRESULT hr;
CoInitialize(NULL);
printf("enter the Path\n");
scanf("%s",file);
// DirectShow interfaces
// Get the interface for DirectShow's GraphBuilder
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGB);
// QueryInterface for DirectShow interfaces
pGB->QueryInterface(IID_IMediaControl, (void **)&pMC);
pGB->QueryInterface(IID_IMediaEventEx, (void **)&pME);
pGB->QueryInterface(IID_IMediaSeeking, (void **)&pMS);
pGB->QueryInterface(IID_IMediaPosition, (void **)&pMP);
// Query for video interfaces, which may not be relevant for audio files
pGB->QueryInterface(IID_IVideoWindow, (void **)&pVW);
pGB->QueryInterface(IID_IBasicVideo, (void **)&pBV);
// Query for audio interfaces, which may not be relevant for video-only files
pGB->QueryInterface(IID_IBasicAudio, (void **)&pBA);
// Have the graph builder construct its the appropriate graph automatically
hr=pGB->RenderFile(file, 0);
// Run the graph to play the media file
hr=pMC->Run();
long m_lCurrentVolume;
m_lCurrentVolume=100;
hr=pBA->put_Volume(-m_lCurrentVolume);
hr=pBA->get_Volume(&m_lCurrentVolume);
LONG evcode;
hr=pME->WaitForCompletion(INFINITE,&evcode);
if(pMC)pMC->Release;
if(pGB)pGB->Release;
if(pME)pME->Release;
return 0;
}
定义了wchar file,用来得到文件的路径,但是似乎不对,每次renderfile都失败。
问题点数:50、回复次数:3Top
1 楼madmanahong(疯子阿虹)回复于 2006-07-20 11:46:58 得分 50
这怎么查?
错误码多少?
修改为scanf("%ws",file);看看Top
2 楼rageliu(天气好了就去长白山看水怪去了,嘿嘿...)回复于 2006-07-20 11:52:54 得分 0
先直接写路径看看能行不??
播放的多媒体文件格式有对应的解码filter吗?Top
3 楼ljlyun()回复于 2006-07-20 12:40:58 得分 0
多谢madmanahong(疯子阿虹)~~Top





