00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "GfxVideoPlayer.h"
00030
00031 #include <EIKENV.H>
00032
00033 _LIT(KVideoFileName,"c:\\data\\video\\videotest.3gp");
00034
00035 CGfxVideoPlayer * CGfxVideoPlayer :: NewL(CVideoPlayerControl* aView)
00036 {
00037 CGfxVideoPlayer * self = new (ELeave) CGfxVideoPlayer ();
00038 CleanupStack::PushL( self);
00039 self->ConstructL(aView );
00040 CleanupStack::Pop();
00041 return self;
00042 }
00043 void CGfxVideoPlayer ::ConstructL(CVideoPlayerControl* aView)
00044 {
00045 iView = aView;
00046 }
00047 CGfxVideoPlayer ::CGfxVideoPlayer ():iPlayer(NULL)
00048 {
00049
00050 }
00051 CGfxVideoPlayer ::~CGfxVideoPlayer ()
00052 {
00053 delete iPlayer, iPlayer = NULL;
00054 }
00055
00056 void CGfxVideoPlayer ::InitControllerL()
00057 {
00058 iPlayer = NULL;
00059 iPlayer = CVideoPlayerUtility::NewL(*this,EMdaPriorityNormal,
00060 EMdaPriorityPreferenceNone,
00061 iView->ClientWsSession(),
00062 iView->ScreenDevice(),
00063 iView->ClientWindow(),
00064 iView->VideoRect(),
00065 iView->VideoRect() );
00066 iPlayer->OpenFileL( KVideoFileName);
00067 }
00068 void CGfxVideoPlayer ::MvpuoPrepareComplete(TInt aError)
00069 {
00070 if(aError)
00071 iView->SignalError(_L("MvpuoPrepareComplete"), aError);
00072 else
00073 iPlayer->Play();
00074 }
00075 void CGfxVideoPlayer ::MvpuoEvent(const TMMFEvent& )
00076 {
00077
00078
00079 }
00080 void CGfxVideoPlayer ::MvpuoPlayComplete(TInt aError)
00081 {
00082 if(aError)
00083 iView->SignalError(_L("MvpuoPlayComplete"), aError);
00084 }
00085 void CGfxVideoPlayer ::MvpuoFrameReady(CFbsBitmap& ,TInt aError)
00086 {
00087 if(aError)
00088 iView->SignalError(_L("MvpuoFrameReady"), aError);
00089 }
00090 void CGfxVideoPlayer ::MvpuoOpenComplete(TInt aError)
00091 {
00092 if(aError)
00093 iView->SignalError(_L("MvpuoOpenComplete"), aError);
00094 else
00095 iPlayer->Prepare();
00096 }
00097 void CGfxVideoPlayer ::PauseL()
00098 {
00099 iPlayer->PauseL();
00100 }
00101 TTimeIntervalMicroSeconds CGfxVideoPlayer ::PositionL()
00102 {
00103 return iPlayer->PositionL();
00104 }
00105 TTimeIntervalMicroSeconds CGfxVideoPlayer ::DurationL()
00106 {
00107 return iPlayer->DurationL();
00108 }
00109 void CGfxVideoPlayer ::Stop()
00110 {
00111 iPlayer->Stop();
00112 }
00113
00114 CVideoPlayerControl* CVideoPlayerControl::NewL(const TRect& aRect)
00115 {
00116 CVideoPlayerControl* self = CVideoPlayerControl::NewLC(aRect);
00117 CleanupStack::Pop(self);
00118 return self;
00119 }
00120 CVideoPlayerControl* CVideoPlayerControl::NewLC(const TRect& aRect)
00121 {
00122 CVideoPlayerControl* self = new (ELeave) CVideoPlayerControl;
00123 CleanupStack::PushL(self);
00124 self->ConstructL(aRect);
00125 return self;
00126 }
00127
00128 CVideoPlayerControl::CVideoPlayerControl()
00129 {
00130
00131 }
00132 CVideoPlayerControl::~CVideoPlayerControl()
00133 {
00134 if(iPlayer)
00135 iPlayer->Stop();
00136 delete iPlayer;
00137 }
00138 void CVideoPlayerControl::ConstructL(const TRect& aRect)
00139 {
00140 iPlayer = CGfxVideoPlayer::NewL(this);
00141
00142 CreateWindowL();
00143 SetRect(aRect);
00144 iVideoRect = Rect();
00145 TPoint point = PositionRelativeToScreen();
00146 iVideoRect.Move(point);
00147 ActivateL();
00148 }
00149
00150 void CVideoPlayerControl::StartL()
00151 {
00152 iPlayer->InitControllerL();
00153 }
00154
00155 void CVideoPlayerControl::StopL()
00156 {
00157 iPlayer->Stop();
00158 }
00159
00160 void CVideoPlayerControl::SignalError(const TDesC& aCallBack, TInt aErrorCode)
00161 {
00162 TBuf<10> errorString;
00163 errorString.AppendNum(aErrorCode);
00164
00165 iEikonEnv->AlertWin(aCallBack, errorString);
00166 }
00167
00168 void CVideoPlayerControl::Draw(const TRect& ) const
00169 {
00170 CWindowGc& gc = SystemGc();
00171
00172 gc.SetBrushColor(KRgbTransparent);
00173 gc.SetBrushStyle (CGraphicsContext::ESolidBrush);
00174 TRect rect = Rect();
00175 gc.Clear(rect);
00176 }
00177
00178 inline RWindow& CVideoPlayerControl::ClientWindow()
00179 {
00180 return Window();
00181 }
00182 inline TRect CVideoPlayerControl::VideoRect() const
00183 {
00184 return iVideoRect;
00185 }
00186 inline RWsSession& CVideoPlayerControl::ClientWsSession()
00187 {
00188 return ControlEnv()->WsSession();
00189 }
00190 inline CWsScreenDevice& CVideoPlayerControl::ScreenDevice()
00191 {
00192 return *(ControlEnv()->ScreenDevice());
00193 }