chxavplayview.cpp
来自「symbian 下的helix player源代码」· C++ 代码 · 共 1,708 行 · 第 1/3 页
CPP
1,708 行
* Seek in larger steps as a seek key is held down, up to an absolute max step.
*
*/
UINT32
CHXAvPlayView::GetNextSeekStep(UINT32 msSeekStep)
{
const UINT32 ONE_SECOND_MS = 1000;
const UINT32 BIG_SEEK_DIV_MS = 20; // 5 % per step
if (m_player != NULL)
{
UINT32 duration = m_player->GetClipDuration();
UINT32 msMaxStep = duration / BIG_SEEK_DIV_MS;
if( msSeekStep != 0 )
{
// double current step
msSeekStep *= 2;
}
else
{
// init first step
msSeekStep = ONE_SECOND_MS;
}
// confine value to our limits
msSeekStep = max(ONE_SECOND_MS, min(msSeekStep, msMaxStep));
}
DPRINTF(SYMP_INFO, ("CHXAvPlayView::GetNextSeekStep(): next step = %lu ms", msSeekStep));
return msSeekStep;
}
// helper
void CHXAvPlayView::HandleShowPopupL()
{
// pop up left options menu
//
// showing a popup menu prevents us from getting the key up event; just in case,
// ensure we deactivate the playlist control
//
if( m_player->IsPlaying() )
{
// pause or stop
DoTogglePlayState();
}
if(m_player->IsPaused())
{
ShowPopupMenuL(R_AVP_PAUSE_MENU_BAR);
}
else if (m_player->IsStopped())
{
ShowPopupMenuL(R_AVP_STOPPED_MENU_BAR);
}
else if(m_player->GetClipInfo().IsLive())
{
ShowPopupMenuL(R_AVP_LIVE_PLAY_MENU_BAR);
}
}
/*
* HandleCommandL
* --------------
* Handle commands passed to us by our control and directly.
*
*/
void CHXAvPlayView::HandleCommandL(TInt command)
{
bool bWasHandled = TryHandlePlaylistCommandL(command);
if( !bWasHandled )
{
switch(command)
{
case EPlayPause:
HX_ASSERT(m_player->CanPause() || m_player->CanResume());
DoTogglePlayState();
break;
case EStop:
m_player->Stop();
break;
case EBeginSeek:
HX_ASSERT(m_player->CanSeek());
EnterSeekMode(true);
break;
case EEndSeek:
EnterSeekMode(false);
break;
case ESeekForward:
HandleSeekKeyCommand(true);
break;
case ESeekBack:
HandleSeekKeyCommand(false);
break;
case EVolUp:
case EVolDown:
HandleVolumeCommand(command);
break;
case EMute:
m_player->Mute(!m_player->IsMuted());
break;
case ESaveToFolder:
DoSaveL();
break;
case EClipInfoDialog:
DoViewClipInfoL();
break;
case EShowDefaultMenu:
HandleShowPopupL();
break;
/*case EToggleFullScreen:
m_wpStatusPane->MakeVisible(!m_wpStatusPane->IsVisible());
break;*/
default:
CHXAvViewBase::HandleCommandL(command);
break;
}
}
}
/*
* UpdateViewStateL
* ----------------
* ensure that view is in sync with player state
*
*/
void CHXAvPlayView::UpdateViewStateL()
{
UpdateSoftkeyMenuStateL();
UpdateTitleL();
UpdateContextPaneL();
UpdateNaviVolumeControlL();
UpdateNaviPlaylistControlL();
UpdateNaviDefaultControlL();
}
////////////////////////////////////////////////////////////
// set file to launch on next view activation
void CHXAvPlayView::SetViewActivateClipL(const TDesC& file)
{
m_spViewActivateClip = file.AllocL();
}
/*
* CreateViewWindowForActivatingViewL
* -------------------
* Construct view window needed for active view
*
*/
CCoeControl* CHXAvPlayView::CreateViewWindowForActivatingViewL()
{
DPRINTF(SYMP_INFO, ("CHXAvPlayView::CreateViewWindowForActivatingViewL()\n"));
if(!m_spWindow)
{
m_spWindow = new (ELeave) CHXAvPlayViewWindow();
m_spWindow->ConstructL(m_playerUI, this, ClientRect());
}
return m_spWindow.raw_ptr();
}
/*
* FinishViewActivateL
* -------------------
* View window is active and on top of control stack. Now
* is a good time to allocate additional resources needed
* for the active view.
*
*/
void CHXAvPlayView::FinishViewActivateL()
{
DPRINTF(SYMP_INFO, ("CHXAvPlayView::FinishViewActivateL()\n"));
HX_ASSERT(m_spWindow);
CHXAvPresentationWindow* pRenderWin = m_spWindow->GetPresentationWindow();
// shut down player by default when view deactivates
m_bShutDownOnViewDeactivate = true;
if( m_player->IsShutDown() )
{
m_player->InitPlayerL(pRenderWin);
}
m_player->GetPlayerState().AddObserver(m_spNetConnectUi.raw_ptr());
m_player->GetPlayerState().AddObserver(this);
}
/*
* FinishViewDeactivateL
* ---------------------
* Destroy resources not needed when view is inactive
*
*/
void CHXAvPlayView::FinishViewDeactivateL()
{
DPRINTF(SYMP_INFO, ("CHXAvPlayView::FinishViewDeactivateL()\n"));
// this ensures that next view gets a restored status pane
m_spNaviVolDecorator = 0;
m_spNaviDefaultDecorator = 0;
m_spNaviPlaylistDecorator = 0;
// ensure we don't get observation messages (and try to do ui stuff in response) when inactive
m_player->GetPlayerState().RemoveObserver(this);
m_player->GetPlayerState().RemoveObserver(m_spNetConnectUi.raw_ptr());
if( m_bShutDownOnViewDeactivate )
{
// shutting down player saves some resources and ensures no cpu is used for static rendering
m_player->ShutDown();
// only destroy window if player is shutdown (otherwise player site still needs presentation window)
m_spWindow = 0;
}
m_bViewPlaylistMode = false;
m_bEnsureResumeOnExitPlaylistMode = false;
// in case we were full screen
// m_wpStatusPane->MakeVisible(ETrue);
}
/*
* OnPlayInitiate
* --------------
* CHXAvPlayerStateObserver
*
*/
void
CHXAvPlayView::OnPlayInitiate(const char *url)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayView::OnPlayInitiate(): '%s'\n", (const char*)url));
UpdateContextPaneL();
UpdateSoftkeyMenuStateL();
UpdateTitleL();
}
/*
* OnMute
* ------
* CHXAvPlayerStateObserver, mute.
*
*/
void
CHXAvPlayView::OnMute(bool bMute)
{
if(bMute)
{
//
// mute state is indicated on the default navi control - hide temp
// navi control so user can see it (vol control does not show mute)
//
HideTempNaviControlNowL();
}
}
void
CHXAvPlayView::OnBacklightTimer()
{
User::ResetInactivityTime();
}
/*
* OnResume
* --------
* CHXAvPlayerStateObserver, started playing again.
*
*/
void
CHXAvPlayView::OnResume()
{
UpdateContextPaneL();
UpdateSoftkeyMenuStateL();
InitBacklightState();
}
/*
* OnStop
* ------
* CHXAvPlayerStateObserver, stopped.
*
*/
void
CHXAvPlayView::OnStop()
{
UpdateContextPaneL();
UpdateSoftkeyMenuStateL();
m_cbBacklight.Stop();
}
/*
* OnPause
* -------
* CHXAvPlayerStateObserver, paused.
*
*/
void
CHXAvPlayView::OnPause()
{
UpdateContextPaneL();
UpdateSoftkeyMenuStateL();
m_cbBacklight.Stop();
}
void
CHXAvPlayView::OnAdvancePlaylist()
{
UpdateTitleL();
UpdateSoftkeyMenuStateL();
}
/*
* OnBeginBuffering
* ----------------
*
*/
void
CHXAvPlayView::OnBeginBuffering(bool /*bIsBegin*/)
{
// update everything when entering/exiting buffering state
UpdateContextPaneL();
UpdateSoftkeyMenuStateL();
}
/*
* OnBeginSeek
* -----------
* CHXAvPlayerStateObserver
*
*/
void
CHXAvPlayView::OnBeginSeek()
{
UpdateSoftkeyMenuStateL();
// this event only happens from user interaction; override volume control
HideTempNaviControlNowL();
}
/*
* OnLoadSession
* -------------
* Change the softkeys to show a stop button now that we are actually playing back.
*
*/
void
CHXAvPlayView::OnLoadSession(IHXRequest *request)
{
CHXAvURLListPtr spRecentClips = m_playerUI->GetRecentClipsList();
// Add this url to the recent clip list...
HX_ASSERT(spRecentClips);
if (spRecentClips)
{
HBufC* pTitleText = CHXAvMisc::AllocTitleL(m_player);
if( pTitleText )
{
AUTO_PUSH_POP_DEL(pTitleText);
CHXString strUrl = m_player->GetPlayURL();
CHXString strTitle = CHXAvStringUtils::DescToString(*pTitleText);
CHXAvURLInfo* pInfo = new (ELeave) CHXAvURLInfo(strUrl, strTitle); //XXXLCM leave
spRecentClips->AddHead(pInfo);
}
}
UpdateContextPaneL();
UpdateSoftkeyMenuStateL();
UpdateTitleL();
// this is the first time we can know this is a video presentation
InitBacklightState();
}
void CHXAvPlayView::InitBacklightState()
{
if(m_player->GetClipInfo().IsVideoPresentation())
{
// set repeating callback for keeping backlight on
m_cbBacklight.Set(k_msBacklightInterval, CHXAvCallback::REPEAT);
}
}
/*
* OnVolume
* --------
* CHXAvPlayerStateObserver, volume changing.
*
*/
void
CHXAvPlayView::OnVolume(unsigned int /*percentVol*/)
{
//if( bIsUserCommand )
//{
if(!m_bViewPlaylistMode )
{
ActivateNaviVolumeControlL(k_msShowTempNavi);
UpdateNaviVolumeControlL();
m_naviPane->PushL(*m_spNaviVolDecorator);
}
}
void
CHXAvPlayView::OnNetConnect()
{
UpdateSoftkeyMenuStateL();
}
/*
* UpdateSoftkeyMenuStateL
* ----------------------
* Update the softeky and menu bar based on the player state.
*
*/
void
CHXAvPlayView::UpdateSoftkeyMenuStateL()
{
CEikMenuBar* pMenuBar = MenuBar();
HX_ASSERT(pMenuBar);
if(!pMenuBar)
{
return;
}
const CHXAvPlayerState& state = m_player->GetPlayerState();
CHXAvPlayerState::State playState = state.GetState();
TInt idMenuBar = -1;
TInt idCba = -1;
if( m_bViewPlaylistMode )
{
idCba = R_AVP_PLAYER_VIEW_PLAYLIST_MODE_CBA;
idMenuBar = R_AVP_EMPTY_MENU_BAR;
}
else
{
switch (playState)
{
case CHXAvPlayerState::Stopped:
idCba = R_AVP_PLAYER_VIEW_IDLE_CBA;
idMenuBar = R_AVP_STOPPED_MENU_BAR;
break;
case CHXAvPlayerState::Paused:
idCba = R_AVP_PLAYER_VIEW_PAUSE_CBA;
idMenuBar = R_AVP_PAUSE_MENU_BAR;
break;
case CHXAvPlayerState::Initiating:
idCba = R_AVP_PLAYER_VIEW_CONNECTING_CBA;
idMenuBar = R_AVP_EMPTY_MENU_BAR;
break;
case CHXAvPlayerState::Seeking:
idCba = R_AVKON_SOFTKEYS_EMPTY;
idMenuBar = R_AVP_EMPTY_MENU_BAR;
break;
case CHXAvPlayerState::Connecting:
idCba = R_AVP_PLAYER_VIEW_CONNECTING_CBA;
idMenuBar = R_AVP_EMPTY_MENU_BAR;
break;
case CHXAvPlayerState::Playing:
if (m_player->GetClipInfo().IsLive())
{
idCba = R_AVP_PLAYER_VIEW_LIVE_PLAY_CBA;
idMenuBar = R_AVP_LIVE_PLAY_MENU_BAR;
}
else
{
idCba = R_AVP_PLAYER_VIEW_PLAY_CBA;
idMenuBar = R_AVP_EMPTY_MENU_BAR;
}
break;
default:
break;
}
}
if (idMenuBar != -1 && idCba != -1)
{
Cba()->SetCommandSetL(idCba);
pMenuBar->SetMenuTitleResourceId(idMenuBar);
if (!m_playerUI->IsDisplayingMenuOrDialog())
{
Cba()->DrawNow();
}
}
}
//////////////////////////////
// update volume control (if active) to match current player volume state
//
void CHXAvPlayView::UpdateNaviVolumeControlL()
{
if( m_spNaviVolDecorator)
{
CAknVolumeControl* volControl = static_cast<CAknVolumeControl*>(
m_spNaviVolDecorator->DecoratedControl());
TUint vol = m_player->GetVolume();
HX_ASSERT( vol >= 0 && vol <= 100);
// scale volume to vol (0 - 100) to control setting scale (1 - 10)
TUint scaleVol = ( 10 * (vol + 9) ) / 100;
if( scaleVol == 0 )
{
scaleVol = 1;
}
HX_ASSERT(scaleVol >=1 && scaleVol <= 10);
volControl->SetValue(scaleVol);
}
}
////////////////////////////////////
//
void CHXAvPlayView::UpdateNaviPlaylistControlL()
{
// nothing
}
////////////////////////////////////
//
void CHXAvPlayView::DeactivateNaviVolumeControl()
{
if(m_spNaviVolDecorator)
{
if( m_cbTempNaviDisplay.IsPending() )
{
m_cbTempNaviDisplay.Stop();
}
m_naviPane->Pop(m_spNaviVolDecorator.Ptr());
m_spNaviVolDecorator = 0;
}
}
////////////////////////////////////
//
void CHXAvPlayView::DeactivateNaviPlaylistControl()
{
m_bViewPlaylistMode = false;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?