videoplayerapp/videoplayerengine/src/mpxvideoplaybackwrapper.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
equal deleted inserted replaced
47:45e72b57a2fd 52:e3cecb93e76a
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implimentation of QMpxVideoPlaybackWrapper
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version:  ou1cpsw#5 %
       
    19 
       
    20 
       
    21 #include "mpxvideo_debug.h"
       
    22 #include "mpxvideoplaybackwrapper.h"
       
    23 #include "mpxvideoplayerappuiengine.h"
       
    24 
       
    25 
       
    26 // -------------------------------------------------------------------------------------------------
       
    27 //   QMpxVideoPlaybackWrapper::QMpxVideoPlaybackWrapper()
       
    28 // -------------------------------------------------------------------------------------------------
       
    29 //
       
    30 QMpxVideoPlaybackWrapper::QMpxVideoPlaybackWrapper()
       
    31 {
       
    32     MPX_ENTER_EXIT(_L("QMpxVideoPlaybackWrapper::QMpxVideoPlaybackWrapper()"));
       
    33 
       
    34     initializePlugins();
       
    35 }
       
    36 
       
    37 // -------------------------------------------------------------------------------------------------
       
    38 //   QMpxVideoPlaybackWrapper::~QMpxVideoPlaybackWrapper()
       
    39 // -------------------------------------------------------------------------------------------------
       
    40 //
       
    41 QMpxVideoPlaybackWrapper::~QMpxVideoPlaybackWrapper()
       
    42 {
       
    43     MPX_ENTER_EXIT(_L("QMpxVideoPlaybackWrapper::~QMpxVideoPlaybackWrapper()"));
       
    44 
       
    45     if ( mUiEngine ) 
       
    46     {
       
    47         delete mUiEngine;
       
    48         mUiEngine = NULL;
       
    49     }        
       
    50 }
       
    51 
       
    52 // -------------------------------------------------------------------------------------------------
       
    53 //   QMpxVideoPlaybackWrapper::initializePlugins()
       
    54 // -------------------------------------------------------------------------------------------------
       
    55 //
       
    56 void QMpxVideoPlaybackWrapper::initializePlugins()
       
    57 {
       
    58     MPX_ENTER_EXIT(_L("QMpxVideoPlaybackWrapper::initializePlugins()"));
       
    59 
       
    60     TRAPD( err, mUiEngine = CMpxVideoPlayerAppUiEngine::NewL( this ) );
       
    61     MPX_DEBUG(_L("QMpxVideoPlaybackWrapper::initializePlugins err = %d"), err);
       
    62     Q_UNUSED(err);
       
    63 }
       
    64 
       
    65 // -------------------------------------------------------------------------------------------------
       
    66 //   QMpxVideoPlaybackWrapper::playMedia()
       
    67 // -------------------------------------------------------------------------------------------------
       
    68 //
       
    69 int QMpxVideoPlaybackWrapper::playMedia( QString aFileName )
       
    70 {
       
    71     MPX_ENTER_EXIT(_L("QMpxVideoPlaybackWrapper::playMedia"));   
       
    72     
       
    73     TBuf<KMaxFileName> filename( aFileName.utf16() );
       
    74     int error = openFileWithNativePath( filename );
       
    75 
       
    76     MPX_DEBUG(_L("QMpxVideoPlaybackWrapper::playMedia err = %d"), error);
       
    77 
       
    78     return error;
       
    79 }
       
    80 
       
    81 // -------------------------------------------------------------------------------------------------
       
    82 //   QMpxVideoPlaybackWrapper::playMedia()
       
    83 // -------------------------------------------------------------------------------------------------
       
    84 //
       
    85 int QMpxVideoPlaybackWrapper::playMedia( RFile aFile )
       
    86 {
       
    87     MPX_ENTER_EXIT(_L("QMpxVideoPlaybackWrapper::playMedia"));   
       
    88     
       
    89     TRAPD( error, mUiEngine->OpenFileL( aFile ) );
       
    90 
       
    91     MPX_DEBUG(_L("QMpxVideoPlaybackWrapper::playMedia err = %d"), error);
       
    92 
       
    93     return error;
       
    94 }
       
    95 
       
    96 // -------------------------------------------------------------------------------------------------
       
    97 //   QMpxVideoPlaybackWrapper::openPlaybackView()
       
    98 // -------------------------------------------------------------------------------------------------
       
    99 //
       
   100 void QMpxVideoPlaybackWrapper::openPlaybackView()
       
   101 {
       
   102     MPX_ENTER_EXIT(_L("QMpxVideoPlaybackWrapper::openPlaybackView()"));
       
   103 
       
   104     emit handlePlaybackView( MpxHbVideoCommon::ActivatePlaybackView );
       
   105 }
       
   106 
       
   107 // -------------------------------------------------------------------------------------------------
       
   108 //   QMpxVideoPlaybackWrapper::postInit()
       
   109 // -------------------------------------------------------------------------------------------------
       
   110 //
       
   111 void QMpxVideoPlaybackWrapper::lateInit()
       
   112 {
       
   113     MPX_ENTER_EXIT(_L("QMpxVideoPlaybackWrapper::postInit()"));
       
   114     
       
   115     TRAP_IGNORE( mUiEngine->LateInitL() );
       
   116 }
       
   117 
       
   118 // -------------------------------------------------------------------------------------------------
       
   119 //   QMpxVideoPlaybackWrapper::openFileWithNativePath()
       
   120 // -------------------------------------------------------------------------------------------------
       
   121 //
       
   122 int QMpxVideoPlaybackWrapper::openFileWithNativePath(const TDesC& aFileName)
       
   123 {
       
   124     MPX_DEBUG(_L("QMpxVideoPlaybackWrapper::openFileWithNativePath()"));    
       
   125     
       
   126     int err = KErrNone;
       
   127 
       
   128     int fwdSlashPos = aFileName.LocateF('/');
       
   129 
       
   130     if( fwdSlashPos == KErrNotFound )
       
   131     {
       
   132         // no fwd slashes found => filepath is already in 
       
   133         // preferred format eg. c:\\data\\videos\\test.3gp
       
   134         //
       
   135         TRAP( err, mUiEngine->OpenFileL( aFileName ) );        
       
   136     }
       
   137     else
       
   138     {        
       
   139         HBufC* fileName = NULL;
       
   140 
       
   141         TRAP( err,  fileName = aFileName.AllocL() );
       
   142 
       
   143         if ( err == KErrNone )
       
   144         {
       
   145             int count( fileName->Des().Length() );
       
   146 
       
   147             for ( int j = fwdSlashPos ; j < count; ++j )
       
   148             {
       
   149                 if ( fileName->Des()[j]== '/' )
       
   150                 {
       
   151                     fileName->Des()[j]='\\';
       
   152                 }
       
   153             }
       
   154             
       
   155         }
       
   156 
       
   157         TRAP( err, mUiEngine->OpenFileL( fileName->Des() ) );
       
   158         
       
   159         if ( fileName )
       
   160         {
       
   161             delete fileName;
       
   162             fileName = NULL;
       
   163         }        
       
   164     }
       
   165     
       
   166     return err;
       
   167 }
       
   168 
       
   169 
       
   170 // End of File