×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    136

    Unable to Play video

    Hi,
    I am trying to play video file in Symbian^3 device ( Nokia N8). I followed this example


    header file
    Code:
    // --------------------------------------------------------------------------
    // SimpleVideoPlayer.h
    // 
    // Copyright 2007, Symbian Press
    // --------------------------------------------------------------------------
    
    #ifndef SIMPLEVIDEOPLAYER_H
    #define SIMPLEVIDEOPLAYER_H
    
    // INCLUDE FILES
    #include <e32std.h>
    #include <e32base.h>
    #include <VideoPlayer.h>
    
    // FORWARD DECLARATION
    class CCoeControl;
    
    // CLASS DECLARATION
    
    class CSimpleVideoPlayer : public CBase, public MVideoPlayerUtilityObserver
    	{
    public: // Constructors and destructor
    	~CSimpleVideoPlayer();
    	static CSimpleVideoPlayer* NewL(const CCoeControl& aControl);
    	static CSimpleVideoPlayer* NewLC(const CCoeControl& aControl);
    
    public: // Public methods
    	void PlayL(const TDesC& aFileName);
    	void Stop();
    	
    	void SetDisplayWindowL(const CCoeControl& aControl);
    
    private: // Constructors
    	CSimpleVideoPlayer();
    	void ConstructL(const CCoeControl& aControl);
    
    private: // From MVideoPlayerUtilityObserver
    	void MvpuoOpenComplete(TInt aError);
    	void MvpuoPrepareComplete(TInt aError);
    	void MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError);
    	void MvpuoPlayComplete(TInt aError);
    	void MvpuoEvent(const TMMFEvent& aEvent);
    
    private: // Private methods
    	void DisplayErrorMessage(TInt aError);
    	
    private: // Member variables
    	CVideoPlayerUtility* iPlayerUtility;
    	};
    
    #endif // SIMPLEVIDEOPLAYER_H
    
    // End of File

    .cpp file
    Code:
    // --------------------------------------------------------------------------
    // SimpleVideoPlayer.cpp
    // 
    // Copyright 2007, Symbian Press
    // --------------------------------------------------------------------------
    
    // INCLUDE FILES
    #include <coecntrl.h>
    #include <eikenv.h>
    #include <VideoPlayer.h>
    #include "SimpleVideoPlayer.h"
    
    // CONSTANTS
    const TInt KVolumeDenominator = 2;
    
    // METHODS DEFINITION
    
    CSimpleVideoPlayer::CSimpleVideoPlayer()
    	{
    	}
    
    CSimpleVideoPlayer::~CSimpleVideoPlayer()
    	{
    	delete iPlayerUtility;
    	}
    
    CSimpleVideoPlayer* CSimpleVideoPlayer::NewLC(const CCoeControl& aControl)
    	{
    	CSimpleVideoPlayer* self = new (ELeave)CSimpleVideoPlayer();
    	CleanupStack::PushL(self);
    	self->ConstructL(aControl);
    	return self;
    	}
    
    CSimpleVideoPlayer* CSimpleVideoPlayer::NewL(const CCoeControl& aControl)
    	{
    	CSimpleVideoPlayer* self=CSimpleVideoPlayer::NewLC(aControl);
    	CleanupStack::Pop(self);
    	return self;
    	}
    
    void CSimpleVideoPlayer::ConstructL(const CCoeControl& aControl)
    	{
    	TRect rect(
    			aControl.PositionRelativeToScreen(),
    			TSize(aControl.Rect().Width(), aControl.Rect().Height()));
    	iPlayerUtility = CVideoPlayerUtility::NewL(
    			*this,
    			EMdaPriorityNormal,
    			EMdaPriorityPreferenceNone,
    			aControl.ControlEnv()->WsSession(),
    			*aControl.ControlEnv()->ScreenDevice(),
    			*aControl.DrawableWindow(),
    			rect,
    			rect
    			);
    	}
    
    void CSimpleVideoPlayer::PlayL(const TDesC& aFileName)
    	{
    	iPlayerUtility->Close();
    	iPlayerUtility->OpenFileL(aFileName);
    	}
    
    void CSimpleVideoPlayer::Stop()
    	{
    	iPlayerUtility->Stop();
    	}
    
    void CSimpleVideoPlayer::SetDisplayWindowL(const CCoeControl& aControl)
    	{
    	TRect rect(
    			aControl.PositionRelativeToScreen(),
    			TSize(aControl.Rect().Width(), aControl.Rect().Height()));
    	iPlayerUtility->SetDisplayWindowL(aControl.ControlEnv()->WsSession(),
    			*aControl.ControlEnv()->ScreenDevice(),
    			*aControl.DrawableWindow(),
    			rect,
    			rect);
    	}
    
    void CSimpleVideoPlayer::MvpuoOpenComplete(TInt aError)
    	{
    	if (KErrNone == aError)
    		{
    		iPlayerUtility->Prepare();
    		}
    	else
    		{
    		// Do something when error happens.
    		TRAP_IGNORE(DisplayErrorMessage(aError));
    		}
    	}
    
    void CSimpleVideoPlayer::MvpuoPrepareComplete(TInt aError)
    	{
    	if (KErrNone == aError)
    		{
    		TRAP_IGNORE(iPlayerUtility->SetVolumeL(iPlayerUtility->MaxVolume()
    				/ KVolumeDenominator));
    		iPlayerUtility->Play();
    		}
    	else
    		{
    		iPlayerUtility->Close();
    		
    		// Do something when error happens.
    		TRAP_IGNORE(DisplayErrorMessage(aError));
    		}
    	}
    
    void CSimpleVideoPlayer::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,
    		TInt /*aError*/)
    	{	
    	}
    
    void CSimpleVideoPlayer::MvpuoPlayComplete(TInt aError)
    	{
    	if (KErrNone == aError)
    		{
    		}
    	else
    		{
    		TRAP_IGNORE(DisplayErrorMessage(aError));
    		}
    	}
    
    void CSimpleVideoPlayer::MvpuoEvent(const TMMFEvent& /*aEvent*/)
    	{
    	}
    
    void CSimpleVideoPlayer::DisplayErrorMessage(TInt aError)
    	{
    	const TInt KMaxBuffer = 15;
    	_LIT(KErrorMessage, "Error: %d");
    	TBuf<KMaxBuffer> buffer;
    	buffer.AppendFormat(KErrorMessage, aError);
    	TRAP_IGNORE(CEikonEnv::Static()->InfoWinL(KNullDesC, buffer));
    	}
    
    // End of File
    This class works perfect in 5th edition device, but when I install the same sis file in my N8 its not working, I can only hear the sound not the video, the video screen is a white blank screen.


    Do i need to make any changes in the class or is there any other specific class for S^3 device

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: Unable to Play video

    White screen probably comes from a gc.Clear in your Draw method.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    136

    Re: Unable to Play video

    Quote Originally Posted by wizard_hu_ View Post
    White screen probably comes from a gc.Clear in your Draw method.

    Sorry, but its not working. I have commented the gc.clear function , but still the white screen. I can hear the sound. But its working in 5th edition device, do you know why?

  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    136

    Re: Unable to Play video

    here is the other classes
    view class
    Code:
    // --------------------------------------------------------------------------
    // VideoPlayingMainView.cpp
    // 
    // Copyright 2007, Symbian Press
    // --------------------------------------------------------------------------
    
    #include <eikedwin.h>
    #include <eikenv.h>
    #include <aknutils.h>
    #include <VideoPlaying2.rsg>
    
    #include "VideoPlayingMainView.h"
    
    // --------------------------------------------------------------------------
    // Two-phase constructor
    // --------------------------------------------------------------------------
    CVideoPlayingMainView* CVideoPlayingMainView::NewL(const TRect& aRect)
    	{
    	CVideoPlayingMainView* self = CVideoPlayingMainView::NewLC(aRect);
    	CleanupStack::Pop(self);
    	return self;
    	}
    
    // --------------------------------------------------------------------------
    // Two-phase constructor
    // --------------------------------------------------------------------------
    CVideoPlayingMainView* CVideoPlayingMainView::NewLC(const TRect& aRect)
    	{
    	CVideoPlayingMainView* self = new (ELeave) CVideoPlayingMainView;
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    	}
    
    // --------------------------------------------------------------------------
    // Destructor
    // --------------------------------------------------------------------------
    CVideoPlayingMainView::~CVideoPlayingMainView()
    	{
    	delete iEikEdwin;
    	}
    	
    // --------------------------------------------------------------------------
    // Second phase constructor
    // --------------------------------------------------------------------------
    void CVideoPlayingMainView::ConstructL(const TRect& aRect)
    	{
    	CreateWindowL();
    	
    	// Create an edwin on this control.
    	/*iEikEdwin = new (ELeave) CEikEdwin();
    	iEikEdwin->ConstructL(CEikEdwin::EReadOnly | CEikEdwin::ENoAutoSelection);
        iEikEdwin->SetContainerWindowL(*this);
    	HBufC* message = ControlEnv()->AllocReadResourceLC(
    		R_VIDEOPLAYING_TEXT);	
        iEikEdwin->SetTextL(message);
    	CleanupStack::PopAndDestroy(message);
    	*/
    	SetRect(aRect);
    	ActivateL();
    	}
    
    // --------------------------------------------------------------------------
    // Sets the text to be displayed on this control.
    // --------------------------------------------------------------------------
    void CVideoPlayingMainView::SetTextL(const TDesC& aText)
    	{
    	/*if (iEikEdwin)
    		{
    		iEikEdwin->SetTextL(&aText);
    		DrawDeferred();
    		}
    		*/
    	}
    
    // --------------------------------------------------------------------------
    // Returns the number of controls.
    // In this example, it returns 1 because there is only one
    // control, which is an edwin control.
    // --------------------------------------------------------------------------
    TInt CVideoPlayingMainView::CountComponentControls() const
    	{
    	/*if (iEikEdwin)
    		{
    		return 1;
    		}
    		*/
    	return 0;
    	}
    
    // --------------------------------------------------------------------------
    // Returns the pointer of the controls.
    // In this example, it returns the pointer of the edwin control.
    // --------------------------------------------------------------------------
    CCoeControl* CVideoPlayingMainView::ComponentControl(TInt aIndex) const
    	{
    	/*switch (aIndex)
    		{
    		case 0:
    			return iEikEdwin;
    		default:
    			break;
    		}
    		*/
    	return 0;
    	}
    
    // --------------------------------------------------------------------------
    // Called when this control needs to be redrawn.
    // --------------------------------------------------------------------------
    void CVideoPlayingMainView::Draw(const TRect& /*aRect*/) const
    	{
    	CWindowGc& gc = SystemGc();
    	gc.Clear();
    	}
    
    // --------------------------------------------------------------------------
    // Called when the size/resolution of this control has been
    // changed. If this happens, the size of the edwin has to be
    // adjusted as well.
    // --------------------------------------------------------------------------
    void CVideoPlayingMainView::SizeChanged()
        {
       /* if (iEikEdwin)
    		{
    		TRect rect(Rect());
    		iEikEdwin->SetExtent(
    			TPoint(0, 0),
    			TSize(rect.Width(), rect.Height()));
    		}
    		*/
        }
    	
    // End of File
    Appui.cpp
    Code:
    // --------------------------------------------------------------------------
    // VideoPlayingAppUi.cpp
    // 
    // Copyright 2007, Symbian Press
    // --------------------------------------------------------------------------
    
    // INCLUDES
    #include <eikapp.h>
    #include <VideoPlaying2.rsg>
    
    #include "VideoPlayingAppUi.h"
    #include "VideoPlayingMainView.h"
    #include "SimpleVideoPlayer.h"
    #include "VideoPlaying.hrh"
    
    // CONSTANTS
    _LIT(KFileName, "\\data\\sample.3gp");
    
    // METHODS DEFINITION
    
    // --------------------------------------------------------------------------
    // Constructor
    // --------------------------------------------------------------------------
    void CVideoPlayingAppUi::ConstructL()
    	{
    #ifdef __SERIES60_3X__
    
    	BaseConstructL(EAknEnableSkin);
    	
    	iMainView = CVideoPlayingMainView::NewL(ClientRect());
    
    #else
    
    	BaseConstructL();
    	
    	CVideoPlayingMainView* mainView = CVideoPlayingMainView::NewLC(*this);
    	AddViewL(*mainView);
    	CleanupStack::Pop(mainView);
    	iMainView = mainView;
    	
    #endif	
    	}
    	
    // --------------------------------------------------------------------------
    // Destructor
    // --------------------------------------------------------------------------
    CVideoPlayingAppUi::~CVideoPlayingAppUi()
        {
        delete iVideoPlayer;
        
    #ifdef __SERIES60_3X__
        if (iMainView)
            {
            delete iMainView;
            iMainView = NULL;
            }
    #endif
        }
    
    // --------------------------------------------------------------------------
    // Handles user command.
    // --------------------------------------------------------------------------
    void CVideoPlayingAppUi::HandleCommandL(TInt aCommand)
    	{
    	switch ( aCommand )
    		{
    #ifdef __SERIES60_3X__
    		// For S60, we need to handle this event, which is normally
    		// an event from the right soft key.
    		case EAknSoftkeyExit:
    #endif
    		case EEikCmdExit:
    			{
    			Exit();
    			break;
    			}
    		
    		case EVideoPlayingPlayFromFile:
    			{
    			// Construct file name.
    			// It adds drive letter to KFileName, where drive letter
    			// is the same as the application's executable.
    			TParsePtrC parseAppPath(Application()->AppFullName());
    			TParse parseFileName;
    			parseFileName.Set(parseAppPath.Drive(), 0, &KFileName);
    			
    			// If there is no instance of CSimpleVideoPlayer, then create it.
    			if (!iVideoPlayer)
    				{
    				iVideoPlayer = CSimpleVideoPlayer::NewL(*iMainView);
    				}			
    			iVideoPlayer->PlayL(parseFileName.FullName());
    			
    			// We need to set the text in the control to an empty string
    			// so that there no text displayed during video playback.
    			//iMainView->SetTextL(KNullDesC);
    			break;
    			}
    			
    		case EVideoPlayingStop:
    			{
    			if (iVideoPlayer)
    				{
    				iVideoPlayer->Stop();
    				}
    			break;
    			}
    		
    		default:
    			// Do nothing
    			break;
    		}
    	}
    
    	
    #ifdef __SERIES60_3X__
    
    // --------------------------------------------------------------------------
    // Handles screen resolution/size changes.
    // --------------------------------------------------------------------------
    void CVideoPlayingAppUi::HandleResourceChangeL(TInt aType)
    	{
    	CAknAppUi::HandleResourceChangeL(aType);
    	iMainView->SetRect(ClientRect());
    	
    	if (iVideoPlayer)
    		{
    		iVideoPlayer->SetDisplayWindowL(*iMainView);
    		}
    	}
    
    #endif
    	
    // End of File

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    136

    Re: Unable to Play video

    Quote Originally Posted by wizard_hu_ View Post
    White screen probably comes from a gc.Clear in your Draw method.

    can it happen cause of this
    Code:
    #ifdef __SERIES60_3X__
    	
    ..........
    #endif

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: Unable to Play video

    Those conditional blocks may cause problems if you build the code with Symbian^3 SDK. However if you are building with S60 5th, it is probably fine.
    You can try the example+modification from http://discussion.forum.nokia.com/fo...oPlayerUtility, comments suggest that it works.

  7. #7
    Registered User
    Join Date
    Oct 2010
    Posts
    136

    Re: Unable to Play video

    Quote Originally Posted by wizard_hu_ View Post
    Those conditional blocks may cause problems if you build the code with Symbian^3 SDK. However if you are building with S60 5th, it is probably fine.
    You can try the example+modification from http://discussion.forum.nokia.com/fo...oPlayerUtility, comments suggest that it works.
    Just to let you know that I am not able to build with S^3 SDK, its gives me lots or error, like eikon.rh, avkon.rh missing. so I build the project with 5th edition SDK, and installed on N8, but in N8 I don't see the Video, only the audio comes up.


    I went through the link, also I followed your suggesation, when i comment gc.clear() it works but not like the way it should behave. i mean when I start the app it comes up with the device sreen(not the app screen) with Option and exit menu. when I click on the option->play the video starts playing and I can see the video, but the outside edge of the player is white, where as when I run the same app on 5th edition its black,
    Last edited by v-6; 2011-06-07 at 12:03. Reason: edited

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: Unable to Play video

    Symbian^3 scatters its includes in various places. Obviously the files exist, just they are moved somewhere else. Like these two (eikon.rh and avkon.rh) are moved into \epoc32\include\mw, so you will need this location to appear amongst the SYSTEMINCLUDE-s in the .mmp file. Expect some other similar messages, many headers are moved to new locations.

  9. #9
    Registered User
    Join Date
    Oct 2010
    Posts
    136

    Re: Unable to Play video

    I checked and found that my video plays behind the view screen. how do I bring in front

Similar Threads

  1. Unable to Play Audio/ Video (Qt)
    By somnathbanik in forum Qt
    Replies: 2
    Last Post: 2010-10-13, 08:01
  2. Replies: 0
    Last Post: 2009-10-28, 18:03
  3. Unable to play video
    By hiteshrawat in forum Mobile Java General
    Replies: 24
    Last Post: 2009-07-01, 07:10
  4. Unable to play video in Nokia97 wrt
    By vijaygopal12345 in forum Symbian
    Replies: 1
    Last Post: 2009-06-15, 08:31
  5. Unable To Play a Video File In symbian 9.1 device
    By mailkamlesh in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-08-14, 18:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×