📄 vrexengine.cpp
字号:
/*
* ============================================================================
* Name : CVRexEngine from VRexEngine.cpp
* Part of : Video Example
* Created : 30/08/2006 by Forum Nokia
* Implementation notes:
* Version : 2.0
* Copyright: Nokia Corporation, 2006
* ============================================================================
*/
// INCLUDE FILES
#include <PathInfo.h> // for PathInfo
#include "VRexEngine.h"
#include "VRexListView.h"
#include "VRexRecorderAdapter.h"
// Number, name and file size
_LIT(KStringSize,"%d\t%S\t%d bytes");
// Number, name and date modified
_LIT(KStringDate,"%d\t%S\t%S");
// Date string format
_LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");
const TInt KDateStringLength = 30;
/*
-----------------------------------------------------------------------------
CVRexEngine* CVRexEngine::NewL()
Description: Two-phased constructor.
Comments :
Return values: CVRexEngine
-----------------------------------------------------------------------------
*/
CVRexEngine* CVRexEngine::NewL()
{
CVRexEngine* self =
CVRexEngine::NewLC();
CleanupStack::Pop(self);
return self;
}
/*
-----------------------------------------------------------------------------
CVRexEngine* CVRexEngine::NewLC()
Description: Two-phased constructor.
Comments : Leaves object in top of cleanup stack
Return values: CVRexEngine
-----------------------------------------------------------------------------
*/
CVRexEngine* CVRexEngine::NewLC()
{
CVRexEngine* self =
new (ELeave) CVRexEngine();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
/*
-----------------------------------------------------------------------------
void CVRexEngine::ConstructL(CVRexView* aView)
Description: Second phase constructor.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexEngine::ConstructL()
{
iVPlayer = CVideoPlayerAdapter::NewL();
//Creating iVRecorder fails in 6600.
//The leave is ignored here. When the recorder
//is tried to use and it's NULL a KErrNotSupported
//is thrown.
TRAPD(err,
iVRecorder = CVideoRecorderAdapter::NewL(this)
);
}
/*
-----------------------------------------------------------------------------
CVRexEngine::CVRexEngine()
Description: Constructor.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
CVRexEngine::CVRexEngine()
{
}
/*
-----------------------------------------------------------------------------
CVRexEngine::~CVRexEngine()
Description: Destructor.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
CVRexEngine::~CVRexEngine()
{
delete iVPlayer;
iVPlayer = NULL;
delete iVRecorder;
iVRecorder = NULL;
delete iDirList;
iDirList = NULL;
iFsSession.Close();
}
/*
-----------------------------------------------------------------------------
TInt CVRexEngine::StartFileList()
Description: This method reads the appropriate directory list.
Comments :
Return values: Error code
-----------------------------------------------------------------------------
*/
TInt CVRexEngine::StartFileList()
{
if (iDirList)
{
delete iDirList;
iDirList = 0;
}
TInt error = KErrNone;
// Root path in phone memory
TFileName rootPath = PathInfo::PhoneMemoryRootPath();
// Connect to file server
error = iFsSession.Connect();
if (error == KErrNone)
{
switch (iDirectory)
{
// Get dir. KEntryAttNormal means that no hidden files or
// directories are included
case EFileListVideos:
rootPath.Append(PathInfo::VideosPath());
error = iFsSession.GetDir(rootPath,KEntryAttNormal,
ESortByName,iDirList);
break;
// Sounds and Pictures paths are not used in this example
case EFileListSounds:
case EFileListPictures:
error = KErrNotSupported;
break;
default:
rootPath.Append(PathInfo::VideosPath());
error = iFsSession.GetDir(rootPath,KEntryAttNormal,
ESortByName,iDirList);
break;
}
}
return error;
}
/*
-----------------------------------------------------------------------------
void CVRexEngine::GetFileListItemsL(CDesCArray* aItems)
Description: This method constructs the listbox items with directory
information.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexEngine::GetFileListItemsL(CDesCArray* aItems)
{
if(!iDirList)
return;
for (TInt i=0;i<iDirList->Count();i++)
{
TFileName filename;
if(iSizeDate==EFileListSize)
{
// Show file size
filename.Format(KStringSize,i+1,&(*iDirList)[i].iName,
(*iDirList)[i].iSize);
}
else
{
// Fix the date and time string of last modification
TBuf<KDateStringLength> dateString;
(*iDirList)[i].iModified.FormatL(dateString,KDateString);
// Show date modified
filename.Format(KStringDate,i+1,&(*iDirList)[i].iName,&dateString);
}
aItems->AppendL(filename);
}
}
/*
-----------------------------------------------------------------------------
void CVRexEngine::SetDirectory(TInt aDirectory)
Description: This method sets which directory to list.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexEngine::SetDirectory(TInt aDirectory)
{
if (aDirectory!=EFileListDirNoChange)
iDirectory=aDirectory;
}
/*
-----------------------------------------------------------------------------
void CVRexEngine::SetSizeDate(TInt aSizeDate)
Description: This method sets whether modification date or file size
is shown. There is also an option for toggling the status.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexEngine::SetSizeDate(TInt aSizeDate)
{
if (aSizeDate==EFileListToggle)
{
if (iSizeDate==EFileListSize)
iSizeDate=EFileListDate;
else
iSizeDate=EFileListSize;
}
else
{
if (aSizeDate!=EFileListSizeDateNoChange)
iSizeDate=aSizeDate;
}
}
/*
-----------------------------------------------------------------------------
void CVRexEngine::EndFileList()
Description: This method ends the file server session.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexEngine::EndFileList()
{
// Close the file server session
iFsSession.Close();
}
/*
-----------------------------------------------------------------------------
void CVRexEngine::GetVideoFilePathAndNameAtPosition(TInt aPosition,
TDes &aName)
Description: This method gets the video file name at the listbox position.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexEngine::GetVideoFilePathAndNameAtPosition(TInt aPosition, TDes &aName)
{
if(!iDirList || aPosition < 0 || aPosition >= iDirList->Count())
return;
aName.Append(PathInfo::PhoneMemoryRootPath());
// Use appropriate directory path for launching file
// Only Videos path is supported by this example
if (iDirectory == EFileListVideos)
{
//Add Videos path
aName.Append(PathInfo::VideosPath());
// Add filename to be launched
aName.Append((*iDirList)[aPosition].iName);
}
iCurrentFileName = aName;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -