次のコードを使用して、S60 5th エディションで音楽ファイルを再生しようとしています。
_LIT(KMusicFilename, "C:\\Data\\Music.mp3");
TApaTaskList iTaskList(CCoeEnv::Static()->WsSession());
TBool iExists;
TApaTask iApaTask = iTaskList.FindApp(TUid::Uid(0x102072C3));
iExists = iApaTask.Exists();
if(iExists)
{
// Music player already running
iApaTask.SwitchOpenFile(KMusicFilename);
iApaTask.BringToForeground();
}
else
{
// music player is not running and needs to be launched
RApaLsSession iAplsSession;
User::LeaveIfError(iAplsSession.Connect());
TThreadId thread;
iAplsSession.StartDocument( KMusicFilename,
thread,
RApaLsSession::ESwitchFiles );
iAplsSession.Close();
}
問題は、音楽プレーヤーが既に実行されている場合、このコード サンプルが機能しないことです。既に再生されていたメディア ファイルは引き続き再生されますが、この機能SwitchOpenFile
は影響しません。
これに対する回避策はありますか?
ありがとうございました。