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