📄 mplayer.h
字号:
/*
This file is part of KCeasy (http://www.kceasy.com)
Copyright (C) 2002-2004 Markus Kern <mkern@kceasy.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
//---------------------------------------------------------------------------
#ifndef MPlayerH
#define MPlayerH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <extctrls.hpp>
#include "istring.h"
#include "simplevlc.h"
//---------------------------------------------------------------------------
static const UINT WM_SVLC_CALLBACK = WM_USER + 1;
//---------------------------------------------------------------------------
using namespace KCeasyEngine;
typedef enum
{
MPClosed,
MPLoading,
MPOpen,
MPPlaying,
MPPaused,
MPStopped,
MPError
} TMPlayerState;
typedef enum
{
MPHalfSize,
MPDefaultSize,
MPDoubleSize,
MPFitToWindow,
MPFullscreen
} TMPlayerDisplaySize;
typedef void __fastcall (__closure *TMPlayerStateChangeEvent)(TObject* Sender, TMPlayerState NewState);
typedef void __fastcall (__closure *TMPlayerPositionChangeEvent)(TObject* Sender, float Position, int Duration);
typedef void __fastcall (__closure *TMPlayerDisplayPopupEvent)(TObject* Sender, bool Show);
class TMPlayer : public TWinControl
{
friend long FAR PASCAL gDisplayWndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);
friend void SVLC_CC gSVlcCallbackFunc (HSVLC svlc, SVlcCallbackEvent event, void *edata, void *udata);
__published:
__property OnKeyPress = {read=FOnKeyPress, write=FOnKeyPress, default=NULL};
__property TMPlayerStateChangeEvent OnStateChange = {read=FOnStateChange, write=FOnStateChange, default=NULL};
__property TMPlayerPositionChangeEvent OnPositionChange = {read=FOnPositionChange, write=FOnPositionChange, default=NULL};
__property TMPlayerDisplayPopupEvent OnDisplayPopup = {read=FOnDisplayPopup, write=FOnDisplayPopup, default=NULL};
public:
__fastcall virtual TMPlayer(TComponent* Owner);
__fastcall virtual ~TMPlayer();
// don't call this before the TMPlayer window is fully created
bool Initialize(int LogLevel = -1);
bool Shutdown();
bool IsInitialized() { return IsVlcLoaded(); }
// playback
bool Play(string Filename);
bool PlayNetwork(string Url);
bool Stop();
bool Pause(bool Pause);
bool TogglePause();
bool IsPaused() { return (GetState() == MPPaused); }
TMPlayerState GetState();
bool IsSeekable();
bool SetPosition(float Position);
float GetPosition(); // in [0,1]
int GetDuration(); // in msec
bool GetStreamCount(int* Audio, int* Video);
bool SetVisualization(bool Show);
// video
TMPlayerDisplaySize GetDisplaySize();
bool SetDisplaySize(TMPlayerDisplaySize Size);
// audio
bool SetVolume(float Volume);
float GetVolume(); // in [0,1]
bool Mute(bool Mute);
bool IsMuted();
bool ToggleMute();
protected:
TMPlayerStateChangeEvent FOnStateChange;
TMPlayerPositionChangeEvent FOnPositionChange;
TMPlayerDisplayPopupEvent FOnDisplayPopup;
TKeyPressEvent FOnKeyPress;
HINSTANCE hVlcDll;
SVlcInterface *VlcIntf;
HSVLC hVlc;
HWND DisplayWnd;
bool LoadVlc(int LogLevel = -1);
bool UnloadVlc();
bool IsVlcLoaded();
void __fastcall WMSVlcCallback(TMessage& Msg);
bool CreateDisplayWnd();
bool DestroyDisplayWnd();
long FAR PASCAL DisplayWndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);
TMPlayerState ConvertVlcState(SVlcPlaybackState VlcState);
DYNAMIC void __fastcall Resize(void);
virtual void __fastcall CreateParams(TCreateParams &Params);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_SVLC_CALLBACK, TMessage, WMSVlcCallback)
END_MESSAGE_MAP(TWinControl)
};
#endif // MPlayerH
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -