engine/src/PodcastModel.cpp
branchsymbian1
changeset 44 f6f9647922ba
parent 36 e010fc411ddc
child 56 c5cd47bc11ef
child 65 bcd88ba95046
equal deleted inserted replaced
41:56821195bd44 44:f6f9647922ba
    17 */
    17 */
    18 
    18 
    19 #include <commdb.h>
    19 #include <commdb.h>
    20 #include "PodcastModel.h"
    20 #include "PodcastModel.h"
    21 #include "FeedEngine.h"
    21 #include "FeedEngine.h"
    22 #include "SoundEngine.h"
       
    23 #include "SettingsEngine.h"
    22 #include "SettingsEngine.h"
    24 #include "ShowEngine.h"
    23 #include "ShowEngine.h"
    25 #include "connectionengine.h"
    24 #include "connectionengine.h"
    26 
    25 
    27 #include <cmdestination.h>
    26 #include <cmdestination.h>
    43 
    42 
    44 CPodcastModel::~CPodcastModel()
    43 CPodcastModel::~CPodcastModel()
    45 {
    44 {
    46 	
    45 	
    47 	delete iFeedEngine;
    46 	delete iFeedEngine;
    48 	delete iSoundEngine;
       
    49 	delete iSettingsEngine;
    47 	delete iSettingsEngine;
    50 	delete iShowEngine;
    48 	delete iShowEngine;
    51 
    49 
    52 	delete iIapNameArray;
    50 	delete iIapNameArray;
    53 	iIapIdArray.Close();
    51 	iIapIdArray.Close();
    87 	iConnectionEngine = CConnectionEngine::NewL(*this);	
    85 	iConnectionEngine = CConnectionEngine::NewL(*this);	
    88 	
    86 	
    89 	iFeedEngine = CFeedEngine::NewL(*this);
    87 	iFeedEngine = CFeedEngine::NewL(*this);
    90 	iShowEngine = CShowEngine::NewL(*this);
    88 	iShowEngine = CShowEngine::NewL(*this);
    91 
    89 
    92 	iSoundEngine = CSoundEngine::NewL(*this);	
       
    93 	DP("CPodcastModel::ConstructL END");
    90 	DP("CPodcastModel::ConstructL END");
    94 }
    91 }
    95 
    92 
    96 
    93 
    97 
    94 
   197 EXPORT_C CShowEngine& CPodcastModel::ShowEngine()
   194 EXPORT_C CShowEngine& CPodcastModel::ShowEngine()
   198 {
   195 {
   199 	return *iShowEngine;
   196 	return *iShowEngine;
   200 }
   197 }
   201 
   198 
   202 EXPORT_C CSoundEngine& CPodcastModel::SoundEngine()
       
   203 {
       
   204 	return *iSoundEngine;
       
   205 }
       
   206 
       
   207 EXPORT_C CSettingsEngine& CPodcastModel::SettingsEngine()
   199 EXPORT_C CSettingsEngine& CPodcastModel::SettingsEngine()
   208 {
   200 {
   209 	return *iSettingsEngine;
   201 	return *iSettingsEngine;
   210 }
   202 }
   211 
   203 
   214 	return *iConnectionEngine;
   206 	return *iConnectionEngine;
   215 }
   207 }
   216 
   208 
   217 EXPORT_C void CPodcastModel::PlayPausePodcastL(CShowInfo* aPodcast, TBool aPlayOnInit) 
   209 EXPORT_C void CPodcastModel::PlayPausePodcastL(CShowInfo* aPodcast, TBool aPlayOnInit) 
   218 	{
   210 	{
   219 	
   211 	// TODO: interact with MPX
   220 	// special treatment if this podcast is already active
   212 	}
   221 	if (iPlayingPodcast->Uid() == aPodcast->Uid() && SoundEngine().State() > ESoundEngineOpening ) {
       
   222 		if (aPodcast->PlayState() == EPlaying) {
       
   223 			SoundEngine().Pause();
       
   224 			aPodcast->SetPosition(iSoundEngine->Position());
       
   225 			aPodcast->SetPlayState(EPlayed);
       
   226 			aPodcast->SetPlayState(EPlayed);
       
   227 		} else {
       
   228 			iSoundEngine->Play();
       
   229 		}
       
   230 	} else {
       
   231 		// switching file, so save position
       
   232 		iSoundEngine->Pause();
       
   233 		if (iPlayingPodcast != NULL) {
       
   234 			iPlayingPodcast->SetPosition(iSoundEngine->Position());
       
   235 		}
       
   236 		
       
   237 		iSoundEngine->Stop(EFalse);
       
   238 
       
   239 		// we play video podcasts through the external player
       
   240 		if(aPodcast != NULL && aPodcast->ShowType() != EVideoPodcast) {
       
   241 			DP1("Starting: %S", &(aPodcast->FileName()));
       
   242 			TRAPD( error, iSoundEngine->OpenFileL(aPodcast->FileName(), aPlayOnInit) );
       
   243 			if (error != KErrNone) {
       
   244 				DP1("Error: %d", error);
       
   245 			} else {
       
   246 				iSoundEngine->SetPosition(aPodcast->Position().Int64() / 1000000);
       
   247 			}
       
   248 		}
       
   249 
       
   250 		iPlayingPodcast = aPodcast;		
       
   251 	}
       
   252 }
       
   253 
   213 
   254 EXPORT_C CFeedInfo* CPodcastModel::ActiveFeedInfo()
   214 EXPORT_C CFeedInfo* CPodcastModel::ActiveFeedInfo()
   255 {
   215 {
   256 	return iActiveFeed;
   216 	return iActiveFeed;
   257 }
   217 }