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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <coecntrl.h>
00043 #include <coemain.h>
00044
00045
00046 #include "videoengine.h"
00047 #include "videoplayerwrapper.h"
00048
00049
00050 _LIT(KDirVideos,"C:\\data\\Videos\\example_video.3gp");
00051
00052
00057 CVideoPlayerEngine* CVideoPlayerEngine::NewL(VideoPlayerWrapper *aPlayerWrapper)
00058 {
00059 CVideoPlayerEngine* self = CVideoPlayerEngine::NewLC(aPlayerWrapper);
00060 CleanupStack::Pop(self);
00061 return self;
00062 }
00063
00068 CVideoPlayerEngine* CVideoPlayerEngine::NewLC(VideoPlayerWrapper *aPlayerWrapper)
00069 {
00070 CVideoPlayerEngine* self = new (ELeave) CVideoPlayerEngine();
00071 CleanupStack::PushL(self);
00072 self->ConstructL(aPlayerWrapper);
00073 return self;
00074 }
00075
00079 void CVideoPlayerEngine::ConstructL(VideoPlayerWrapper *aPlayerWrapper)
00080 {
00081 iPlayerWrapper = aPlayerWrapper;
00082 }
00083
00087 CVideoPlayerEngine::CVideoPlayerEngine() :
00088 iState(ENotInitialized)
00089 {
00090 }
00091
00095 CVideoPlayerEngine::~CVideoPlayerEngine()
00096 {
00097 if( iPlayer )
00098 {
00099 iPlayer->Close();
00100 delete iPlayer;
00101 iPlayer = NULL;
00102 }
00103 if( iVideoContainer )
00104 {
00105 delete iPlayer;
00106 iPlayer = NULL;
00107 }
00108 }
00109
00114 void CVideoPlayerEngine::InitL()
00115
00116 {
00117 iState = ENotInitialized;
00118 if (iPlayer)
00119 {
00120 delete iPlayer;
00121 iPlayer = NULL;
00122 };
00123
00124
00125 if ( ! iVideoContainer )
00126 {
00127 iVideoContainer = CVideoContainer::NewL();
00128 }
00129
00130 iPlayer = CVideoPlayerUtility::NewL( *this, EMdaPriorityNormal, EMdaPriorityPreferenceNone,
00131 iVideoContainer->ClientWsSession(), iVideoContainer->ScreenDevice(),
00132 iVideoContainer->ClientWindow(), iVideoContainer->VideoRect(), iVideoContainer->VideoRect());
00133
00134 }
00135
00139 void CVideoPlayerEngine::OpenL()
00140 {
00141 TRAPD(unsupported, iPlayer->OpenFileL(KDirVideos));
00142 if ( unsupported != KErrNone )
00143 {
00144 _LIT(KOpenFailed, "Open failed");
00145 TBuf<24> message(KOpenFailed);
00146 iPlayerWrapper->printMessage(message);
00147 iPlayer->Close();
00148 delete iPlayer;
00149 iPlayer = NULL;
00150 User::Leave(unsupported);
00151 }
00152 }
00156 void CVideoPlayerEngine::Play()
00157 {
00158 if(( iState == EInitialized)||( iState == EPaused ))
00159 {
00160 iPlayer->Play();
00161 iState = EPlaying;
00162 _LIT(KPlaying, "Video playing");
00163 TBuf<24> message(KPlaying);
00164 iPlayerWrapper->printMessage(message);
00165 }
00166 else
00167 {
00168 return;
00169 }
00170 }
00171
00175 void CVideoPlayerEngine::PauseL()
00176 {
00177 if( iState == EPlaying )
00178 {
00179 TRAPD(err,iPlayer->PauseL());
00180 if (err != KErrNone)
00181 {
00182 _LIT(KPausefailed,"Video Pause failed");
00183 TBuf<32> message(KPausefailed);
00184 iPlayerWrapper->printMessage(message);
00185 User::Leave(err);
00186 }
00187 else
00188 {
00189 iState = EPaused;
00190 _LIT(KPaused,"Video Paused");
00191 TBuf<32> message(KPaused);
00192 iPlayerWrapper->printMessage(message);
00193 }
00194 }
00195 else
00196 {
00197 return;
00198 }
00199 }
00200
00204 void CVideoPlayerEngine::Stop()
00205 {
00206 if( iState != EPlaying && iState != EPaused )
00207 {
00208 return;
00209 }
00210 iPlayer->Stop();
00211 iState = EStopped;
00212 _LIT(KStopped,"Video Playback stopped !!!");
00213 TBuf<32> message(KStopped);
00214 iPlayerWrapper->printMessage(message);
00215 iPlayer->Close();
00216 }
00217
00222 void CVideoPlayerEngine::SetVolume(TInt aValue)
00223 {
00224 if( iState )
00225 {
00226 TRAPD(err,iPlayer->SetVolumeL(aValue));
00227 if (err != KErrNone)
00228 {
00229 User::Leave(err);
00230 }
00231 }
00232 else
00233 {
00234 return;
00235 }
00236
00237 }
00238
00244 void CVideoPlayerEngine::MvpuoOpenComplete(TInt aError)
00245 {
00246 if( aError == KErrNone )
00247 {
00248 _LIT(KFileOpen,"File Open Completed !!!");
00249 TBuf<24> message(KFileOpen);
00250 iPlayerWrapper->printMessage(message);
00251 iPlayer->Prepare();
00252 iState = EInitialized;
00253 }
00254 else
00255 {
00256 _LIT(KOpenComFailed,"File Open Complete failed !!!");
00257 TBuf<24> message(KOpenComFailed);
00258 iPlayerWrapper->printMessage(message);
00259 iPlayer->Close();
00260 iState = EStopped;
00261
00262 if ( iPlayer )
00263 {
00264 delete iPlayer;
00265 iPlayer = NULL;
00266 };
00267 }
00268 }
00269
00277 void CVideoPlayerEngine::MvpuoPrepareComplete(TInt aError)
00278 {
00279 if( aError == KErrNone )
00280 {
00281 _LIT(KPrepareComplete,"Prepare Completed !!!");
00282 TBuf<24> message(KPrepareComplete);
00283 iPlayerWrapper->printMessage(message);
00284 }
00285 }
00286
00292 void CVideoPlayerEngine::MvpuoPlayComplete(TInt aError)
00293 {
00294 if( aError == KErrNone )
00295 {
00296 _LIT(KPlayComplete,"Playback Completed !!!");
00297 TBuf<24> message(KPlayComplete);
00298 iPlayerWrapper->printMessage(message);
00299 Stop();
00300 }
00301 else
00302 {
00303 _LIT(KPlayCompletefailed,"Playback Complete failed !!!");
00304 TBuf<24> message(KPlayCompletefailed);
00305 iPlayerWrapper->printMessage(message);
00306 }
00307 }
00308
00313 void CVideoPlayerEngine::MvpuoFrameReady(CFbsBitmap& ,TInt )
00314 {
00315 }
00316
00320 void CVideoPlayerEngine::MvpuoEvent(const TMMFEvent& )
00321 {
00322 }
00323
00324
00325