videoplayerapp/videoplayerengine/src/videoplayerengine.cpp
author hgs
Fri, 30 Apr 2010 09:52:11 +0300
changeset 37 4eb2df7f7cbe
parent 36 8aed59de29f9
child 38 ff53afa8ad05
permissions -rw-r--r--
201017
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
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:  Implementation of VideoPlayerEngine
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
37
hgs
parents: 36
diff changeset
    18
// Version : %version: 27 %
30
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
34
hgs
parents: 30
diff changeset
    21
#include <QApplication>
30
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
#include <hbinstance.h>
hgs
parents:
diff changeset
    24
#include <xqpluginloader.h>
hgs
parents:
diff changeset
    25
#include <xqplugininfo.h>
hgs
parents:
diff changeset
    26
#include <xqserviceutil.h>
35
hgs
parents: 34
diff changeset
    27
#include <hbview.h>
30
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
#include "videoplayerengine.h"
hgs
parents:
diff changeset
    30
#include "mpxvideoplaybackwrapper.h"
hgs
parents:
diff changeset
    31
#include "videoservices.h"
35
hgs
parents: 34
diff changeset
    32
#include "mpxvideo_debug.h"
30
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    35
// QVideoPlayerEngine()
hgs
parents:
diff changeset
    36
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    37
//
36
hgs
parents: 35
diff changeset
    38
QVideoPlayerEngine::QVideoPlayerEngine( bool isService )
30
hgs
parents:
diff changeset
    39
    : mIsService( isService )
36
hgs
parents: 35
diff changeset
    40
    , mEmbedded( false )
hgs
parents: 35
diff changeset
    41
    , mDelayedLoadDone( false )
30
hgs
parents:
diff changeset
    42
    , mCurrentViewPlugin( 0 )
hgs
parents:
diff changeset
    43
    , mPlaybackViewPlugin( 0 )
hgs
parents:
diff changeset
    44
    , mCollectionViewPlugin( 0 )
hgs
parents:
diff changeset
    45
    , mFileDetailsViewPlugin( 0 )
hgs
parents:
diff changeset
    46
    , mPlaybackWrapper( 0 )
36
hgs
parents: 35
diff changeset
    47
    , mVideoServices( 0 )
30
hgs
parents:
diff changeset
    48
{
36
hgs
parents: 35
diff changeset
    49
    MPX_DEBUG(_L("QVideoPlayerEngine::QVideoPlayerEngine()"));
30
hgs
parents:
diff changeset
    50
}
hgs
parents:
diff changeset
    51
hgs
parents:
diff changeset
    52
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    53
// ~QVideoPlayerEngine()
hgs
parents:
diff changeset
    54
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    55
//
hgs
parents:
diff changeset
    56
QVideoPlayerEngine::~QVideoPlayerEngine()
hgs
parents:
diff changeset
    57
{
35
hgs
parents: 34
diff changeset
    58
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::~QVideoPlayerEngine()"));
hgs
parents: 34
diff changeset
    59
    	
30
hgs
parents:
diff changeset
    60
    if ( mVideoServices )
hgs
parents:
diff changeset
    61
    {
hgs
parents:
diff changeset
    62
    	mVideoServices->decreaseReferenceCount();
hgs
parents:
diff changeset
    63
    	mVideoServices = 0;
hgs
parents:
diff changeset
    64
    }
hgs
parents:
diff changeset
    65
hgs
parents:
diff changeset
    66
    if ( mCollectionViewPlugin ) 
hgs
parents:
diff changeset
    67
    {
hgs
parents:
diff changeset
    68
        mCollectionViewPlugin->destroyView();
hgs
parents:
diff changeset
    69
    }
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
    if ( mPlaybackViewPlugin ) 
hgs
parents:
diff changeset
    72
    {
hgs
parents:
diff changeset
    73
        mPlaybackViewPlugin->destroyView();
hgs
parents:
diff changeset
    74
    }
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
    if ( mFileDetailsViewPlugin ) 
hgs
parents:
diff changeset
    77
    {
hgs
parents:
diff changeset
    78
        mFileDetailsViewPlugin->destroyView();
hgs
parents:
diff changeset
    79
    }
hgs
parents:
diff changeset
    80
hgs
parents:
diff changeset
    81
    delete mPlaybackWrapper;
hgs
parents:
diff changeset
    82
hgs
parents:
diff changeset
    83
    // disconnect all signals 
hgs
parents:
diff changeset
    84
    disconnect();
hgs
parents:
diff changeset
    85
}
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    88
// initialize()
hgs
parents:
diff changeset
    89
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    90
//
hgs
parents:
diff changeset
    91
void QVideoPlayerEngine::initialize()
hgs
parents:
diff changeset
    92
{
35
hgs
parents: 34
diff changeset
    93
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::initialize()"));	
36
hgs
parents: 35
diff changeset
    94
	
30
hgs
parents:
diff changeset
    95
    //
hgs
parents:
diff changeset
    96
    // Clean up QVideoPlayerEngine when qApp try to quit
hgs
parents:
diff changeset
    97
    //
hgs
parents:
diff changeset
    98
    connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( handleQuit() ) );
hgs
parents:
diff changeset
    99
hgs
parents:
diff changeset
   100
    //
hgs
parents:
diff changeset
   101
    // Create playback wrapper
hgs
parents:
diff changeset
   102
    //
hgs
parents:
diff changeset
   103
    if ( !mPlaybackWrapper )
hgs
parents:
diff changeset
   104
    {
hgs
parents:
diff changeset
   105
        mPlaybackWrapper = new QMpxVideoPlaybackWrapper();
hgs
parents:
diff changeset
   106
        connect( mPlaybackWrapper,
hgs
parents:
diff changeset
   107
                 SIGNAL( handlePlaybackView( int ) ),
hgs
parents:
diff changeset
   108
                 this,
hgs
parents:
diff changeset
   109
                 SLOT( handleCommand( int ) ) );
hgs
parents:
diff changeset
   110
    }
hgs
parents:
diff changeset
   111
hgs
parents:
diff changeset
   112
    //
hgs
parents:
diff changeset
   113
    // Get VideoServices instance
hgs
parents:
diff changeset
   114
    //
37
hgs
parents: 36
diff changeset
   115
    if ( mIsService && ! mVideoServices )
30
hgs
parents:
diff changeset
   116
    {
37
hgs
parents: 36
diff changeset
   117
        mVideoServices = VideoServices::instance(this);
hgs
parents: 36
diff changeset
   118
        connect( mVideoServices, SIGNAL(activated(int)), this, SLOT(handleCommand(int)));
30
hgs
parents:
diff changeset
   119
    }
hgs
parents:
diff changeset
   120
hgs
parents:
diff changeset
   121
    QList<XQPluginInfo> impls;
hgs
parents:
diff changeset
   122
    XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls);
hgs
parents:
diff changeset
   123
hgs
parents:
diff changeset
   124
    //
36
hgs
parents: 35
diff changeset
   125
    // Pre-load collection plugin and create collection view
30
hgs
parents:
diff changeset
   126
    //
36
hgs
parents: 35
diff changeset
   127
    loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
30
hgs
parents:
diff changeset
   128
    
hgs
parents:
diff changeset
   129
    //
36
hgs
parents: 35
diff changeset
   130
    // if app is opened via serviceFW create remaining views
hgs
parents: 35
diff changeset
   131
    // otherwise activate default view i.e. the collection view.    
30
hgs
parents:
diff changeset
   132
    //
37
hgs
parents: 36
diff changeset
   133
    if ( mIsService )
30
hgs
parents:
diff changeset
   134
    {
36
hgs
parents: 35
diff changeset
   135
        createPlayAndDetailsViews(); 
hgs
parents: 35
diff changeset
   136
    }
hgs
parents: 35
diff changeset
   137
    else
hgs
parents: 35
diff changeset
   138
    {        
30
hgs
parents:
diff changeset
   139
        activateView( MpxHbVideoCommon::CollectionView );
36
hgs
parents: 35
diff changeset
   140
    }
hgs
parents: 35
diff changeset
   141
        
30
hgs
parents:
diff changeset
   142
}
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   145
// handleCommand()
hgs
parents:
diff changeset
   146
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   147
//
hgs
parents:
diff changeset
   148
void QVideoPlayerEngine::handleCommand( int commandCode )
hgs
parents:
diff changeset
   149
{
36
hgs
parents: 35
diff changeset
   150
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleCommand()"),
hgs
parents: 35
diff changeset
   151
                   _L("commandCode = %d"), commandCode );
hgs
parents: 35
diff changeset
   152
    
30
hgs
parents:
diff changeset
   153
    switch ( commandCode )
hgs
parents:
diff changeset
   154
    {
hgs
parents:
diff changeset
   155
        case MpxHbVideoCommon::ActivateCollectionView:
hgs
parents:
diff changeset
   156
        {
hgs
parents:
diff changeset
   157
            if ( mCurrentViewPlugin != mCollectionViewPlugin )
hgs
parents:
diff changeset
   158
            { 
hgs
parents:
diff changeset
   159
                activateView( MpxHbVideoCommon::CollectionView );
hgs
parents:
diff changeset
   160
            }
hgs
parents:
diff changeset
   161
            break;
hgs
parents:
diff changeset
   162
        }
hgs
parents:
diff changeset
   163
        case MpxHbVideoCommon::ActivatePlaybackView:
hgs
parents:
diff changeset
   164
        {
hgs
parents:
diff changeset
   165
            if ( mCurrentViewPlugin != mPlaybackViewPlugin )
hgs
parents:
diff changeset
   166
            {                
hgs
parents:
diff changeset
   167
                activateView( MpxHbVideoCommon::PlaybackView );                
hgs
parents:
diff changeset
   168
            }
hgs
parents:
diff changeset
   169
            break;
hgs
parents:
diff changeset
   170
        }
hgs
parents:
diff changeset
   171
        case MpxHbVideoCommon::ActivateVideoDetailsView:
hgs
parents:
diff changeset
   172
        {
hgs
parents:
diff changeset
   173
            if ( mCurrentViewPlugin != mFileDetailsViewPlugin )
37
hgs
parents: 36
diff changeset
   174
            {
hgs
parents: 36
diff changeset
   175
                activateView( MpxHbVideoCommon::VideoDetailsView );                
30
hgs
parents:
diff changeset
   176
            }
hgs
parents:
diff changeset
   177
            break;
hgs
parents:
diff changeset
   178
        }
35
hgs
parents: 34
diff changeset
   179
        case MpxHbVideoCommon::DoDelayedLoad:
30
hgs
parents:
diff changeset
   180
        {
37
hgs
parents: 36
diff changeset
   181
            if ( ! mDelayedLoadDone )
hgs
parents: 36
diff changeset
   182
            {
hgs
parents: 36
diff changeset
   183
                doDelayedLoad();
hgs
parents: 36
diff changeset
   184
            }
35
hgs
parents: 34
diff changeset
   185
            break;
hgs
parents: 34
diff changeset
   186
        }
30
hgs
parents:
diff changeset
   187
        
hgs
parents:
diff changeset
   188
        default:
hgs
parents:
diff changeset
   189
        {
hgs
parents:
diff changeset
   190
            break;
hgs
parents:
diff changeset
   191
        }
hgs
parents:
diff changeset
   192
    }    
hgs
parents:
diff changeset
   193
}
hgs
parents:
diff changeset
   194
hgs
parents:
diff changeset
   195
// -------------------------------------------------------------------------------------------------
35
hgs
parents: 34
diff changeset
   196
// doDelayedLoad()
hgs
parents: 34
diff changeset
   197
// -------------------------------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   198
//
hgs
parents: 34
diff changeset
   199
void QVideoPlayerEngine::doDelayedLoad()
hgs
parents: 34
diff changeset
   200
{
36
hgs
parents: 35
diff changeset
   201
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::doDelayedLoad()"));
hgs
parents: 35
diff changeset
   202
	
hgs
parents: 35
diff changeset
   203
    createPlayAndDetailsViews();
35
hgs
parents: 34
diff changeset
   204
	
37
hgs
parents: 36
diff changeset
   205
    mDelayedLoadDone = true;
35
hgs
parents: 34
diff changeset
   206
}
hgs
parents: 34
diff changeset
   207
hgs
parents: 34
diff changeset
   208
// -------------------------------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   209
// createPlayAndDetailsViews()
hgs
parents: 35
diff changeset
   210
// -------------------------------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   211
//
hgs
parents: 35
diff changeset
   212
void QVideoPlayerEngine::createPlayAndDetailsViews()
hgs
parents: 35
diff changeset
   213
{
hgs
parents: 35
diff changeset
   214
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::createPlayAndDetailsViews()"));
hgs
parents: 35
diff changeset
   215
    
37
hgs
parents: 36
diff changeset
   216
    //
hgs
parents: 36
diff changeset
   217
    // delayed initialization of some uiengine member variables
hgs
parents: 36
diff changeset
   218
    // to help application startup time & improve playback start time
hgs
parents: 36
diff changeset
   219
    //
hgs
parents: 36
diff changeset
   220
    mPlaybackWrapper->lateInit();
hgs
parents: 36
diff changeset
   221
    
36
hgs
parents: 35
diff changeset
   222
    if ( ! mPlaybackViewPlugin )
hgs
parents: 35
diff changeset
   223
    {
hgs
parents: 35
diff changeset
   224
        loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
hgs
parents: 35
diff changeset
   225
    }
hgs
parents: 35
diff changeset
   226
hgs
parents: 35
diff changeset
   227
    if ( ! mFileDetailsViewPlugin )
hgs
parents: 35
diff changeset
   228
    {
hgs
parents: 35
diff changeset
   229
        loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );
37
hgs
parents: 36
diff changeset
   230
    }
36
hgs
parents: 35
diff changeset
   231
}
hgs
parents: 35
diff changeset
   232
hgs
parents: 35
diff changeset
   233
hgs
parents: 35
diff changeset
   234
// -------------------------------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   235
// activateView()
hgs
parents:
diff changeset
   236
// activate view based on view type.
hgs
parents:
diff changeset
   237
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   238
//
hgs
parents:
diff changeset
   239
void QVideoPlayerEngine::activateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
hgs
parents:
diff changeset
   240
{
36
hgs
parents: 35
diff changeset
   241
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::activateView() "),
hgs
parents: 35
diff changeset
   242
                   _L("viewType = %d"), viewType );
hgs
parents: 35
diff changeset
   243
    	  
30
hgs
parents:
diff changeset
   244
    disconnectView();
hgs
parents:
diff changeset
   245
    
hgs
parents:
diff changeset
   246
    if ( mCurrentViewPlugin )
hgs
parents:
diff changeset
   247
    {
hgs
parents:
diff changeset
   248
        mCurrentViewPlugin->deactivateView();
hgs
parents:
diff changeset
   249
        mCurrentViewPlugin = NULL;
hgs
parents:
diff changeset
   250
    }
hgs
parents:
diff changeset
   251
hgs
parents:
diff changeset
   252
    if ( viewType == MpxHbVideoCommon::CollectionView && mCollectionViewPlugin  ) 
hgs
parents:
diff changeset
   253
    {
36
hgs
parents: 35
diff changeset
   254
        if ( mIsService &&  
hgs
parents: 35
diff changeset
   255
             ( mVideoServices->currentService() == VideoServices::EPlayback ||
37
hgs
parents: 36
diff changeset
   256
               mVideoServices->currentService() == VideoServices::EView || 
hgs
parents: 36
diff changeset
   257
               mVideoServices->currentService() == VideoServices::EUriFetcher ) )
36
hgs
parents: 35
diff changeset
   258
        {
37
hgs
parents: 36
diff changeset
   259
            if ( mVideoServices->currentService() == VideoServices::EUriFetcher )
hgs
parents: 36
diff changeset
   260
            {
hgs
parents: 36
diff changeset
   261
                if ( ! mVideoServices->mFetchSelected )    
hgs
parents: 36
diff changeset
   262
                {
hgs
parents: 36
diff changeset
   263
                    // 
hgs
parents: 36
diff changeset
   264
                    // view is in 'fetch' service but 'attach' operation has not been selected,
hgs
parents: 36
diff changeset
   265
                    // therefore, go back to collection view
hgs
parents: 36
diff changeset
   266
                    //
hgs
parents: 36
diff changeset
   267
                    mCurrentViewPlugin = mCollectionViewPlugin;
hgs
parents: 36
diff changeset
   268
                    setCurrentView();                    
hgs
parents: 36
diff changeset
   269
                }
hgs
parents: 36
diff changeset
   270
            }
hgs
parents: 36
diff changeset
   271
            else
hgs
parents: 36
diff changeset
   272
            {
hgs
parents: 36
diff changeset
   273
                qApp->quit();
hgs
parents: 36
diff changeset
   274
                XQServiceUtil::toBackground( false );
hgs
parents: 36
diff changeset
   275
            }
36
hgs
parents: 35
diff changeset
   276
        }
hgs
parents: 35
diff changeset
   277
        else
hgs
parents: 35
diff changeset
   278
        {
hgs
parents: 35
diff changeset
   279
            mCurrentViewPlugin = mCollectionViewPlugin;
hgs
parents: 35
diff changeset
   280
            setCurrentView();
hgs
parents: 35
diff changeset
   281
        }
30
hgs
parents:
diff changeset
   282
    }
35
hgs
parents: 34
diff changeset
   283
    else if ( viewType == MpxHbVideoCommon::PlaybackView ) 
30
hgs
parents:
diff changeset
   284
    {
37
hgs
parents: 36
diff changeset
   285
        if ( ! mPlaybackViewPlugin )
35
hgs
parents: 34
diff changeset
   286
    	{
37
hgs
parents: 36
diff changeset
   287
            loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
36
hgs
parents: 35
diff changeset
   288
        }
hgs
parents: 35
diff changeset
   289
		
30
hgs
parents:
diff changeset
   290
        mCurrentViewPlugin = mPlaybackViewPlugin;
36
hgs
parents: 35
diff changeset
   291
        setCurrentView();
30
hgs
parents:
diff changeset
   292
    }
35
hgs
parents: 34
diff changeset
   293
    else if ( viewType == MpxHbVideoCommon::VideoDetailsView ) 
30
hgs
parents:
diff changeset
   294
    {
37
hgs
parents: 36
diff changeset
   295
        if ( ! mFileDetailsViewPlugin )
35
hgs
parents: 34
diff changeset
   296
    	{
37
hgs
parents: 36
diff changeset
   297
            loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );	
35
hgs
parents: 34
diff changeset
   298
    	}
36
hgs
parents: 35
diff changeset
   299
		
30
hgs
parents:
diff changeset
   300
        mCurrentViewPlugin = mFileDetailsViewPlugin;
36
hgs
parents: 35
diff changeset
   301
        setCurrentView();
30
hgs
parents:
diff changeset
   302
    }
hgs
parents:
diff changeset
   303
}
hgs
parents:
diff changeset
   304
hgs
parents:
diff changeset
   305
// -------------------------------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   306
// loadPluginAndCreateView()
30
hgs
parents:
diff changeset
   307
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   308
//
36
hgs
parents: 35
diff changeset
   309
void QVideoPlayerEngine::loadPluginAndCreateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
30
hgs
parents:
diff changeset
   310
{
36
hgs
parents: 35
diff changeset
   311
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::loadPluginAndCreateView() "), 
hgs
parents: 35
diff changeset
   312
                   _L("viewType = %d"), viewType );
35
hgs
parents: 34
diff changeset
   313
	  
30
hgs
parents:
diff changeset
   314
    int viewTypeUid( 0 );
hgs
parents:
diff changeset
   315
hgs
parents:
diff changeset
   316
    if ( viewType == MpxHbVideoCommon::CollectionView ) 
hgs
parents:
diff changeset
   317
    {
hgs
parents:
diff changeset
   318
        viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllCollectionUid;
hgs
parents:
diff changeset
   319
    }
hgs
parents:
diff changeset
   320
    else if ( viewType == MpxHbVideoCommon::PlaybackView ) 
hgs
parents:
diff changeset
   321
    {
hgs
parents:
diff changeset
   322
        viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllPlaybackUid;
hgs
parents:
diff changeset
   323
    }
37
hgs
parents: 36
diff changeset
   324
    else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
30
hgs
parents:
diff changeset
   325
    {
hgs
parents:
diff changeset
   326
        viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllFileDetailsUid;
hgs
parents:
diff changeset
   327
    }
hgs
parents:
diff changeset
   328
hgs
parents:
diff changeset
   329
    if ( viewTypeUid )
hgs
parents:
diff changeset
   330
    {
36
hgs
parents: 35
diff changeset
   331
        // 
37
hgs
parents: 36
diff changeset
   332
        // load corresponding plug-in
hgs
parents: 36
diff changeset
   333
        //
30
hgs
parents:
diff changeset
   334
        XQPluginLoader pluginLoader( viewTypeUid );
hgs
parents:
diff changeset
   335
        QObject* instance = pluginLoader.instance();
hgs
parents:
diff changeset
   336
hgs
parents:
diff changeset
   337
        if ( instance )
hgs
parents:
diff changeset
   338
        {
36
hgs
parents: 35
diff changeset
   339
            MpxViewPlugin *currentViewPlugin = NULL;
hgs
parents: 35
diff changeset
   340
30
hgs
parents:
diff changeset
   341
            if ( viewType == MpxHbVideoCommon::CollectionView ) 
hgs
parents:
diff changeset
   342
            {
hgs
parents:
diff changeset
   343
                mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
36
hgs
parents: 35
diff changeset
   344
                currentViewPlugin = mCollectionViewPlugin;
30
hgs
parents:
diff changeset
   345
            }
hgs
parents:
diff changeset
   346
            else if ( viewType == MpxHbVideoCommon::PlaybackView )
hgs
parents:
diff changeset
   347
            {
hgs
parents:
diff changeset
   348
                mPlaybackViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
36
hgs
parents: 35
diff changeset
   349
                currentViewPlugin = mPlaybackViewPlugin;
30
hgs
parents:
diff changeset
   350
            }
hgs
parents:
diff changeset
   351
            else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
hgs
parents:
diff changeset
   352
            {
hgs
parents:
diff changeset
   353
                mFileDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
36
hgs
parents: 35
diff changeset
   354
                currentViewPlugin = mFileDetailsViewPlugin;
30
hgs
parents:
diff changeset
   355
            }
36
hgs
parents: 35
diff changeset
   356
            else
hgs
parents: 35
diff changeset
   357
            {
hgs
parents: 35
diff changeset
   358
                MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : plugin not FOUND ! "));                
hgs
parents: 35
diff changeset
   359
            }
hgs
parents: 35
diff changeset
   360
            
37
hgs
parents: 36
diff changeset
   361
            //
hgs
parents: 36
diff changeset
   362
            // create corresponding view
hgs
parents: 36
diff changeset
   363
            //
36
hgs
parents: 35
diff changeset
   364
            if ( currentViewPlugin ) 
hgs
parents: 35
diff changeset
   365
            {
hgs
parents: 35
diff changeset
   366
                QGraphicsWidget *view = currentViewPlugin->getView();
hgs
parents: 35
diff changeset
   367
          
hgs
parents: 35
diff changeset
   368
                if ( ! view )
hgs
parents: 35
diff changeset
   369
                {
hgs
parents: 35
diff changeset
   370
                    MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : create view "));
hgs
parents: 35
diff changeset
   371
                    
hgs
parents: 35
diff changeset
   372
                    currentViewPlugin->createView();
hgs
parents: 35
diff changeset
   373
                    hbInstance->allMainWindows().value(0)->addView( currentViewPlugin->getView() );
hgs
parents: 35
diff changeset
   374
                }
hgs
parents: 35
diff changeset
   375
                else
hgs
parents: 35
diff changeset
   376
                {
hgs
parents: 35
diff changeset
   377
                    MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : view has already been created! "));                    
hgs
parents: 35
diff changeset
   378
                }
hgs
parents: 35
diff changeset
   379
            }
hgs
parents: 35
diff changeset
   380
            else
hgs
parents: 35
diff changeset
   381
            {
hgs
parents: 35
diff changeset
   382
                MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : currentViewPlugin is NULL ! "));                    
hgs
parents: 35
diff changeset
   383
            }            
30
hgs
parents:
diff changeset
   384
        }
hgs
parents:
diff changeset
   385
    }
hgs
parents:
diff changeset
   386
}
hgs
parents:
diff changeset
   387
hgs
parents:
diff changeset
   388
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   389
// connectView()
hgs
parents:
diff changeset
   390
// connect application to view by setting up the signals and slots.
hgs
parents:
diff changeset
   391
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   392
//
hgs
parents:
diff changeset
   393
void QVideoPlayerEngine::connectView()
hgs
parents:
diff changeset
   394
{
36
hgs
parents: 35
diff changeset
   395
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::connectView()"));
35
hgs
parents: 34
diff changeset
   396
	  
30
hgs
parents:
diff changeset
   397
    connect( mCurrentViewPlugin,
hgs
parents:
diff changeset
   398
             SIGNAL( command( int ) ),
hgs
parents:
diff changeset
   399
             this,
hgs
parents:
diff changeset
   400
             SLOT( handleCommand( int ) ) );
hgs
parents:
diff changeset
   401
}
hgs
parents:
diff changeset
   402
hgs
parents:
diff changeset
   403
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   404
// disconnectView()
hgs
parents:
diff changeset
   405
// connect application to view by setting up the signals and slots.
hgs
parents:
diff changeset
   406
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   407
//
hgs
parents:
diff changeset
   408
void QVideoPlayerEngine::disconnectView()
hgs
parents:
diff changeset
   409
{
36
hgs
parents: 35
diff changeset
   410
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::disconnectView()"));
35
hgs
parents: 34
diff changeset
   411
	  
30
hgs
parents:
diff changeset
   412
    if ( mCurrentViewPlugin )
hgs
parents:
diff changeset
   413
    {
hgs
parents:
diff changeset
   414
        disconnect( mCurrentViewPlugin,
hgs
parents:
diff changeset
   415
                    SIGNAL( command( int ) ),
hgs
parents:
diff changeset
   416
                    this,
hgs
parents:
diff changeset
   417
                    SLOT( handleCommand( int ) ) );   
hgs
parents:
diff changeset
   418
    }
hgs
parents:
diff changeset
   419
}
hgs
parents:
diff changeset
   420
hgs
parents:
diff changeset
   421
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   422
// handleQuit()
hgs
parents:
diff changeset
   423
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   424
//
hgs
parents:
diff changeset
   425
void QVideoPlayerEngine::handleQuit()
hgs
parents:
diff changeset
   426
{
36
hgs
parents: 35
diff changeset
   427
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleQuit()"));
35
hgs
parents: 34
diff changeset
   428
	  
30
hgs
parents:
diff changeset
   429
    delete this;
hgs
parents:
diff changeset
   430
}
hgs
parents:
diff changeset
   431
hgs
parents:
diff changeset
   432
hgs
parents:
diff changeset
   433
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   434
// playMedia()
hgs
parents:
diff changeset
   435
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   436
//
hgs
parents:
diff changeset
   437
void QVideoPlayerEngine::playMedia( QString filePath )
hgs
parents:
diff changeset
   438
{
36
hgs
parents: 35
diff changeset
   439
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia()"),
hgs
parents: 35
diff changeset
   440
                   _L("filePath = %s"), filePath.data() );  
35
hgs
parents: 34
diff changeset
   441
	  	
30
hgs
parents:
diff changeset
   442
    mPlaybackWrapper->playMedia( filePath );
hgs
parents:
diff changeset
   443
}
hgs
parents:
diff changeset
   444
hgs
parents:
diff changeset
   445
// -------------------------------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   446
// playMedia()
hgs
parents: 35
diff changeset
   447
// -------------------------------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   448
//
hgs
parents: 35
diff changeset
   449
void QVideoPlayerEngine::playMedia( RFile file )
hgs
parents: 35
diff changeset
   450
{
hgs
parents: 35
diff changeset
   451
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia( RFile )")); 
hgs
parents: 35
diff changeset
   452
        
hgs
parents: 35
diff changeset
   453
    mPlaybackWrapper->playMedia( file );    
hgs
parents: 35
diff changeset
   454
}
hgs
parents: 35
diff changeset
   455
hgs
parents: 35
diff changeset
   456
// -------------------------------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   457
// setEmbedded()
hgs
parents:
diff changeset
   458
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   459
//
hgs
parents:
diff changeset
   460
void QVideoPlayerEngine::setEmbedded()
hgs
parents:
diff changeset
   461
{
36
hgs
parents: 35
diff changeset
   462
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setEmbedded()")); 
35
hgs
parents: 34
diff changeset
   463
	  
30
hgs
parents:
diff changeset
   464
    mEmbedded = true;
hgs
parents:
diff changeset
   465
}
hgs
parents:
diff changeset
   466
36
hgs
parents: 35
diff changeset
   467
// -------------------------------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   468
// setCurrentView()
hgs
parents: 35
diff changeset
   469
// -------------------------------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   470
//
hgs
parents: 35
diff changeset
   471
void QVideoPlayerEngine::setCurrentView()
hgs
parents: 35
diff changeset
   472
{
hgs
parents: 35
diff changeset
   473
    MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setCurrentView()")); 
hgs
parents: 35
diff changeset
   474
	
hgs
parents: 35
diff changeset
   475
    if ( mCurrentViewPlugin )
hgs
parents: 35
diff changeset
   476
    {
hgs
parents: 35
diff changeset
   477
        //
hgs
parents: 35
diff changeset
   478
        // set current view
hgs
parents: 35
diff changeset
   479
        //
hgs
parents: 35
diff changeset
   480
        hbInstance->allMainWindows().value(0)->setCurrentView( 
hgs
parents: 35
diff changeset
   481
		                            qobject_cast<HbView*>( mCurrentViewPlugin->getView() ), false );
hgs
parents: 35
diff changeset
   482
hgs
parents: 35
diff changeset
   483
        //
hgs
parents: 35
diff changeset
   484
        // connect view
hgs
parents: 35
diff changeset
   485
        //
hgs
parents: 35
diff changeset
   486
        connectView();
hgs
parents: 35
diff changeset
   487
hgs
parents: 35
diff changeset
   488
        // 
hgs
parents: 35
diff changeset
   489
        // activate view
hgs
parents: 35
diff changeset
   490
        //
hgs
parents: 35
diff changeset
   491
        mCurrentViewPlugin->activateView();
hgs
parents: 35
diff changeset
   492
    }
hgs
parents: 35
diff changeset
   493
}
hgs
parents: 35
diff changeset
   494
hgs
parents: 35
diff changeset
   495
30
hgs
parents:
diff changeset
   496
// End of file