⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 videoappui.cpp

📁 symbian video 的 实现
💻 CPP
📖 第 1 页 / 共 2 页
字号:

-----------------------------------------------------------------------------
*/
void CVideoAppUi::PlayVideoFileL(TDesC &aFileName)
	{
	// Set the file name first
	iEngine->SetNewFileL( aFileName );

	// Set time navi pane to "Loading...."
	_LIT( KLoading, "Loading..." );
	SetNaviLabelL( KLoading );
	
	// Init the controller
	DoInitControllerL();
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::DoStopL()

	Description: Stop a playing video file
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::DoStopL()
	{
	SetNaviLabelL( KNullDesC );

	iEngine->DoStop();

	iCba = CEikButtonGroupContainer::Current();
	if( iCba) 
		{
		iCba->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_EXIT );
		iCba->DrawNow();
		}

	// Refresh the List window.
	iAppContainer->DrawNow();
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::InitControllerCompletedL(TInt aError )

	Description: It is called when the controller is initialized
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::InitControllerCompletedL(TInt /*aError*/ )
    {
   	// play it
	iEngine->DoPlayL();
    }

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::PlayCompletedL(TInt aError )

	Description: called after a video has been completed
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::PlayCompletedL(TInt /*aError*/)
    {
	
	// The play has been completed, we need to refresh the display now.
	iAppContainer->DrawNow();
	SetNaviLabelL( KNullDesC );

	iCba = CEikButtonGroupContainer::Current();
	if( iCba) 
		{
		iCba->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_EXIT );
		iCba->DrawNow();
		}
    }

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::DoInitControllerL()

	Description: Initialize the video engine
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::DoInitControllerL()
	{
    if ( iAppContainer )
        {
        TRect tmp  = iAppContainer->VideoRect();
        iEngine->InitControllerL( this, iAppContainer->ClientWsSession(), 
			                      iAppContainer->ScreenDevice(),
                                  iAppContainer->ClientWindow(), tmp, tmp );
        }
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::DoPauseL()

	Description: Pause a playing video clip
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::DoPauseL()
	{
	iEngine->DoPauseL();

	// Change the CBA to "continue" and "stop"
	iCba = CEikButtonGroupContainer::Current();
	if( iCba) 
		{
		iCba->SetCommandSetL( R_VIDEO_CONTINUE_RETURN );
		iCba->DrawNow();
		}	
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::DoDocPlayL()

	Description: Launch a video player using a document handler
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::DoDocPlayL()
	{
    TDataType data = TDataType( KNullUid );

	// Set the file name first
	TFileName fileName;
	iAppContainer->GetCurrentVideoFileNameL( fileName );
	iEngine->DocumentHandlerL().OpenFileEmbeddedL( fileName, data );
	}

/*
-----------------------------------------------------------------------------

	CAknNavigationDecorator* CVideoAppUi::CreateTimeNaviL()

	Description: Create a Navi pane to show the time progress.
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
CAknNavigationDecorator* CVideoAppUi::CreateTimeNaviL()
	{
    CVideoNaviDecoratorTime* timeNavi = CVideoNaviDecoratorTime::NewL();
    CleanupStack::PushL(timeNavi);

    CAknNavigationDecorator* decoratedFolder =
        CAknNavigationDecorator::NewL( iNaviPane, timeNavi, 
                                 CAknNavigationDecorator::ENotSpecified );
    CleanupStack::Pop(); // timeNavi, decoratedFolder owns it now.
    
    CleanupStack::PushL( decoratedFolder );
    decoratedFolder->SetContainerWindowL( *iNaviPane );
    timeNavi->SetContainerWindowL( *decoratedFolder);
    CleanupStack::Pop(); // decoratedFolder
        
    decoratedFolder->MakeScrollButtonVisible( EFalse );

    return decoratedFolder;
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::SetNaviLabelL(TDesC &aLabel)

	Description: Set the text for the time Navi pane
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::SetNaviLabelL(const TDesC &aLabel)
	{
    CVideoNaviDecoratorTime* timeNavi = 
        static_cast<CVideoNaviDecoratorTime*>(iTimeNavi->DecoratedControl());

	timeNavi->SetLabelL( aLabel);
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::DoGetFileInfoL()

	Description: Get the video file information
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::DoGetFileInfoL()
	{
    CVideoFileDetailsDialog* dlg = CVideoFileDetailsDialog::NewL();

	TFileName fileName;
	iAppContainer->GetCurrentVideoFileNameL( fileName );
	dlg->ExecuteLD( fileName);
	}

/*
-----------------------------------------------------------------------------

	CVideoEngine* CVideoAppUi::GetVideoEngine()

	Description: Get the video engine
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
CVideoEngine* CVideoAppUi::GetVideoEngine()
	{
	return iEngine;
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::PlaybackPositionChangedL(TInt64 aPlaybackPosInSeconds, 
					  TInt64 aTotalLengthInSeconds)

	Description: Set the play back time poistion (play progress)
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::PlaybackPositionChangedL(TInt64 aPlaybackPosInSeconds, TInt64 aTotalLengthInSeconds)
    {
    
    TTime posTime = TTime( aPlaybackPosInSeconds*KMPOneSecond );
    TTime durTime = TTime( aTotalLengthInSeconds*KMPOneSecond );

    TBuf<16> pos;
    TBuf<16> dur;

    if (aTotalLengthInSeconds > 0 && aTotalLengthInSeconds < KOneHourInSeconds)
       {
       // Format time to user readable format. (min:sec) 
       posTime.FormatL(pos, *iMinSecFormatString);
       durTime.FormatL(dur, *iMinSecFormatString);     
       }
    else
       {
       // Format time to user readable format. (hour:min:sec)
       posTime.FormatL(pos, *iHourMinSecFormatString);
       aTotalLengthInSeconds = 0;
       }
                
    // if duration greated than 0, show postion in 00:00/00:00 format
    if (aTotalLengthInSeconds > 0)
        {
        CDesCArrayFlat* strings = new CDesCArrayFlat(2);
        CleanupStack::PushL(strings);
        strings->AppendL(pos); //First string (position)
        strings->AppendL(dur); //Second string (duration)
        HBufC* stringholder = StringLoader::LoadLC(R_VIDEO_NAVI_TIME,*strings,iEikonEnv);
        static_cast<CVideoNaviDecoratorTime*> (iTimeNavi->DecoratedControl())->SetLabelL(*stringholder);
        CleanupStack::PopAndDestroy(2); // strings & stringholder
        }    
    else // show position in 00:00:00 format
        {
        static_cast<CVideoNaviDecoratorTime*>(iTimeNavi->DecoratedControl())->SetLabelL(pos);
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -