I've checked it, here's my code:
Document:
Code:
CFileStore* CMyDocument::OpenFileL(TBool doOpen, const TDesC& filename, RFs& fs)
{
CFileStore* result = CAknDocument::OpenFileL(doOpen, filename, fs);
CMyAppUi* appUi = (CMyAppUi*) iAvkonAppUi;
if (appUi->IsRunningEmbedded ())
{
appUi->iLauncher = CMyLauncher::NewL();
appUi->iImportFileName = filename;
appUi->iLauncher->Start(0);
}
return result;
}
Launcher.h
Code:
class CMyLauncher : CActive
{
public:
static CMyLauncher* NewL();
~CMyLauncher();
void Start(TTimeIntervalMicroSeconds32 delay);
private:
CMyLauncher();
void ConstructL();
void RunL();
void DoCancel();
TInt RunError (TInt error);
private:
RTimer iTimer;
};
Relevant code from Launcher.cpp
Code:
void CMyLauncher::RunL()
{
CMyAppUi* appUi = (CMyAppUi*) iAvkonAppUi;
appUi->LaunchFile();
}
Relevant code from AppUi:
Code:
void CMyAppUi::LaunchFile()
{
TBuf8<KMaxFileName> launchFileName;
launchFileName.Copy(iImportFileName);
ActivateLocalViewL(iMyPlayerView->Id(), TUid::Uid(1), launchFileName);
}
inline TBool IsRunningEmbedded () { return iEikonEnv->StartedAsServerApp(); }
Relevant code from reg_rss:
Code:
RESOURCE APP_REGISTRATION_INFO
{
app_file="myappfile";
localisable_resource_file = qtn_loc_resource_file_1;
localisable_resource_id = R_LOCALISABLE_APP_INFO;
embeddability=KAppEmbeddable;
newfile=KAppDoesNotSupportNewFile;
// MIME priorities
datatype_list =
{
DATATYPE
{
priority = EDataTypePriorityHigh;
type = "video/3gpp";
},
DATATYPE
{
priority = EDataTypePriorityHigh;
type = "video/mp4v-es";
}
};
}
Launcher (active object) waits until my program's event loop starts and then launches the file. I am not sure if I am supposed to build a recognizer. The problem is that RealPlayer starts playing the file when I open it, then it switches to my player. The realplayer thread stays active, but when I close the viewer after my app has played the video, that thread crashes.