Автор: Пользователь скрыл имя, 20 Ноября 2014 в 22:02, курсовая работа
Цель разработки: создание информационной мультимедиа системы (медиа-плеера) для презентации аудио-видео информации о факультете КТАС, представленной в специально отснятых и смонтированных .avi файлах.
Результатом разработки является программная реализация специализированного видео проигрывателя и оформление его в виде прикладного приложения в среде Visual C++ 2003 .NET, а также построение специализированного модуля для воспроизведения и управления воспроизведением .avi файлов.
Введение.............................................................................................2
1. Эскизный проект.............................................................................3
1.1 Концептуальная модель системы………………………………….3
1.2 Методика реализации визуализации ИМС …............................4
1.3 Методика реализации пользовательского интерфейса .............4
2. Технологический проект.................................................................5
2.1 Технология разработки модулей программы ……….................5
2.2 Разработка модулей ………………………………........................5
2.2.1. Разработка модуля воспроизведения …………….............5
2.2.2. Разработка модуля пользовательского интерфейса..........9
3. Руководство программиста.............................................................11
3.1 Назначение и условия применения программы..........................11
3.2 Входные и выходные данные.....................................................11
Заключение.........................................................................................12
//// Is this an audio-only file (no video component)?
CheckVisibility();
//// Have the graph signal event via window callbacks for performance
JIF(pME->SetNotifyWindow((
if (!g_bAudioOnly)
{
// Setup the video window
JIF(pVW->put_Owner((OAHWND)
JIF(pVW->put_WindowStyle(WS_
JIF(InitVideoWindow(1, 1));
}
else
{
// Initialize the default player size and enable playback menu items
JIF(InitPlayerWindow());
}
// Complete window initialization
ShowWindow(ghApp, SW_SHOWNORMAL);
UpdateWindow(ghApp);
SetForegroundWindow(ghApp);
g_bFullscreen = FALSE;
g_PlaybackRate = 1.0;
//#ifdef REGISTER_FILTERGRAPH
// hr = AddGraphToRot(pGB, &g_dwGraphRegister);
// if (FAILED(hr))
// {
// Msg(TEXT("Failed to register filter graph with ROT! hr=0x%x"), hr);
// g_dwGraphRegister = 0;
// }
//#endif
// Run the graph to play the media file
JIF(pMC->Run());
g_psCurrent=Running;
SetFocus(ghApp);
}
return hr;
}
//Я
HRESULT InitVideoWindow(int nMultiplier, int nDivider)
{
//LONG lHeight, lWidth;
HRESULT hr = S_OK;
RECT rect;
if (!pBV)
return S_OK;
// Read the default video size
//hr = pBV->GetVideoSize(&lWidth, &lHeight);
if (hr == E_NOINTERFACE)
return S_OK;
// Account for requests of normal, half, or double size
/*lWidth = lWidth * nMultiplier / nDivider;
lHeight = lHeight * nMultiplier / nDivider;
int nTitleHeight = GetSystemMetrics(SM_CYCAPTION)
int nBorderWidth = GetSystemMetrics(SM_CXBORDER);
int nBorderHeight = GetSystemMetrics(SM_CYBORDER);
GetClientRect(ghApp, &rect);
// Account for size of title bar and borders for exact match
// of window client area to default video size
SetWindowPos(ghApp, NULL, 0, 0, rect.right,rect.bottom,
SWP_NOMOVE | SWP_NOOWNERZORDER);
GetClientRect(ghApp, &rect);
JIF(pVW->SetWindowPosition(
return hr;
}
//Я
HRESULT InitPlayerWindow(void)
{
// Reset to a default size for audio and after closing a clip
/*SetWindowPos(ghApp, NULL, 0, 0,
DEFAULT_AUDIO_WIDTH,
DEFAULT_AUDIO_HEIGHT,
SWP_NOMOVE | SWP_NOOWNERZORDER);*/
// Check the 'full size' menu item
//
CheckSizeMenu(ID_FILE_SIZE_
// EnablePlaybackMenu(FALSE, 0);
return S_OK;
}
void CheckVisibility(void)
{
long lVisible;
HRESULT hr;
if ((!pVW) || (!pBV))
{
// Audio-only files have no video interfaces. This might also
// be a file whose video component uses an unknown video codec.
g_bAudioOnly = TRUE;
return;
}
else
{
// Clear the global flag
g_bAudioOnly = FALSE;
}
hr = pVW->get_Visible(&lVisible);
if (FAILED(hr))
{
// If this is an audio-only clip, get_Visible() won't work.
//
// Also, if this video is encoded with an unsupported codec,
// we won't see any video, although the audio will work if it is
// of a supported format.
//
if (hr == E_NOINTERFACE)
{
g_bAudioOnly = TRUE;
}
else
{
Msg(TEXT("Failed(%08lx) in pVW->get_Visible()!\r\n"), hr);
}
}
}
void PauseClip(void)
{
if (!pMC)
return;
// Toggle play/pause behavior
if((g_psCurrent == Paused) || (g_psCurrent == Stopped))
{
if (SUCCEEDED(pMC->Run()))
g_psCurrent = Running;
}
else
{
if (SUCCEEDED(pMC->Pause()))
g_psCurrent = Paused;
}
}
void StopClip(void)
{
HRESULT hr;
if ((!pMC) || (!pMS))
return;
// Stop and reset postion to beginning
if((g_psCurrent == Paused) || (g_psCurrent == Running))
{
LONGLONG pos = 0;
hr = pMC->Stop();
g_psCurrent = Stopped;
// Seek to the beginning
hr = pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning ,
NULL, AM_SEEKING_NoPositioning);
// Display the first frame to indicate the reset condition
hr = pMC->Pause();
}
}
//Я
void OpenClip(int clip)
{
HRESULT hr;
// Reset status variables
g_psCurrent = Stopped;
g_lVolume = VOLUME_FULL;
GetCurrentDirectory(MAX_PATH,
LPSTR file;
switch(clip)
{
case 1:file=_tcscat(g_szFileName,_
case 2:file=_tcscat(g_szFileName,_
case 3:file=_tcscat(g_szFileName,_
case 4:file=_tcscat(g_szFileName,_
}
// Start playing the media file
hr = PlayMovieInWindow(file);
// If we couldn't play the clip, clean up
if (FAILED(hr))
CloseClip();
}
void CloseClip()
{
HRESULT hr;
// Stop media playback
if(pMC)
hr = pMC->Stop();
// Clear global flags
g_psCurrent = Stopped;
g_bAudioOnly = TRUE;
g_bFullscreen = FALSE;
// Free DirectShow interfaces
CloseInterfaces();
// Clear file name to allow selection of new file with open dialog
g_szFileName[0] = L'\0';
// No current media state
g_psCurrent = Init;
// Reset the player window
RECT rect;
GetClientRect(ghApp, &rect);
InvalidateRect(ghApp, &rect, TRUE);
InitPlayerWindow();
}
void CloseInterfaces(void)
{
HRESULT hr;
// Relinquish ownership (IMPORTANT!) after hiding video window
if(pVW)
{
hr = pVW->put_Visible(OAFALSE);
hr = pVW->put_Owner(NULL);
}
// Disable event callbacks
if (pME)
hr = pME->SetNotifyWindow((OAHWND)
// Release and zero DirectShow interfaces
SAFE_RELEASE(pME);
SAFE_RELEASE(pMS);
SAFE_RELEASE(pMP);
SAFE_RELEASE(pMC);
SAFE_RELEASE(pBA);
SAFE_RELEASE(pBV);
SAFE_RELEASE(pVW);
SAFE_RELEASE(pGB);
}
//Я
void Msg(TCHAR *szFormat, ...)
{
TCHAR szBuffer[1024]; // Large buffer for long filenames or URLs
const size_t NUMCHARS = sizeof(szBuffer) / sizeof(szBuffer[0]);
const int LASTCHAR = NUMCHARS - 1;
// Format the input string
va_list pArgs;
va_start(pArgs, szFormat);
// Use a bounded buffer size to prevent buffer overruns. Limit count to
// character size minus one to allow for a NULL terminating character.
_vsntprintf(szBuffer, NUMCHARS - 1, szFormat, pArgs);
va_end(pArgs);
// Ensure that the formatted string is NULL-terminated
szBuffer[LASTCHAR] = TEXT('\0');
// Display a message box with the formatted string
MessageBox(NULL, szBuffer, TEXT("PlayWnd Sample"), MB_OK);
}
//Я
HRESULT ToggleMute(void)
{
HRESULT hr=S_OK;
if ((!pGB) || (!pBA))
return S_OK;
// Read current volume
hr = pBA->get_Volume(&g_lVolume);
if (hr == E_NOTIMPL)
{
// Fail quietly if this is a video-only media file
return S_OK;
}
else if (FAILED(hr))
{
Msg(TEXT("Failed to read audio volume! hr=0x%x\r\n"), hr);
return hr;
}
// Switch volume levels
if (g_lVolume == VOLUME_FULL)
g_lVolume = VOLUME_SILENCE;
else
g_lVolume = VOLUME_FULL;
// Set new volume
JIF(pBA->put_Volume(g_lVolume)
//UpdateMainTitle();
return hr;
}
HRESULT ToggleFullScreen(void)
{
HRESULT hr=S_OK;
LONG lMode;
static HWND hDrain=0;
// Don't bother with full-screen for audio-only files
if ((g_bAudioOnly) || (!pVW))
return S_OK;
// Read current state
JIF(pVW->get_FullScreenMode(&
if (lMode == OAFALSE)
{
// Save current message drain
LIF(pVW->get_MessageDrain((
// Set message drain to application main window
LIF(pVW->put_MessageDrain((
// Switch to full-screen mode
lMode = OATRUE;
JIF(pVW->put_FullScreenMode(
g_bFullscreen = TRUE;
}
else
{
// Switch back to windowed mode
lMode = OAFALSE;
JIF(pVW->put_FullScreenMode(
// Undo change of message drain
LIF(pVW->put_MessageDrain((
// Reset video window
LIF(pVW->SetWindowForeground(-
// Reclaim keyboard focus for player application
UpdateWindow(ghApp);
SetForegroundWindow(ghApp);
SetFocus(ghApp);
g_bFullscreen = FALSE;
}
return hr;
}
//Я
HRESULT HandleGraphEvent(void)
{
LONG evCode, evParam1, evParam2;
HRESULT hr=S_OK;
// Make sure that we don't access the media event interface
// after it has already been released.
if (!pME)
return S_OK;
// Process all queued events
while(SUCCEEDED(pME->GetEvent(
(LONG_PTR *) &evParam2, 0)))
{
// Free memory associated with callback, since we're not using it
hr = pME->FreeEventParams(evCode, evParam1, evParam2);
// If this is the end of the clip, reset to beginning
if(EC_COMPLETE == evCode)
{
LONGLONG pos=0;
// Reset to first frame of movie
hr = pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning ,
if (FAILED(hr))
{
// Some custom filters (like the Windows CE MIDI filter)
// may not implement seeking interfaces (IMediaSeeking)
// to allow seeking to the start. In that case, just stop
// and restart for the same effect. This should not be
// necessary in most cases.
if (FAILED(hr = pMC->Stop()))
{
Msg(TEXT("Failed(0x%08lx) to stop media clip!\r\n"), hr);
break;
}
if (FAILED(hr = pMC->Run()))
{
Msg(TEXT("Failed(0x%08lx) to reset media clip!\r\n"), hr);
break;
}
}
}
}
return hr;
}
}
Информация о работе Разработка тренажёров и обучающих программ