• PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 96KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 96
    下载次数
  • 2006-08-29 09:51
    上传日期
简单播放器 directshow 开发,能够满足各种avi文件的播放
simpleplay.rar
  • simpleplay
  • res
  • SimplePlayer.rc2
    404B
  • SimplePlayer.ico
    1.1KB
  • CDXGraph.cpp
    20.4KB
  • SimplePlayer.opt
    50.5KB
  • SimplePlayer.plg
    1.4KB
  • SimplePlayer.cpp
    2.1KB
  • Resource.h
    920B
  • CDXGraph.h
    2.4KB
  • StdAfx.h
    999B
  • SimplePlayer.h
    1.4KB
  • SimplePlayer.ncb
    297KB
  • StdAfx.cpp
    214B
  • SimplePlayer.dsp
    4.5KB
  • SimplePlayer.rc
    5.1KB
  • SimplePlayerDlg.h
    2.4KB
  • SimplePlayer.aps
    20.2KB
  • SimplePlayer.dsw
    549B
  • SimplePlayerDlg.cpp
    12.7KB
  • KeyProvider.h
    827B
  • KeyProvider.cpp
    1.7KB
  • www.pudn.com.txt
    218B
内容介绍
// // CDXGraph.cpp // #include "stdafx.h" #include <streams.h> #include "CDXGraph.h" #include <InitGuid.h> #include <Qedit.h> #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //////////////////////////////////////////////////////////////////////////////// CDXGraph::CDXGraph() { mGraph = NULL; mMediaControl = NULL; mEvent = NULL; mBasicVideo = NULL; mBasicAudio = NULL; mVideoWindow = NULL; mSeeking = NULL; mSampleGrabber = NULL; mObjectTableEntry = 0; } CDXGraph::~CDXGraph() { Release(); } bool CDXGraph::Create(void) { if (!mGraph) { if (SUCCEEDED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&mGraph))) { AddToObjectTable(); if(!mSampleGrabber) { if(SUCCEEDED(CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&mFilter))) { AddToObjectTable(); return QueryInterfaces(); } } } mGraph = 0; mSampleGrabber = 0; } return false; } bool CDXGraph::QueryInterfaces(void) { //WCHAR str[MAX_PATH]; // MultiByteToWideChar(CP_ACP, 0, "Grabber", -1, str, MAX_PATH); if (mGraph) { HRESULT hr = NOERROR; hr |= mGraph->QueryInterface(IID_IMediaControl, (void **)&mMediaControl); hr |= mGraph->QueryInterface(IID_IMediaEventEx, (void **)&mEvent); hr |= mGraph->QueryInterface(IID_IBasicVideo, (void **)&mBasicVideo); hr |= mGraph->QueryInterface(IID_IBasicAudio, (void **)&mBasicAudio); hr |= mGraph->QueryInterface(IID_IVideoWindow, (void **)&mVideoWindow); hr |= mGraph->QueryInterface(IID_IMediaSeeking, (void **)&mSeeking); hr |= mFilter->QueryInterface(IID_ISampleGrabber, (void **)&mSampleGrabber); mGraph->AddFilter(mFilter,L"Grabber"); if (mSeeking) { mSeeking->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME); } return SUCCEEDED(hr); } return false; } void CDXGraph::Release(void) { if (mSeeking) { mSeeking->Release(); mSeeking = NULL; } if (mMediaControl) { mMediaControl->Release(); mMediaControl = NULL; } if (mEvent) { mEvent->Release(); mEvent = NULL; } if (mBasicVideo) { mBasicVideo->Release(); mBasicVideo = NULL; } if (mBasicAudio) { mBasicAudio->Release(); mBasicAudio = NULL; } if (mVideoWindow) { mVideoWindow->put_Visible(OAFALSE); mVideoWindow->put_MessageDrain((OAHWND)NULL); mVideoWindow->put_Owner(OAHWND(0)); mVideoWindow->Release(); mVideoWindow = NULL; } RemoveFromObjectTable(); if (mGraph) { mGraph->Release(); mGraph = NULL; } } bool CDXGraph::Attach(IGraphBuilder * inGraphBuilder) { Release(); if (inGraphBuilder) { inGraphBuilder->AddRef(); mGraph = inGraphBuilder; AddToObjectTable(); return QueryInterfaces(); } return true; } IGraphBuilder * CDXGraph::GetGraph(void) { return mGraph; } IMediaEventEx * CDXGraph::GetEventHandle(void) { return mEvent; } // Connect filter from the upstream output pin to the downstream input pin bool CDXGraph::ConnectFilters(IPin * inOutputPin, IPin * inInputPin, const AM_MEDIA_TYPE * inMediaType) { if (mGraph && inOutputPin && inInputPin) { HRESULT hr = mGraph->ConnectDirect(inOutputPin, inInputPin, inMediaType); return SUCCEEDED(hr) ? true : false; } return false; } void CDXGraph::DisconnectFilters(IPin * inOutputPin) { if (mGraph && inOutputPin) { HRESULT hr = mGraph->Disconnect(inOutputPin); } } bool CDXGraph::SetDisplayWindow(HWND inWindow) { if (mVideoWindow) { // long lVisible; // mVideoWindow->get_Visible(&lVisible); // Hide the video window first mVideoWindow->put_Visible(OAFALSE); mVideoWindow->put_Owner((OAHWND)inWindow); RECT windowRect; ::GetClientRect(inWindow, &windowRect); mVideoWindow->put_Left(0); mVideoWindow->put_Top(0); mVideoWindow->put_Width(windowRect.right - windowRect.left); mVideoWindow->put_Height(windowRect.bottom - windowRect.top); mVideoWindow->put_WindowStyle(WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS); mVideoWindow->put_MessageDrain((OAHWND) inWindow); // Restore the video window if (inWindow != NULL) { // mVideoWindow->put_Visible(lVisible); mVideoWindow->put_Visible(OATRUE); } else { mVideoWindow->put_Visible(OAFALSE); } return true; } return false; } bool CDXGraph::ResizeVideoWindow(long inLeft, long inTop, long inWidth, long inHeight) { if (mVideoWindow) { long lVisible = OATRUE; mVideoWindow->get_Visible(&lVisible); // Hide the video window first mVideoWindow->put_Visible(OAFALSE); mVideoWindow->put_Left(inLeft); mVideoWindow->put_Top(inTop); mVideoWindow->put_Width(inWidth); mVideoWindow->put_Height(inHeight); // Restore the video window mVideoWindow->put_Visible(lVisible); return true; } return false; } bool CDXGraph::SetNotifyWindow(HWND inWindow) { if (mEvent) { mEvent->SetNotifyWindow((OAHWND)inWindow, WM_GRAPHNOTIFY, 0); return true; } return false; } void CDXGraph::HandleEvent(WPARAM inWParam, LPARAM inLParam) { if (mEvent) { LONG eventCode = 0, eventParam1 = 0, eventParam2 = 0; while (SUCCEEDED(mEvent->GetEvent(&eventCode, &eventParam1, &eventParam2, 0))) { mEvent->FreeEventParams(eventCode, eventParam1, eventParam2); switch (eventCode) { case EC_COMPLETE: break; case EC_USERABORT: case EC_ERRORABORT: break; default: break; } } } } bool CDXGraph::Run(void) { if (mGraph && mMediaControl) { if (!IsRunning()) { mSampleGrabber->SetBufferSamples(TRUE); // mSampleGrabber->SetOneShot(TRUE); if (SUCCEEDED(mMediaControl->Run())) { // long evCode; // mEvent->WaitForCompletion(INFINITE, &evCode); return true; } } else { return true; } } return false; } bool CDXGraph::Stop(void) { if (mGraph && mMediaControl) { if (!IsStopped()) { if (SUCCEEDED(mMediaControl->Stop())) { return true; } } else { return true; } } return false; } bool CDXGraph::Pause(void) { if (mGraph && mMediaControl) { if (!IsPaused()) { if (SUCCEEDED(mMediaControl->Pause())) { return true; } } else { return true; } } return false; } bool CDXGraph::IsRunning(void) { if (mGraph && mMediaControl) { OAFilterState state = State_Stopped; if (SUCCEEDED(mMediaControl->GetState(10, &state))) { return state == State_Running; } } return false; } bool CDXGraph::IsStopped(void) { if (mGraph && mMediaControl) { OAFilterState state = State_Stopped; if (SUCCEEDED(mMediaControl->GetState(10, &state))) { return state == State_Stopped; } } return false; } bool CDXGraph::IsPaused(void) { if (mGraph && mMediaControl) { OAFilterState state = State_Stopped; if (SUCCEEDED(mMediaControl->GetState(10, &state))) { return state == State_Paused; } } return false; } bool CDXGraph::SetFullScreen(BOOL inEnabled) { if (mVideoWindow) { HRESULT hr = mVideoWindow->put_FullScreenMode(inEnabled ? OATRUE : OAFALSE); return SUCCEEDED(hr); } return false; } bool CDXGraph::GetFullScreen(void) { if (mVideoWindow) { long fullScreenMode = OAFALSE; mVideoWindow->get_FullScreenMode(&fullScreenMode); return (fullScreenMode == OATRUE); } return false; } // IMediaSeeking features bool CDXGraph::GetCurrentPosition(double * outPosition) { if (mSeeking) { __int64 position = 0; if (SUCCEEDED(mSeeking->GetCurrentPosition(&position))) { *outPosition = ((double)position) / 10000000.; return true; } } return false; } bool CDXGraph::GetStopPosition(double * outPosition) { if (mSeeking) { __int64
评论
    相关推荐
    • 一个简单的directshow播放器
      一个简单的基于mfc播放器,可以支持各种类型,利于初学者入门
    • DirectShow播放器
      本程序是基于VC++开发的DirectShow视频播放器,可以实现打开视频文件、播放、暂停、停止以及显示播放进度、拖动播放等功……
    • Directshow播放器
      在MFC框架下利用Directshow变成接口,生成一个简单的视频播放器,代码量少实用性高,可以在此基础上添加其他对视频图像进行操作的代码,代码重用率较高。
    • 基于directshow的媒体播放器
      基于directshow的媒体播放器 可用于做为毕业设计 c++ 播放器播放器播放器播放器播放器播放器播放器播放器播放器播放器播放器播放器播放器播放器播放器播放器播放器
    • 基于Directshow的MP3播放器
      现在在学directshow,顺便做了个播放器。由于MFC的界面让人看着实在蛋疼,所以又花了点时间在界面上(重写了几个控件类)。至于歌词显示功能没有做。 下载解压后,运行SetUp.exe. 要源码的话,请联系我: QQ:...
    • directshow视频播放器MFC
      借用directshow开发的视频播放器,支持avi,mpg,mpeg,mp3,wma等多种音视频格式
    • DirectShow_PLAY播放器
      DirectShow_PLAY播放器,用delphi写的,基于Microsoft DirectShow开发而成。
    • asp.net directShow播放器
      asp.net directShow播放器
    • DirectShow音乐播放器源码
      Ctrl + Home 显示/隐藏播放器 Ctrl + Up 音量增大 Ctrl + Down 音量减小 5.使用DirectShow播放音乐。 6.支持发送歌曲直接到可移动磁盘。 7.搜索引擎使用的是百度。 。。。 更多的内容请参看源码中的说明.
    • C# Directshow简单播放器实例
      一个winCe下简单的多媒体播放器。可以播放3gp avi wmv等视频。供初学者学习。调用OpenNETCF开源控件