D
dafu2
Unregistered / Unconfirmed
GUEST, unregistred user!
我是用DirectShow做播放器,在获取媒体长度时,老是报错!
搞不懂,晕........................
function TVideoPlayer.GetVideoPlayTime(const FileName: PWideChar): int64;
var
VideoLongth: int64;
Graph: IGraphBuilder;
MediaSeeking: IMediaSeeking;
begin
try
// CoInitialize(nil);
CoCreateInstance(CLSID_FilterGraph, nil, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, Graph);
Graph.RenderFile(FileName, nil);
Graph.QueryInterface(IID_IMediaSeeking, MediaSeeking);
//获取媒体总时间
MediaSeeking.SetTimeFormat(TIME_FORMAT_MEDIA_TIME);
MediaSeeking.GetDuration(VideoLongth);
Result := VideoLongth;
finally
Graph := nil;
MediaSeeking := nil;
//CoUninitialize;
end;
//Result := 100000000;
end;
搞不懂,晕........................
function TVideoPlayer.GetVideoPlayTime(const FileName: PWideChar): int64;
var
VideoLongth: int64;
Graph: IGraphBuilder;
MediaSeeking: IMediaSeeking;
begin
try
// CoInitialize(nil);
CoCreateInstance(CLSID_FilterGraph, nil, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, Graph);
Graph.RenderFile(FileName, nil);
Graph.QueryInterface(IID_IMediaSeeking, MediaSeeking);
//获取媒体总时间
MediaSeeking.SetTimeFormat(TIME_FORMAT_MEDIA_TIME);
MediaSeeking.GetDuration(VideoLongth);
Result := VideoLongth;
finally
Graph := nil;
MediaSeeking := nil;
//CoUninitialize;
end;
//Result := 100000000;
end;