chxavplayerui.cpp
来自「symbian 下的helix player源代码」· C++ 代码 · 共 1,429 行 · 第 1/3 页
CPP
1,429 行
break;
default:
break;
}
CAknViewAppUi::HandleWsEventL(event, pDest);
}
////////////////////////////////////
// ensure play view is activated and attempt to play clip
//
void CHXAvPlayerUI::ActivatePlayViewL(const TDesC& url)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::ActivatePlayViewL(): current view exists = '%s' \n", dbg::Bool(iView)));
if( iView && (TUid::Uid(VID_PlayerView) == iView->Id()) )
{
// play view is active view
CHXAvPlayer* pPlayer = GetPlayer();
HX_ASSERT(pPlayer);
pPlayer->Play(url);
}
else
{
// we need to activate play view
CHXAvPlayView* pPlayView = GetPlayView();
// set clip to launch on view activation (view activates asynchronously)
pPlayView->SetViewActivateClipL(url);
//
// Activate player view if not in process of app
// startup (see OnViewForegroundActivateL()).
// Otherwise wait for default view (file view) to launch.
//
// iView becomes non-0 sometime after first foreground event
// for first activating view
//
m_bLaunchAppWithClipPending = (0 == iView);
if( !m_bLaunchAppWithClipPending )
{
ActivateLocalViewL(TUid::Uid(VID_PlayerView));
}
}
}
//
// Called when view receives first foreground event after activation
//
void CHXAvPlayerUI::OnViewForegroundActivateL(TInt idxView)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::OnViewForegroundActivateL(): current view id = %d\n", idxView));
//
// If this app instance was launched with a clip we get a call
// to OpenFileL() before the default view (i.e., file view in
// stand-alone launch case) is activated. If we activate the
// player view at that time, the default view will immediately
// activate after that (and yours truly has not found a good way
// to prevent this). So to work around this, we wait for the default
// view to activate before activating the play view.
//
if ( (VID_PlayerView != idxView) && m_bLaunchAppWithClipPending)
{
ActivateLocalViewL(TUid::Uid(VID_PlayerView));
}
m_bLaunchAppWithClipPending = false;
}
CHXAvPlayView* CHXAvPlayerUI::GetPlayView()
{
CHXAvPlayView* pPlayView = (CHXAvPlayView *)(View(TUid::Uid(VID_PlayerView)));
HX_ASSERT(pPlayView);
return pPlayView;
}
// player will be NULL if play view not activated
comptr<CHXAvPlayer> CHXAvPlayerUI::GetPlayer()
{
CHXAvPlayView* pPlayView = GetPlayView();
CHXAvPlayer* pPlayer = pPlayView->GetPlayer();
HX_ASSERT(pPlayer);
return pPlayer;
}
/*
* DoAboutL
* --------
* Do about screen.
*
*/
void
CHXAvPlayerUI::DoAboutL()
{
HBufC* pText = AllocAboutTextL();
AUTO_PUSH_POP_DEL(pText);
CHXAvMessageDialog::DoLongTextInfoPromptL(CHXAvCleanString(R_ABOUT_CAPTION)(), *pText, CHXAvMessageDialog::PromptBack);
}
/*
* DoOpenURLL
* ----------
* Show the open url dialog.
*
*/
void
CHXAvPlayerUI::DoOpenURLL()
{
CHXAvCleanString promptText(R_PROMPT_ENTER_URL);
//
// keep prompting until user: a) cancels; or b) enters a valid URL
//
for(;;)
{
HBufC* pDefaultText = 0;
if(m_lastClipEntered.IsEmpty())
{
// fill with default protocol prefix
pDefaultText = CHXAvUtil::KRTSPProtocolPrefix().AllocL();
}
else
{
// fill with last text entered by the user
pDefaultText = CHXAvStringUtils::AllocTextL(m_lastClipEntered);
}
AUTO_PUSH_POP_DEL(pDefaultText);
// Query the user for the url...
HBufC* pUrl = CHXAvMessageDialog::DoQueryTextL(promptText(), *pDefaultText, KMaxFileName);
if (pUrl != NULL)
{
AUTO_PUSH_POP_DEL(pUrl);
// remember what user entered (even if it turns out to be bad)
CHXAvStringUtils::DesToString(*pUrl, m_lastClipEntered);
ValidateUrlResult res = ValidateUrl(*pUrl);
if (CHXAvUtil::vuGood == res)
{
ActivatePlayViewL(*pUrl);
break;
}
else if(CHXAvUtil::vuMissingScheme == res)
{
//
// no scheme
//
// try with 'rtsp' or 'file' appended, depending on whether url looks
// like a local or remote url
//
HBufC* pAlt = 0;
TInt idxDrive = CHXAvFile::GetDriveIndex(*pUrl);
if(-1 != idxDrive)
{
// begins with a drive letter, looks like a file path...
pAlt = CHXAvFile::AllocFileUrlL(*pUrl);
}
else
{
// guess that this is a remote rtsp URL...
pAlt = CHXAvStringUtils::AllocTextL(KRTSPProtocolPrefix, *pUrl);
}
AUTO_PUSH_POP_DEL(pAlt);
if(CHXAvUtil::IsValidUrl(*pAlt))
{
ActivatePlayViewL(*pAlt);
break;
}
}
// assume typo; let user edit and try again...
CHXAvMessageDialog::DoAlertInfoL(CHXAvCleanString(R_ERR_INVALID_URL)());
}
else
{
// user cancelled
break;
}
}
}
/*
* DoOpenRecentL
* -------------
* Show the open recent url dialog. Launch the item that the user selected.
*
*/
void
CHXAvPlayerUI::DoOpenRecentL()
{
if (m_recentClips->NumURLs() > 0)
{
TInt idxSelectedItem = 0;
CHXAvRecentClipsPopupList* pPopup = new (ELeave) CHXAvRecentClipsPopupList(idxSelectedItem);
// save cleanupstack init until LD
{
AUTO_PUSH_POP(pPopup);
pPopup->ConstructL(m_recentClips.raw_ptr());
}
if (pPopup->ExecuteLD())
{
// Launch the item that the user selected
if ((idxSelectedItem >= 0) && (idxSelectedItem < m_recentClips->NumURLs()))
{
ActivatePlayViewL((m_recentClips->GetURL(idxSelectedItem))->URL());
}
}
}
else
{
CHXAvMessageDialog::DoAlertInfoL(CHXAvCleanString(R_RECENT_CLIPS_EMPTY)());
}
}
/*
* GetMediaStoreInfoL
* ------------------
* Return the list of media information..
*
*/
const CHXAvVector<CHXAvMediaFolderInfoPtr>&
CHXAvPlayerUI::GetMediaStoreInfoL(bool bForceUpdate)
{
if( 0 == m_mediaStoreInfo.Nelements() || bForceUpdate )
{
UpdateMediaStoreInfoL();
}
return m_mediaStoreInfo;
}
/*
* UpdateMediaStoreInfoL
* ---------------------
* Rebuild media store list
*
*/
void CHXAvPlayerUI::UpdateMediaStoreInfoL()
{
m_mediaStoreInfo.Resize(0);
CHXString strLocalMediaFolder = prefs::GetString(m_spEngineMgr->GetPrefs(),
CHXAV_LocalMediaFolder);
HXSYM_LEAVE_IF_TRUE(strLocalMediaFolder.IsEmpty());
AppendMediaStoreInfoL(strLocalMediaFolder, CHXAvMediaFolderInfo::PATH_ENSURE);
CHXString strMmcMediaFolder = prefs::GetString(m_spEngineMgr->GetPrefs(),
CHXAV_MmcMediaFolder);
if(!strMmcMediaFolder.IsEmpty())
{
//Do not try this on a 7650, It will crash the phone.
TInt nModelNumber = 0;
TInt nManufacture = 0;
HAL::Get(HAL::EModel, nModelNumber);
HAL::Get(HAL::EManufacturer, nManufacture);
if( nManufacture != HAL::EManufacturer_Nokia || nModelNumber != NOKIA_7650 )
{
AppendMediaStoreInfoL(strMmcMediaFolder, CHXAvMediaFolderInfo::PATH_OPTIONAL);
}
}
}
/*
* AppendMediaStoreInfoL
* ---------------------
* Here we create each media store, and call routines to find out what's in those locations.
*
*/
void
CHXAvPlayerUI::AppendMediaStoreInfoL(const CHXString& strRootPath, CHXAvMediaFolderInfo::PathCreateType pathType)
{
TFileName* pPath = CHXAvFile::AllocFileNameL(CHXAvCleanString(strRootPath)(), CHXAvFile::ntFolder);
AUTO_PUSH_POP_DEL(pPath);
CHXAvMediaFolderInfoPtr spInfo = new (ELeave) CHXAvMediaFolderInfo();
CHXAvUtil::Append(m_mediaStoreInfo, spInfo);
spInfo->InitL(*pPath, pathType);
}
////////////////////////////////////////
//
// Guide can be specified in config/preferences as:
//
// 1) local file name relative to local guide folder path
// e.g., 'index.html', 'german\index.wmlc'
//
// 3) http url
// e.g., 'http://www.real.com/mobile/home.html'
//
// In either case this returns a properly formed 'file'
// or 'http' url.
//
TPtrC CHXAvPlayerUI::GetGuideUrlL(bool bForceUpdate)
{
TPtrC out(KNullDesC);
if( bForceUpdate )
{
// ensure url is reset
m_spGuideUrl = 0;
}
if( !m_spGuideUrl )
{
DPRINTF(SYMP_INFO, ("GetGuideUrlL(): current locale is %d\n", User::Language()));
// look at 'guide'
CHXString strGuide = prefs::GetString(m_spEngineMgr->GetPrefs(), CHXAV_Guide);
if( !strGuide.IsEmpty() )
{
bool bLocalize = prefs::GetBool(m_spEngineMgr->GetPrefs(), CHXAV_GuideLocalize);
// see if guide is specified as an 'http' url
if(CHXAvUtil::IsHttpUrl(strGuide))
{
// assume config entry is valid http url...
if( bLocalize )
{
// append '?locale=NN' to url to tell server to retrieve localized guide page
_LIT(KQuestionMark, "?");
_LIT(KGuideLocaleQuery, "locale=%d");
const TLanguage locale = User::Language();
CHXAvCleanString urlText(strGuide);
CHXAvCleanString urlQuery(KGuideLocaleQuery, locale);
m_spGuideUrl = CHXAvStringUtils::AllocTextL(urlText(), KQuestionMark, urlQuery());
}
else
{
m_spGuideUrl = CHXAvStringUtils::AllocTextL(strGuide);
}
}
else
{
// looks like we are dealing with a local guide
TFileName* pFullPathGuide = CHXAvFile::AllocFullPrefPathL(m_spEngineMgr->GetPrefs(), CHXAV_Guide);
HXSYM_LEAVE_IF_FALSE(pFullPathGuide != 0);
AUTO_PUSH_POP_DEL(pFullPathGuide);
if(bLocalize)
{
// find localized version, based on TLanguage enum in extension (e.g., for '*.rsc', '*.r01' == English, '*.r10' == American, etc.)
DPRINTF(SYMP_INFO, ("GetGuideUrlL(): default guide is '%s'\n", dbg::CharPtr(*pFullPathGuide)()));
// appears to require drive in path (despite docs); path is not modified if path is invalid
BaflUtils::NearestLanguageFile(iCoeEnv->FsSession(), *pFullPathGuide);
DPRINTF(SYMP_INFO, ("GetGuideUrlL(): localized guide is '%s'\n", dbg::CharPtr(*pFullPathGuide)()));
}
// ensure path exists
bool bExists = CHXAvFile::PathExists(*pFullPathGuide);
HX_ASSERT(bExists);
if(bExists)
{
// save path fixed up so it is a 'file:///' url
m_spGuideUrl = CHXAvFile::AllocFileUrlL(*pFullPathGuide);
}
}
}
}
if( m_spGuideUrl )
{
out.Set(*m_spGuideUrl);
}
DPRINTF(SYMP_INFO, ("GetGuideUrlL(): url is '%s'\n", dbg::CharPtr(out)()));
return out;
}
#if(0)
////////////////////////////////////////////////
// shared data client notifier
void CHXAvPlayerUI::HandleNotifyL(const TUid uid, const TDesC& key, const TDesC& val)
{
DPRINTF(SYMP_INFO, ("avPlayerUI::HandleNotifyL(): uid = 0x%08x, key = '%s', val = '%s'\n", uid.iUid, dbg::CharPtr(key)(), dbg::CharPtr(val)()));
// note: we should not get notifications in cases where we are the source of the change
if(KSDUidSysAp == uid)
{
if (0 == key.CompareF(KSysApLightsControl))
{
if( !IsEqual(val, BacklightAlwaysOn) )
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::HandleNotifyL(): backlight reset\n"));
// some events (e.g., incoming sms) reset backlight behavior; ensure this is set correctly
SetActivePlaybackState(m_bIsActivePlaybackState);
}
}
else if(0 == key.CompareF(KSysApAlarmLightActive))
{
// also see RAlarmServer
if( IsEqual(val, AlarmFlashing) )
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::HandleNotifyL(): alarm firing\n"));
// handle this same way as if we loose app focus
CHXAvViewBase *pActiveView = static_cast<CHXAvViewBase *>(iView);
pActiveView->HandleLosePlayFocus();
}
}
else if(0 == key.CompareF(KSysApMessageToneQuit))
{
if( IsEqual(val, MessageTonesOff) )
{
// we get this when a message comes in in silent mode
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::HandleNotifyL(): msg tone off\n"));
// in silent mode this resets volume; now we (possibly) reset volume back
m_player->SetVolume(m_player->GetVolume());
}
}
}
}
#endif
/*
* GetRecentClipCount
* ------------------
* Returns the count of urls.
*
*/
TInt
CHXAvPlayerUI::GetRecentClipCount() const
{
TInt count = 0;
if (m_recentClips)
{
count = m_recentClips->NumURLs();
}
return count;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?