📄 realplayerview.cpp
字号:
// realplayerView.cpp : implementation of the CRealplayerView class
//
#include "stdafx.h"
#include "realplayer.h"
#include "filemessage.h"
#include "realplayerDoc.h"
#include "realplayerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRealplayerView
IMPLEMENT_DYNCREATE(CRealplayerView, CView)
BEGIN_MESSAGE_MAP(CRealplayerView, CView)
//{{AFX_MSG_MAP(CRealplayerView)
ON_COMMAND(ID_OPEN, OnOpen)
ON_COMMAND(ID_EXIT, OnExit)
ON_COMMAND(ID_PLAY, OnPlay)
ON_WM_SIZE()
ON_WM_CREATE()
ON_COMMAND(ID_LOOP, OnLoop)
ON_UPDATE_COMMAND_UI(ID_LOOP, OnUpdateLoop)
ON_COMMAND(ID_ADD, OnAdd)
ON_COMMAND(ID_SUB, OnSub)
ON_COMMAND(ID_FULLSCREEN, OnFullscreen)
ON_UPDATE_COMMAND_UI(ID_FULLSCREEN, OnUpdateFullscreen)
ON_COMMAND(ID_FILEMESSAGE, OnFilemessage)
ON_COMMAND(ID_PAUSE, OnPause)
ON_COMMAND(ID_STOP, OnStop)
ON_COMMAND(ID_BACK, OnBack)
ON_COMMAND(ID_FRONT, OnFront)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRealplayerView construction/destruction
CRealplayerView::CRealplayerView()
{
// TODO: add construction code here
loop=FALSE;
full=FALSE;
}
CRealplayerView::~CRealplayerView()
{
}
BOOL CRealplayerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CRealplayerView drawing
void CRealplayerView::OnDraw(CDC* pDC)
{
CRealplayerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CRealplayerView printing
BOOL CRealplayerView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CRealplayerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CRealplayerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CRealplayerView diagnostics
#ifdef _DEBUG
void CRealplayerView::AssertValid() const
{
CView::AssertValid();
}
void CRealplayerView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CRealplayerDoc* CRealplayerView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRealplayerDoc)));
return (CRealplayerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CRealplayerView message handlers
void CRealplayerView::OnOpen()
{
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,"real文件|*.rm||");
if(dlg.DoModal()==IDOK){
strname=dlg.GetPathName();
}
if(strname!="")
{
rl.SetSource(strname);
}
}
void CRealplayerView::OnExit()
{
CFrameWnd *p=(CFrameWnd*)this->GetParent();
p->DestroyWindow();
}
void CRealplayerView::OnPlay()
{
rl.DoPlay();
}
void CRealplayerView::OnSize(UINT nType, int cx, int cy)
{
//CView::OnSize(nType, cx, cy);
rl.SetWindowPos(NULL,0,0,cx,cy,SWP_NOZORDER|SWP_NOMOVE);
// TODO: Add your message handler code here
}
int CRealplayerView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
rl.Create("realplayer",WS_CHILD|WS_VISIBLE,CRect(0,0,200,200),this,1000,NULL,FALSE);
// TODO: Add your specialized creation code here
return 0;
}
void CRealplayerView::OnLoop()
{
if(rl.GetPlayState()!=3)return;
loop=!loop;
rl.SetLoop(loop);
}
void CRealplayerView::OnUpdateLoop(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(loop);
}
void CRealplayerView::OnAdd()
{
short vl;
if(rl.GetPlayState()==3)
{
vl=rl.GetVolume();
if(vl<=90)
{
rl.DoPause();
rl.SetVolume(vl+10);
rl.DoPlay();
}
}
else
{
if(vl<=90)
rl.SetVolume(vl+10);
}
}
void CRealplayerView::OnSub()
{
short vl;
if(rl.GetPlayState()==3)
{
vl=rl.GetVolume();
if(vl>=10)
{
rl.DoPause();
rl.SetVolume(vl-10);
rl.DoPlay();
}
}
else
{
if(vl>=10)
rl.SetVolume(vl-10);
}
}
void CRealplayerView::OnFullscreen()
{
// TODO: Add your command handler code here
if(rl.GetPlayState()!=3)return;
full=!full;
rl.DoPause();
rl.SetFullScreen();
rl.DoPlay();
}
void CRealplayerView::OnUpdateFullscreen(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(full);
}
void CRealplayerView::OnFilemessage()
{
if(rl.GetPlayState()==0)return;
FileMessage file;
file.stAuthor=rl.GetAuthor();
file.stVer=rl.GetCopyright();
file.stVer=rl.GetTitle();
file.DoModal();
}
void CRealplayerView::OnPause()
{
if(rl.GetPlayState()!=3)return;
rl.DoPause();
}
void CRealplayerView::OnStop()
{
if(rl.GetPlayState()==0)return;
rl.DoStop();
}
void CRealplayerView::OnBack()
{
if(rl.GetPlayState()==3)
{
long pos=rl.GetPosition();
if(pos<2000)return;
rl.DoPause();
rl.SetPosition(pos-2000);
rl.DoPlay();
}
}
void CRealplayerView::OnFront()
{
if(rl.GetPlayState()==3)
{
long pos=rl.GetPosition();
rl.DoPause();
rl.SetPosition(pos+2000);
rl.DoPlay();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -