I am implementing a header file "IVideoPlayer.h" and I have created an abstract class "IVideoPlayer".
class IVideoPlayer
{
public:
// Initialization
virtual bool Load(const char* pFilePath, bool useSubtitles = false) = 0;
virtual bool Start() = 0;
virtual bool Stop() = 0;
//....
};
And the functions of that are defined in file "VideoPlayer.cpp"
#include "stdafx.h"
#include "IVideoPlayer.h"
#include <dshow.h>
HRESULT hr = CoInitialize(NULL);
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
class VideoPlayer:public IVideoPlayer
{
public:
bool Load(const char* pFilePath, bool useSubtitles = false)
{
EPlaybackStatus var1 = PBS_ERROR;
// Initialize the COM library.
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return 0;
}
// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return 0;
}
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// Build the graph. IMPORTANT: Change this string to a file on your system.
hr = pGraph->RenderFile(L"G:\edit.wmv", NULL);
return 0;
}
bool Start()
{
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
}
return 0;
}
bool Stop()
{
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
return 0;
}
};
And to check the header file I have created file sample.cpp
#include "stdafx.h"
#include "IVideoPlayer.h"
#include <stdio.h>
#include <conio.h>
int main(void)
{
VideoPlayer h;
h.Load("G:\hila.wmv");
getch();
return 0;
}
The errors are:
Error 1 error C2065: 'VideoPlayer' : undeclared identifier
Error 2 error C2146: syntax error : missing ';' before identifier 'h'
Error 3 error C2065: 'h' : undeclared identifier
Error 4 error C2065: 'h' : undeclared identifier
Error 5 error C2228: left of '.Load' must have class/struct/union
Why compiler is showing it as undeclared identifer? Any help is accepted. Thanking you in advance