videoplayerapp/videoplayerengine/src/videoplayerengine.cpp
author hgs
Mon, 23 Aug 2010 14:27:29 +0300
changeset 55 4bfa887905cf
parent 50 21fe8338c6bf
child 58 d2b028fd1f7d
permissions -rw-r--r--
201033
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
55
hgs
parents: 50
diff changeset
    18
// Version : %version: da1mmcf#43 %
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>
40
hgs
parents: 39
diff changeset
    28
#include <hbapplication.h>
hgs
parents: 39
diff changeset
    29
#include <hbactivitymanager.h>
55
hgs
parents: 50
diff changeset
    30
#include <hbnotificationdialog.h>
30
hgs
parents:
diff changeset
    31
hgs
parents:
diff changeset
    32
#include "videoplayerengine.h"
40
hgs
parents: 39
diff changeset
    33
#include "videoactivitystate.h"
44
hgs
parents: 42
diff changeset
    34
#include "videoplaybackwrapper.h"
30
hgs
parents:
diff changeset
    35
#include "videoservices.h"
35
hgs
parents: 34
diff changeset
    36
#include "mpxvideo_debug.h"
30
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
// -------------------------------------------------------------------------------------------------
44
hgs
parents: 42
diff changeset
    39
// VideoPlayerEngine()
30
hgs
parents:
diff changeset
    40
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    41
//
44
hgs
parents: 42
diff changeset
    42
VideoPlayerEngine::VideoPlayerEngine( bool isService )
30
hgs
parents:
diff changeset
    43
    : mIsService( isService )
36
hgs
parents: 35
diff changeset
    44
    , mEmbedded( false )
hgs
parents: 35
diff changeset
    45
    , mDelayedLoadDone( false )
38
hgs
parents: 37
diff changeset
    46
    , mIsPlayService( false )
30
hgs
parents:
diff changeset
    47
    , mCurrentViewPlugin( 0 )
hgs
parents:
diff changeset
    48
    , mPlaybackViewPlugin( 0 )
hgs
parents:
diff changeset
    49
    , mCollectionViewPlugin( 0 )
hgs
parents:
diff changeset
    50
    , mFileDetailsViewPlugin( 0 )
hgs
parents:
diff changeset
    51
    , mPlaybackWrapper( 0 )
36
hgs
parents: 35
diff changeset
    52
    , mVideoServices( 0 )
30
hgs
parents:
diff changeset
    53
{
44
hgs
parents: 42
diff changeset
    54
    MPX_DEBUG(_L("VideoPlayerEngine::VideoPlayerEngine()"));
30
hgs
parents:
diff changeset
    55
}
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
// -------------------------------------------------------------------------------------------------
44
hgs
parents: 42
diff changeset
    58
// ~VideoPlayerEngine()
30
hgs
parents:
diff changeset
    59
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    60
//
44
hgs
parents: 42
diff changeset
    61
VideoPlayerEngine::~VideoPlayerEngine()
30
hgs
parents:
diff changeset
    62
{
44
hgs
parents: 42
diff changeset
    63
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::~VideoPlayerEngine()"));
hgs
parents: 42
diff changeset
    64
    	
30
hgs
parents:
diff changeset
    65
    if ( mVideoServices )
hgs
parents:
diff changeset
    66
    {
hgs
parents:
diff changeset
    67
    	mVideoServices->decreaseReferenceCount();
hgs
parents:
diff changeset
    68
    	mVideoServices = 0;
hgs
parents:
diff changeset
    69
    }
hgs
parents:
diff changeset
    70
44
hgs
parents: 42
diff changeset
    71
    if ( mCollectionViewPlugin ) 
30
hgs
parents:
diff changeset
    72
    {
hgs
parents:
diff changeset
    73
        mCollectionViewPlugin->destroyView();
44
hgs
parents: 42
diff changeset
    74
        delete mCollectionViewPlugin;
hgs
parents: 42
diff changeset
    75
        mCollectionViewPlugin = 0;
30
hgs
parents:
diff changeset
    76
    }
hgs
parents:
diff changeset
    77
44
hgs
parents: 42
diff changeset
    78
    if ( mPlaybackViewPlugin ) 
30
hgs
parents:
diff changeset
    79
    {
hgs
parents:
diff changeset
    80
        mPlaybackViewPlugin->destroyView();
44
hgs
parents: 42
diff changeset
    81
        delete mPlaybackViewPlugin;
hgs
parents: 42
diff changeset
    82
        mPlaybackViewPlugin = 0;
30
hgs
parents:
diff changeset
    83
    }
hgs
parents:
diff changeset
    84
44
hgs
parents: 42
diff changeset
    85
    if ( mFileDetailsViewPlugin ) 
30
hgs
parents:
diff changeset
    86
    {
hgs
parents:
diff changeset
    87
        mFileDetailsViewPlugin->destroyView();
44
hgs
parents: 42
diff changeset
    88
        delete mFileDetailsViewPlugin;
hgs
parents: 42
diff changeset
    89
        mFileDetailsViewPlugin = 0;
30
hgs
parents:
diff changeset
    90
    }
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
    delete mPlaybackWrapper;
hgs
parents:
diff changeset
    93
44
hgs
parents: 42
diff changeset
    94
    // disconnect all signals 
30
hgs
parents:
diff changeset
    95
    disconnect();
hgs
parents:
diff changeset
    96
}
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    99
// initialize()
hgs
parents:
diff changeset
   100
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   101
//
44
hgs
parents: 42
diff changeset
   102
void VideoPlayerEngine::initialize()
30
hgs
parents:
diff changeset
   103
{
44
hgs
parents: 42
diff changeset
   104
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::initialize()"));	
hgs
parents: 42
diff changeset
   105
	
30
hgs
parents:
diff changeset
   106
    //
44
hgs
parents: 42
diff changeset
   107
    // Clean up VideoPlayerEngine when qApp try to quit
30
hgs
parents:
diff changeset
   108
    //
hgs
parents:
diff changeset
   109
    connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( handleQuit() ) );
hgs
parents:
diff changeset
   110
hgs
parents:
diff changeset
   111
    //
hgs
parents:
diff changeset
   112
    // Create playback wrapper
hgs
parents:
diff changeset
   113
    //
44
hgs
parents: 42
diff changeset
   114
    if ( ! mPlaybackWrapper )
30
hgs
parents:
diff changeset
   115
    {
44
hgs
parents: 42
diff changeset
   116
        mPlaybackWrapper = new VideoPlaybackWrapper();
30
hgs
parents:
diff changeset
   117
        connect( mPlaybackWrapper,
hgs
parents:
diff changeset
   118
                 SIGNAL( handlePlaybackView( int ) ),
hgs
parents:
diff changeset
   119
                 this,
hgs
parents:
diff changeset
   120
                 SLOT( handleCommand( int ) ) );
hgs
parents:
diff changeset
   121
    }
hgs
parents:
diff changeset
   122
hgs
parents:
diff changeset
   123
    QList<XQPluginInfo> impls;
hgs
parents:
diff changeset
   124
    XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls);
44
hgs
parents: 42
diff changeset
   125
    
40
hgs
parents: 39
diff changeset
   126
    if ( mIsService )
30
hgs
parents:
diff changeset
   127
    {
44
hgs
parents: 42
diff changeset
   128
        if ( ! mVideoServices )
40
hgs
parents: 39
diff changeset
   129
        {
hgs
parents: 39
diff changeset
   130
            mVideoServices = VideoServices::instance(this);
hgs
parents: 39
diff changeset
   131
            connect( mVideoServices, SIGNAL(activated(int)), this, SLOT(handleCommand(int)));
hgs
parents: 39
diff changeset
   132
        }
44
hgs
parents: 42
diff changeset
   133
40
hgs
parents: 39
diff changeset
   134
        if ( isPlayServiceInvoked() )
hgs
parents: 39
diff changeset
   135
        {
44
hgs
parents: 42
diff changeset
   136
            createPlaybackView(); 
40
hgs
parents: 39
diff changeset
   137
        }
hgs
parents: 39
diff changeset
   138
        else
hgs
parents: 39
diff changeset
   139
        {
44
hgs
parents: 42
diff changeset
   140
            loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );  
hgs
parents: 42
diff changeset
   141
            
hgs
parents: 42
diff changeset
   142
            //
40
hgs
parents: 39
diff changeset
   143
            // Browse service will activate view once the category to be opened is informed from highway
hgs
parents: 39
diff changeset
   144
            // since the category is not known at this point, we do not activate view for it here
44
hgs
parents: 42
diff changeset
   145
            //
hgs
parents: 42
diff changeset
   146
            if ( ! (XQServiceUtil::interfaceName().contains("IVideoBrowse") ) )
40
hgs
parents: 39
diff changeset
   147
            {
44
hgs
parents: 42
diff changeset
   148
                activateView( MpxHbVideoCommon::CollectionView );   
40
hgs
parents: 39
diff changeset
   149
            }
hgs
parents: 39
diff changeset
   150
        }
36
hgs
parents: 35
diff changeset
   151
    }
hgs
parents: 35
diff changeset
   152
    else
38
hgs
parents: 37
diff changeset
   153
    {
44
hgs
parents: 42
diff changeset
   154
        //
hgs
parents: 42
diff changeset
   155
        // check latest plugin type from activity manager data and create + activate it 
40
hgs
parents: 39
diff changeset
   156
        // CollectionView (default) and playbackview are the ones that are accepted
44
hgs
parents: 42
diff changeset
   157
        //
40
hgs
parents: 39
diff changeset
   158
        MpxHbVideoCommon::MpxHbVideoViewType viewType = MpxHbVideoCommon::CollectionView;
44
hgs
parents: 42
diff changeset
   159
        int typeGotten = VideoActivityState::instance().getActivityData( KEY_VIEWPLUGIN_TYPE ).toInt();
hgs
parents: 42
diff changeset
   160
        
hgs
parents: 42
diff changeset
   161
        if ( typeGotten == MpxHbVideoCommon::PlaybackView )  
38
hgs
parents: 37
diff changeset
   162
        {
44
hgs
parents: 42
diff changeset
   163
            createPlaybackView(); 
40
hgs
parents: 39
diff changeset
   164
            viewType = MpxHbVideoCommon::MpxHbVideoViewType(typeGotten);
44
hgs
parents: 42
diff changeset
   165
            QVariant data = VideoActivityState::instance().getActivityData( KEY_LAST_PLAYED_CLIP );
49
hgs
parents: 44
diff changeset
   166
            int error = mPlaybackWrapper->replayMedia( data.toString() );
hgs
parents: 44
diff changeset
   167
            
hgs
parents: 44
diff changeset
   168
            // if replay fails, then activate collection view instead
hgs
parents: 44
diff changeset
   169
            if ( error != KErrNone )
hgs
parents: 44
diff changeset
   170
            {
hgs
parents: 44
diff changeset
   171
                loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );  
hgs
parents: 44
diff changeset
   172
                activateView( MpxHbVideoCommon::CollectionView );                 
hgs
parents: 44
diff changeset
   173
            }            
38
hgs
parents: 37
diff changeset
   174
        }
41
hgs
parents: 40
diff changeset
   175
        else
hgs
parents: 40
diff changeset
   176
        {
44
hgs
parents: 42
diff changeset
   177
            loadPluginAndCreateView( viewType );  
hgs
parents: 42
diff changeset
   178
            activateView( viewType );        
41
hgs
parents: 40
diff changeset
   179
        }
36
hgs
parents: 35
diff changeset
   180
    }
44
hgs
parents: 42
diff changeset
   181
            
30
hgs
parents:
diff changeset
   182
}
hgs
parents:
diff changeset
   183
hgs
parents:
diff changeset
   184
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   185
// handleCommand()
hgs
parents:
diff changeset
   186
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   187
//
44
hgs
parents: 42
diff changeset
   188
void VideoPlayerEngine::handleCommand( int commandCode )
30
hgs
parents:
diff changeset
   189
{
44
hgs
parents: 42
diff changeset
   190
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::handleCommand()"),
36
hgs
parents: 35
diff changeset
   191
                   _L("commandCode = %d"), commandCode );
44
hgs
parents: 42
diff changeset
   192
    
30
hgs
parents:
diff changeset
   193
    switch ( commandCode )
hgs
parents:
diff changeset
   194
    {
hgs
parents:
diff changeset
   195
        case MpxHbVideoCommon::ActivateCollectionView:
hgs
parents:
diff changeset
   196
        {
hgs
parents:
diff changeset
   197
            if ( mCurrentViewPlugin != mCollectionViewPlugin )
44
hgs
parents: 42
diff changeset
   198
            { 
30
hgs
parents:
diff changeset
   199
                activateView( MpxHbVideoCommon::CollectionView );
hgs
parents:
diff changeset
   200
            }
hgs
parents:
diff changeset
   201
            break;
hgs
parents:
diff changeset
   202
        }
hgs
parents:
diff changeset
   203
        case MpxHbVideoCommon::ActivatePlaybackView:
hgs
parents:
diff changeset
   204
        {
hgs
parents:
diff changeset
   205
            if ( mCurrentViewPlugin != mPlaybackViewPlugin )
44
hgs
parents: 42
diff changeset
   206
            {                
hgs
parents: 42
diff changeset
   207
                activateView( MpxHbVideoCommon::PlaybackView );                
30
hgs
parents:
diff changeset
   208
            }
hgs
parents:
diff changeset
   209
            break;
hgs
parents:
diff changeset
   210
        }
hgs
parents:
diff changeset
   211
        case MpxHbVideoCommon::ActivateVideoDetailsView:
hgs
parents:
diff changeset
   212
        {
hgs
parents:
diff changeset
   213
            if ( mCurrentViewPlugin != mFileDetailsViewPlugin )
37
hgs
parents: 36
diff changeset
   214
            {
44
hgs
parents: 42
diff changeset
   215
                activateView( MpxHbVideoCommon::VideoDetailsView );                
30
hgs
parents:
diff changeset
   216
            }
hgs
parents:
diff changeset
   217
            break;
hgs
parents:
diff changeset
   218
        }
35
hgs
parents: 34
diff changeset
   219
        case MpxHbVideoCommon::DoDelayedLoad:
30
hgs
parents:
diff changeset
   220
        {
37
hgs
parents: 36
diff changeset
   221
            if ( ! mDelayedLoadDone )
hgs
parents: 36
diff changeset
   222
            {
hgs
parents: 36
diff changeset
   223
                doDelayedLoad();
hgs
parents: 36
diff changeset
   224
            }
35
hgs
parents: 34
diff changeset
   225
            break;
hgs
parents: 34
diff changeset
   226
        }
44
hgs
parents: 42
diff changeset
   227
        
30
hgs
parents:
diff changeset
   228
        default:
hgs
parents:
diff changeset
   229
        {
hgs
parents:
diff changeset
   230
            break;
hgs
parents:
diff changeset
   231
        }
44
hgs
parents: 42
diff changeset
   232
    }    
30
hgs
parents:
diff changeset
   233
}
hgs
parents:
diff changeset
   234
hgs
parents:
diff changeset
   235
// -------------------------------------------------------------------------------------------------
49
hgs
parents: 44
diff changeset
   236
// viewReadySlot()
hgs
parents: 44
diff changeset
   237
// -------------------------------------------------------------------------------------------------
hgs
parents: 44
diff changeset
   238
//
hgs
parents: 44
diff changeset
   239
void VideoPlayerEngine::viewReadySlot()
hgs
parents: 44
diff changeset
   240
{
hgs
parents: 44
diff changeset
   241
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::viewReady()"));
hgs
parents: 44
diff changeset
   242
    emit applicationReady();
hgs
parents: 44
diff changeset
   243
    // since we need to emit applicationReady only once at startup,
hgs
parents: 44
diff changeset
   244
    // disconnect the viewReady -signal from this object
hgs
parents: 44
diff changeset
   245
    disconnect(hbInstance->allMainWindows().value(0), SIGNAL(viewReady()), 
hgs
parents: 44
diff changeset
   246
               this, SLOT(viewReadySlot()));
hgs
parents: 44
diff changeset
   247
}
hgs
parents: 44
diff changeset
   248
hgs
parents: 44
diff changeset
   249
// -------------------------------------------------------------------------------------------------
35
hgs
parents: 34
diff changeset
   250
// doDelayedLoad()
hgs
parents: 34
diff changeset
   251
// -------------------------------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   252
//
44
hgs
parents: 42
diff changeset
   253
void VideoPlayerEngine::doDelayedLoad()
35
hgs
parents: 34
diff changeset
   254
{
44
hgs
parents: 42
diff changeset
   255
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::doDelayedLoad()"));
hgs
parents: 42
diff changeset
   256
	
40
hgs
parents: 39
diff changeset
   257
    createMissingViews();
44
hgs
parents: 42
diff changeset
   258
	
37
hgs
parents: 36
diff changeset
   259
    mDelayedLoadDone = true;
35
hgs
parents: 34
diff changeset
   260
}
hgs
parents: 34
diff changeset
   261
hgs
parents: 34
diff changeset
   262
// -------------------------------------------------------------------------------------------------
40
hgs
parents: 39
diff changeset
   263
// createPlaybackView()
36
hgs
parents: 35
diff changeset
   264
// -------------------------------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   265
//
44
hgs
parents: 42
diff changeset
   266
void VideoPlayerEngine::createPlaybackView()
36
hgs
parents: 35
diff changeset
   267
{
40
hgs
parents: 39
diff changeset
   268
    mPlaybackWrapper->lateInit();
44
hgs
parents: 42
diff changeset
   269
       
40
hgs
parents: 39
diff changeset
   270
    if ( ! mPlaybackViewPlugin )
hgs
parents: 39
diff changeset
   271
    {
hgs
parents: 39
diff changeset
   272
       loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
hgs
parents: 39
diff changeset
   273
    }
hgs
parents: 39
diff changeset
   274
}
hgs
parents: 39
diff changeset
   275
hgs
parents: 39
diff changeset
   276
// -------------------------------------------------------------------------------------------------
hgs
parents: 39
diff changeset
   277
// createMissingViews()
hgs
parents: 39
diff changeset
   278
// -------------------------------------------------------------------------------------------------
hgs
parents: 39
diff changeset
   279
//
44
hgs
parents: 42
diff changeset
   280
void VideoPlayerEngine::createMissingViews()
40
hgs
parents: 39
diff changeset
   281
{
44
hgs
parents: 42
diff changeset
   282
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::createMissingViews()"));
hgs
parents: 42
diff changeset
   283
    
37
hgs
parents: 36
diff changeset
   284
    //
hgs
parents: 36
diff changeset
   285
    // delayed initialization of some uiengine member variables
hgs
parents: 36
diff changeset
   286
    // to help application startup time & improve playback start time
hgs
parents: 36
diff changeset
   287
    //
40
hgs
parents: 39
diff changeset
   288
    createPlaybackView();
36
hgs
parents: 35
diff changeset
   289
44
hgs
parents: 42
diff changeset
   290
    if ( ! mFileDetailsViewPlugin )
36
hgs
parents: 35
diff changeset
   291
    {
hgs
parents: 35
diff changeset
   292
        loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );
37
hgs
parents: 36
diff changeset
   293
    }
44
hgs
parents: 42
diff changeset
   294
hgs
parents: 42
diff changeset
   295
    if ( ! mCollectionViewPlugin )
40
hgs
parents: 39
diff changeset
   296
    {
hgs
parents: 39
diff changeset
   297
        loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
hgs
parents: 39
diff changeset
   298
    }
36
hgs
parents: 35
diff changeset
   299
}
hgs
parents: 35
diff changeset
   300
hgs
parents: 35
diff changeset
   301
hgs
parents: 35
diff changeset
   302
// -------------------------------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   303
// activateView()
hgs
parents:
diff changeset
   304
// activate view based on view type.
hgs
parents:
diff changeset
   305
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   306
//
44
hgs
parents: 42
diff changeset
   307
void VideoPlayerEngine::activateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
30
hgs
parents:
diff changeset
   308
{
44
hgs
parents: 42
diff changeset
   309
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::activateView() "),
36
hgs
parents: 35
diff changeset
   310
                   _L("viewType = %d"), viewType );
44
hgs
parents: 42
diff changeset
   311
    	  
30
hgs
parents:
diff changeset
   312
    disconnectView();
44
hgs
parents: 42
diff changeset
   313
    
30
hgs
parents:
diff changeset
   314
    if ( mCurrentViewPlugin )
hgs
parents:
diff changeset
   315
    {
hgs
parents:
diff changeset
   316
        mCurrentViewPlugin->deactivateView();
hgs
parents:
diff changeset
   317
        mCurrentViewPlugin = NULL;
hgs
parents:
diff changeset
   318
    }
hgs
parents:
diff changeset
   319
39
hgs
parents: 38
diff changeset
   320
    switch ( viewType )
30
hgs
parents:
diff changeset
   321
    {
39
hgs
parents: 38
diff changeset
   322
        case MpxHbVideoCommon::CollectionView:
36
hgs
parents: 35
diff changeset
   323
        {
39
hgs
parents: 38
diff changeset
   324
            if ( shouldExit() )
37
hgs
parents: 36
diff changeset
   325
            {
55
hgs
parents: 50
diff changeset
   326
                serviceQuit();
37
hgs
parents: 36
diff changeset
   327
            }
39
hgs
parents: 38
diff changeset
   328
            else if ( shouldActivateCollectionView()  )
hgs
parents: 38
diff changeset
   329
            {
hgs
parents: 38
diff changeset
   330
                if ( ! mCollectionViewPlugin )
hgs
parents: 38
diff changeset
   331
                {
hgs
parents: 38
diff changeset
   332
                    loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
44
hgs
parents: 42
diff changeset
   333
                }            
39
hgs
parents: 38
diff changeset
   334
                mCurrentViewPlugin = mCollectionViewPlugin;
44
hgs
parents: 42
diff changeset
   335
                setCurrentView();                    
39
hgs
parents: 38
diff changeset
   336
            }
44
hgs
parents: 42
diff changeset
   337
            
hgs
parents: 42
diff changeset
   338
            break;    
36
hgs
parents: 35
diff changeset
   339
        }
39
hgs
parents: 38
diff changeset
   340
        case MpxHbVideoCommon::PlaybackView:
hgs
parents: 38
diff changeset
   341
        {
hgs
parents: 38
diff changeset
   342
            if ( ! mPlaybackViewPlugin )
hgs
parents: 38
diff changeset
   343
            {
hgs
parents: 38
diff changeset
   344
                loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
hgs
parents: 38
diff changeset
   345
            }
44
hgs
parents: 42
diff changeset
   346
            
39
hgs
parents: 38
diff changeset
   347
            mCurrentViewPlugin = mPlaybackViewPlugin;
44
hgs
parents: 42
diff changeset
   348
            setCurrentView();     
hgs
parents: 42
diff changeset
   349
            
hgs
parents: 42
diff changeset
   350
            break;    
39
hgs
parents: 38
diff changeset
   351
        }
hgs
parents: 38
diff changeset
   352
        case MpxHbVideoCommon::VideoDetailsView:
hgs
parents: 38
diff changeset
   353
        {
hgs
parents: 38
diff changeset
   354
            if ( ! mFileDetailsViewPlugin )
hgs
parents: 38
diff changeset
   355
            {
44
hgs
parents: 42
diff changeset
   356
                loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );  
39
hgs
parents: 38
diff changeset
   357
            }
44
hgs
parents: 42
diff changeset
   358
            
39
hgs
parents: 38
diff changeset
   359
            mCurrentViewPlugin = mFileDetailsViewPlugin;
44
hgs
parents: 42
diff changeset
   360
            setCurrentView();       
hgs
parents: 42
diff changeset
   361
            
hgs
parents: 42
diff changeset
   362
            break;    
hgs
parents: 42
diff changeset
   363
        }        
hgs
parents: 42
diff changeset
   364
    }    
30
hgs
parents:
diff changeset
   365
}
hgs
parents:
diff changeset
   366
hgs
parents:
diff changeset
   367
// -------------------------------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   368
// loadPluginAndCreateView()
30
hgs
parents:
diff changeset
   369
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   370
//
44
hgs
parents: 42
diff changeset
   371
void VideoPlayerEngine::loadPluginAndCreateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
30
hgs
parents:
diff changeset
   372
{
44
hgs
parents: 42
diff changeset
   373
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::loadPluginAndCreateView() "), 
36
hgs
parents: 35
diff changeset
   374
                   _L("viewType = %d"), viewType );
44
hgs
parents: 42
diff changeset
   375
	  
30
hgs
parents:
diff changeset
   376
    int viewTypeUid( 0 );
hgs
parents:
diff changeset
   377
44
hgs
parents: 42
diff changeset
   378
    if ( viewType == MpxHbVideoCommon::CollectionView ) 
30
hgs
parents:
diff changeset
   379
    {
hgs
parents:
diff changeset
   380
        viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllCollectionUid;
hgs
parents:
diff changeset
   381
    }
44
hgs
parents: 42
diff changeset
   382
    else if ( viewType == MpxHbVideoCommon::PlaybackView ) 
30
hgs
parents:
diff changeset
   383
    {
hgs
parents:
diff changeset
   384
        viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllPlaybackUid;
hgs
parents:
diff changeset
   385
    }
37
hgs
parents: 36
diff changeset
   386
    else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
30
hgs
parents:
diff changeset
   387
    {
hgs
parents:
diff changeset
   388
        viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllFileDetailsUid;
hgs
parents:
diff changeset
   389
    }
hgs
parents:
diff changeset
   390
hgs
parents:
diff changeset
   391
    if ( viewTypeUid )
hgs
parents:
diff changeset
   392
    {
44
hgs
parents: 42
diff changeset
   393
        // 
37
hgs
parents: 36
diff changeset
   394
        // load corresponding plug-in
hgs
parents: 36
diff changeset
   395
        //
30
hgs
parents:
diff changeset
   396
        XQPluginLoader pluginLoader( viewTypeUid );
hgs
parents:
diff changeset
   397
        QObject* instance = pluginLoader.instance();
hgs
parents:
diff changeset
   398
hgs
parents:
diff changeset
   399
        if ( instance )
hgs
parents:
diff changeset
   400
        {
36
hgs
parents: 35
diff changeset
   401
            MpxViewPlugin *currentViewPlugin = NULL;
hgs
parents: 35
diff changeset
   402
44
hgs
parents: 42
diff changeset
   403
            if ( viewType == MpxHbVideoCommon::CollectionView ) 
30
hgs
parents:
diff changeset
   404
            {
hgs
parents:
diff changeset
   405
                mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
36
hgs
parents: 35
diff changeset
   406
                currentViewPlugin = mCollectionViewPlugin;
30
hgs
parents:
diff changeset
   407
            }
hgs
parents:
diff changeset
   408
            else if ( viewType == MpxHbVideoCommon::PlaybackView )
hgs
parents:
diff changeset
   409
            {
hgs
parents:
diff changeset
   410
                mPlaybackViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
36
hgs
parents: 35
diff changeset
   411
                currentViewPlugin = mPlaybackViewPlugin;
30
hgs
parents:
diff changeset
   412
            }
hgs
parents:
diff changeset
   413
            else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
hgs
parents:
diff changeset
   414
            {
hgs
parents:
diff changeset
   415
                mFileDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
36
hgs
parents: 35
diff changeset
   416
                currentViewPlugin = mFileDetailsViewPlugin;
30
hgs
parents:
diff changeset
   417
            }
36
hgs
parents: 35
diff changeset
   418
            else
hgs
parents: 35
diff changeset
   419
            {
44
hgs
parents: 42
diff changeset
   420
                MPX_DEBUG(_L("VideoPlayerEngine::loadPluginAndCreateView() : plugin not FOUND ! "));                
36
hgs
parents: 35
diff changeset
   421
            }
44
hgs
parents: 42
diff changeset
   422
            
37
hgs
parents: 36
diff changeset
   423
            //
hgs
parents: 36
diff changeset
   424
            // create corresponding view
hgs
parents: 36
diff changeset
   425
            //
44
hgs
parents: 42
diff changeset
   426
            if ( currentViewPlugin ) 
36
hgs
parents: 35
diff changeset
   427
            {
hgs
parents: 35
diff changeset
   428
                QGraphicsWidget *view = currentViewPlugin->getView();
44
hgs
parents: 42
diff changeset
   429
          
36
hgs
parents: 35
diff changeset
   430
                if ( ! view )
hgs
parents: 35
diff changeset
   431
                {
44
hgs
parents: 42
diff changeset
   432
                    MPX_DEBUG(_L("VideoPlayerEngine::loadPluginAndCreateView() : create view "));
hgs
parents: 42
diff changeset
   433
                    
36
hgs
parents: 35
diff changeset
   434
                    currentViewPlugin->createView();
hgs
parents: 35
diff changeset
   435
                    hbInstance->allMainWindows().value(0)->addView( currentViewPlugin->getView() );
hgs
parents: 35
diff changeset
   436
                }
hgs
parents: 35
diff changeset
   437
                else
hgs
parents: 35
diff changeset
   438
                {
44
hgs
parents: 42
diff changeset
   439
                    MPX_DEBUG(_L("VideoPlayerEngine::loadPluginAndCreateView() : view has already been created! "));                    
36
hgs
parents: 35
diff changeset
   440
                }
hgs
parents: 35
diff changeset
   441
            }
hgs
parents: 35
diff changeset
   442
            else
hgs
parents: 35
diff changeset
   443
            {
44
hgs
parents: 42
diff changeset
   444
                MPX_DEBUG(_L("VideoPlayerEngine::loadPluginAndCreateView() : currentViewPlugin is NULL! "));                    
hgs
parents: 42
diff changeset
   445
            }            
30
hgs
parents:
diff changeset
   446
        }
hgs
parents:
diff changeset
   447
    }
hgs
parents:
diff changeset
   448
}
hgs
parents:
diff changeset
   449
hgs
parents:
diff changeset
   450
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   451
// connectView()
hgs
parents:
diff changeset
   452
// connect application to view by setting up the signals and slots.
hgs
parents:
diff changeset
   453
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   454
//
44
hgs
parents: 42
diff changeset
   455
void VideoPlayerEngine::connectView()
30
hgs
parents:
diff changeset
   456
{
44
hgs
parents: 42
diff changeset
   457
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::connectView()"));
hgs
parents: 42
diff changeset
   458
	  
30
hgs
parents:
diff changeset
   459
    connect( mCurrentViewPlugin,
hgs
parents:
diff changeset
   460
             SIGNAL( command( int ) ),
hgs
parents:
diff changeset
   461
             this,
hgs
parents:
diff changeset
   462
             SLOT( handleCommand( int ) ) );
hgs
parents:
diff changeset
   463
}
hgs
parents:
diff changeset
   464
hgs
parents:
diff changeset
   465
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   466
// disconnectView()
hgs
parents:
diff changeset
   467
// connect application to view by setting up the signals and slots.
hgs
parents:
diff changeset
   468
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   469
//
44
hgs
parents: 42
diff changeset
   470
void VideoPlayerEngine::disconnectView()
30
hgs
parents:
diff changeset
   471
{
44
hgs
parents: 42
diff changeset
   472
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::disconnectView()"));
hgs
parents: 42
diff changeset
   473
	  
30
hgs
parents:
diff changeset
   474
    if ( mCurrentViewPlugin )
hgs
parents:
diff changeset
   475
    {
hgs
parents:
diff changeset
   476
        disconnect( mCurrentViewPlugin,
hgs
parents:
diff changeset
   477
                    SIGNAL( command( int ) ),
hgs
parents:
diff changeset
   478
                    this,
44
hgs
parents: 42
diff changeset
   479
                    SLOT( handleCommand( int ) ) );   
30
hgs
parents:
diff changeset
   480
    }
hgs
parents:
diff changeset
   481
}
hgs
parents:
diff changeset
   482
hgs
parents:
diff changeset
   483
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   484
// handleQuit()
hgs
parents:
diff changeset
   485
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   486
//
44
hgs
parents: 42
diff changeset
   487
void VideoPlayerEngine::handleQuit()
30
hgs
parents:
diff changeset
   488
{
44
hgs
parents: 42
diff changeset
   489
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::handleQuit()"));
hgs
parents: 42
diff changeset
   490
	
hgs
parents: 42
diff changeset
   491
    if ( ! mIsService )
40
hgs
parents: 39
diff changeset
   492
    {
hgs
parents: 39
diff changeset
   493
        VideoActivityState &localActivity(VideoActivityState::instance());
44
hgs
parents: 42
diff changeset
   494
            
40
hgs
parents: 39
diff changeset
   495
        QVariant data = QVariant();
hgs
parents: 39
diff changeset
   496
        HbActivityManager *actManager = qobject_cast<HbApplication*>(qApp)->activityManager();
44
hgs
parents: 42
diff changeset
   497
        
40
hgs
parents: 39
diff changeset
   498
        //
44
hgs
parents: 42
diff changeset
   499
        // deactivate is the final point for current plugin to save it's activity data into 
41
hgs
parents: 40
diff changeset
   500
        // VideoActivityState before they are saved to to activity manager
hgs
parents: 40
diff changeset
   501
        //
44
hgs
parents: 42
diff changeset
   502
        mCurrentViewPlugin->deactivateView();        
hgs
parents: 42
diff changeset
   503
        
41
hgs
parents: 40
diff changeset
   504
        //
40
hgs
parents: 39
diff changeset
   505
        // get and save recent view type: either playback or collection view plugins are currently used.
hgs
parents: 39
diff changeset
   506
        // activity will not be saved from the details plugin
hgs
parents: 39
diff changeset
   507
        //
hgs
parents: 39
diff changeset
   508
        int viewType = MpxHbVideoCommon::CollectionView;
44
hgs
parents: 42
diff changeset
   509
hgs
parents: 42
diff changeset
   510
        if ( mCurrentViewPlugin == mPlaybackViewPlugin )
40
hgs
parents: 39
diff changeset
   511
        {
41
hgs
parents: 40
diff changeset
   512
            // for playback view, the state preservation and restoration should only be done
hgs
parents: 40
diff changeset
   513
            // for loacl clips (non-streaming) - so set KEY_VIEWPLUGIN_TYPE to PlaybackView only
hgs
parents: 40
diff changeset
   514
            // for local clips. Otherwise the default value CollectionView should be set.
hgs
parents: 40
diff changeset
   515
            //
44
hgs
parents: 42
diff changeset
   516
            QVariant playdata = VideoActivityState::instance().getActivityData( KEY_LAST_LOCAL_PLAYBACK );
hgs
parents: 42
diff changeset
   517
41
hgs
parents: 40
diff changeset
   518
            if  ( playdata.toBool() )
hgs
parents: 40
diff changeset
   519
            {
hgs
parents: 40
diff changeset
   520
                viewType = MpxHbVideoCommon::PlaybackView;
44
hgs
parents: 42
diff changeset
   521
            }            
40
hgs
parents: 39
diff changeset
   522
        }
44
hgs
parents: 42
diff changeset
   523
        
41
hgs
parents: 40
diff changeset
   524
        data = viewType;
44
hgs
parents: 42
diff changeset
   525
        localActivity.setActivityData( data, KEY_VIEWPLUGIN_TYPE );
hgs
parents: 42
diff changeset
   526
        
40
hgs
parents: 39
diff changeset
   527
        // save data to activity manager
44
hgs
parents: 42
diff changeset
   528
        actManager->addActivity( ACTIVITY_VIDEOPLAYER_MAINVIEW, 
hgs
parents: 42
diff changeset
   529
                                 localActivity.getActivityData(),
hgs
parents: 42
diff changeset
   530
                                 QVariantHash() );                
40
hgs
parents: 39
diff changeset
   531
    }
44
hgs
parents: 42
diff changeset
   532
    
30
hgs
parents:
diff changeset
   533
    delete this;
hgs
parents:
diff changeset
   534
}
hgs
parents:
diff changeset
   535
hgs
parents:
diff changeset
   536
hgs
parents:
diff changeset
   537
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   538
// playMedia()
hgs
parents:
diff changeset
   539
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   540
//
44
hgs
parents: 42
diff changeset
   541
void VideoPlayerEngine::playMedia( QString filePath )
30
hgs
parents:
diff changeset
   542
{
44
hgs
parents: 42
diff changeset
   543
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::playMedia()"),
hgs
parents: 42
diff changeset
   544
                   _L("filePath = %s"), filePath.data() );  
hgs
parents: 42
diff changeset
   545
	  	
50
hgs
parents: 49
diff changeset
   546
    int result = mPlaybackWrapper->playMedia( filePath );
hgs
parents: 49
diff changeset
   547
    
hgs
parents: 49
diff changeset
   548
    if ( result != KErrNone )
hgs
parents: 49
diff changeset
   549
    {
hgs
parents: 49
diff changeset
   550
        handlePlaybackFailure(result);                       
hgs
parents: 49
diff changeset
   551
    }
hgs
parents: 49
diff changeset
   552
}
hgs
parents: 49
diff changeset
   553
hgs
parents: 49
diff changeset
   554
// -------------------------------------------------------------------------------------------------
hgs
parents: 49
diff changeset
   555
// playURI()
hgs
parents: 49
diff changeset
   556
// -------------------------------------------------------------------------------------------------
hgs
parents: 49
diff changeset
   557
//
hgs
parents: 49
diff changeset
   558
void VideoPlayerEngine::playURI( QString uri )
hgs
parents: 49
diff changeset
   559
{
hgs
parents: 49
diff changeset
   560
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::playURI()"),
hgs
parents: 49
diff changeset
   561
                   _L("uri = %s"), uri.data() );  
hgs
parents: 49
diff changeset
   562
	  	
hgs
parents: 49
diff changeset
   563
    int result = mPlaybackWrapper->playURI( uri );
hgs
parents: 49
diff changeset
   564
    
hgs
parents: 49
diff changeset
   565
    if ( result != KErrNone )
hgs
parents: 49
diff changeset
   566
    {
hgs
parents: 49
diff changeset
   567
        handlePlaybackFailure(result);                       
hgs
parents: 49
diff changeset
   568
    }    
30
hgs
parents:
diff changeset
   569
}
hgs
parents:
diff changeset
   570
hgs
parents:
diff changeset
   571
// -------------------------------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   572
// playMedia()
hgs
parents: 35
diff changeset
   573
// -------------------------------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   574
//
44
hgs
parents: 42
diff changeset
   575
void VideoPlayerEngine::playMedia( RFile file )
36
hgs
parents: 35
diff changeset
   576
{
44
hgs
parents: 42
diff changeset
   577
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::playMedia( RFile )")); 
hgs
parents: 42
diff changeset
   578
        
50
hgs
parents: 49
diff changeset
   579
    int result = mPlaybackWrapper->playMedia( file );   
hgs
parents: 49
diff changeset
   580
    
hgs
parents: 49
diff changeset
   581
    if ( result != KErrNone )
hgs
parents: 49
diff changeset
   582
    {
hgs
parents: 49
diff changeset
   583
        handlePlaybackFailure(result);                        
hgs
parents: 49
diff changeset
   584
    }    
36
hgs
parents: 35
diff changeset
   585
}
hgs
parents: 35
diff changeset
   586
hgs
parents: 35
diff changeset
   587
// -------------------------------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   588
// setEmbedded()
hgs
parents:
diff changeset
   589
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   590
//
44
hgs
parents: 42
diff changeset
   591
void VideoPlayerEngine::setEmbedded()
30
hgs
parents:
diff changeset
   592
{
44
hgs
parents: 42
diff changeset
   593
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::setEmbedded()")); 
hgs
parents: 42
diff changeset
   594
	  
30
hgs
parents:
diff changeset
   595
    mEmbedded = true;
hgs
parents:
diff changeset
   596
}
hgs
parents:
diff changeset
   597
36
hgs
parents: 35
diff changeset
   598
// -------------------------------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   599
// setCurrentView()
hgs
parents: 35
diff changeset
   600
// -------------------------------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   601
//
44
hgs
parents: 42
diff changeset
   602
void VideoPlayerEngine::setCurrentView()
36
hgs
parents: 35
diff changeset
   603
{
44
hgs
parents: 42
diff changeset
   604
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::setCurrentView()")); 
hgs
parents: 42
diff changeset
   605
	
36
hgs
parents: 35
diff changeset
   606
    if ( mCurrentViewPlugin )
hgs
parents: 35
diff changeset
   607
    {
hgs
parents: 35
diff changeset
   608
        //
hgs
parents: 35
diff changeset
   609
        // set current view
hgs
parents: 35
diff changeset
   610
        //
44
hgs
parents: 42
diff changeset
   611
        hbInstance->allMainWindows().value(0)->setCurrentView( 
36
hgs
parents: 35
diff changeset
   612
		                            qobject_cast<HbView*>( mCurrentViewPlugin->getView() ), false );
hgs
parents: 35
diff changeset
   613
hgs
parents: 35
diff changeset
   614
        //
hgs
parents: 35
diff changeset
   615
        // connect view
hgs
parents: 35
diff changeset
   616
        //
hgs
parents: 35
diff changeset
   617
        connectView();
hgs
parents: 35
diff changeset
   618
44
hgs
parents: 42
diff changeset
   619
        // 
36
hgs
parents: 35
diff changeset
   620
        // activate view
hgs
parents: 35
diff changeset
   621
        //
hgs
parents: 35
diff changeset
   622
        mCurrentViewPlugin->activateView();
hgs
parents: 35
diff changeset
   623
    }
hgs
parents: 35
diff changeset
   624
}
hgs
parents: 35
diff changeset
   625
38
hgs
parents: 37
diff changeset
   626
// -------------------------------------------------------------------------------------------------
hgs
parents: 37
diff changeset
   627
// isPlayServiceInvoked()
hgs
parents: 37
diff changeset
   628
// -------------------------------------------------------------------------------------------------
hgs
parents: 37
diff changeset
   629
//
44
hgs
parents: 42
diff changeset
   630
bool VideoPlayerEngine::isPlayServiceInvoked()
38
hgs
parents: 37
diff changeset
   631
{
44
hgs
parents: 42
diff changeset
   632
    MPX_ENTER_EXIT(_L("VideoPlayerEngine::isPlayServiceInvoked()"));       
hgs
parents: 42
diff changeset
   633
    
hgs
parents: 42
diff changeset
   634
    bool result = false;   
hgs
parents: 42
diff changeset
   635
    
38
hgs
parents: 37
diff changeset
   636
    if ( mIsService )
hgs
parents: 37
diff changeset
   637
    {
hgs
parents: 37
diff changeset
   638
        QString intface = XQServiceUtil::interfaceName();
44
hgs
parents: 42
diff changeset
   639
        MPX_DEBUG(_L("VideoPlayerEngine::isPlayServiceInvoked() : interfaceName(%s)"), intface.data() );     
hgs
parents: 42
diff changeset
   640
                        
38
hgs
parents: 37
diff changeset
   641
        if ( intface.contains("IVideoView") ||
50
hgs
parents: 49
diff changeset
   642
             intface.contains("IFileView")  ||
hgs
parents: 49
diff changeset
   643
             intface.contains("IUriView"))
38
hgs
parents: 37
diff changeset
   644
        {
hgs
parents: 37
diff changeset
   645
            result = true;
hgs
parents: 37
diff changeset
   646
            mIsPlayService = true;
hgs
parents: 37
diff changeset
   647
        }
hgs
parents: 37
diff changeset
   648
    }
44
hgs
parents: 42
diff changeset
   649
    
hgs
parents: 42
diff changeset
   650
    MPX_DEBUG(_L("VideoPlayerEngine::isPlayServiceInvoked() return %d"), result);     
38
hgs
parents: 37
diff changeset
   651
    return result;
hgs
parents: 37
diff changeset
   652
}
36
hgs
parents: 35
diff changeset
   653
39
hgs
parents: 38
diff changeset
   654
// -------------------------------------------------------------------------------------------------
hgs
parents: 38
diff changeset
   655
// shouldExit()
hgs
parents: 38
diff changeset
   656
// -------------------------------------------------------------------------------------------------
hgs
parents: 38
diff changeset
   657
//
44
hgs
parents: 42
diff changeset
   658
bool VideoPlayerEngine::shouldExit()
hgs
parents: 42
diff changeset
   659
{            
39
hgs
parents: 38
diff changeset
   660
    bool result = false;
44
hgs
parents: 42
diff changeset
   661
    
39
hgs
parents: 38
diff changeset
   662
    if ( mIsPlayService )  // play or view service
hgs
parents: 38
diff changeset
   663
    {
44
hgs
parents: 42
diff changeset
   664
        result = true;               
39
hgs
parents: 38
diff changeset
   665
    }
44
hgs
parents: 42
diff changeset
   666
    
hgs
parents: 42
diff changeset
   667
    MPX_DEBUG(_L("VideoPlayerEngine::shouldExit() return %d"), result);     
hgs
parents: 42
diff changeset
   668
    
39
hgs
parents: 38
diff changeset
   669
    return result;
hgs
parents: 38
diff changeset
   670
}
hgs
parents: 38
diff changeset
   671
hgs
parents: 38
diff changeset
   672
hgs
parents: 38
diff changeset
   673
// -------------------------------------------------------------------------------------------------
hgs
parents: 38
diff changeset
   674
// shouldActivateCollectionView()
hgs
parents: 38
diff changeset
   675
// -------------------------------------------------------------------------------------------------
hgs
parents: 38
diff changeset
   676
//
44
hgs
parents: 42
diff changeset
   677
bool VideoPlayerEngine::shouldActivateCollectionView()
hgs
parents: 42
diff changeset
   678
{            
hgs
parents: 42
diff changeset
   679
    bool result = true;  
hgs
parents: 42
diff changeset
   680
    
hgs
parents: 42
diff changeset
   681
    //
39
hgs
parents: 38
diff changeset
   682
    // the only case where collection view should NOT be activated is ...
44
hgs
parents: 42
diff changeset
   683
    // if we are in service and that service is fetch and if fetch is selected, 
39
hgs
parents: 38
diff changeset
   684
    // in all other cases collection view should be activated
44
hgs
parents: 42
diff changeset
   685
    //
39
hgs
parents: 38
diff changeset
   686
    if ( mIsService &&
hgs
parents: 38
diff changeset
   687
         mVideoServices->currentService() == VideoServices::EUriFetcher &&
hgs
parents: 38
diff changeset
   688
         mVideoServices->mFetchSelected  )
hgs
parents: 38
diff changeset
   689
    {
44
hgs
parents: 42
diff changeset
   690
        result = false;                    
hgs
parents: 42
diff changeset
   691
    }  
hgs
parents: 42
diff changeset
   692
        
hgs
parents: 42
diff changeset
   693
    MPX_DEBUG(_L("VideoPlayerEngine::shouldActivateCollectionView() return %d"), result);     
hgs
parents: 42
diff changeset
   694
    
39
hgs
parents: 38
diff changeset
   695
    return result;
hgs
parents: 38
diff changeset
   696
}
hgs
parents: 38
diff changeset
   697
50
hgs
parents: 49
diff changeset
   698
hgs
parents: 49
diff changeset
   699
// -------------------------------------------------------------------------------------------------
hgs
parents: 49
diff changeset
   700
// handlePlaybackFailure()
hgs
parents: 49
diff changeset
   701
// -------------------------------------------------------------------------------------------------
hgs
parents: 49
diff changeset
   702
//
hgs
parents: 49
diff changeset
   703
void VideoPlayerEngine::handlePlaybackFailure(int errorCode)
hgs
parents: 49
diff changeset
   704
{                    
hgs
parents: 49
diff changeset
   705
    MPX_DEBUG(_L("VideoPlayerEngine::handlePlaybackFailure()"));        
hgs
parents: 49
diff changeset
   706
            
hgs
parents: 49
diff changeset
   707
    if ( mIsPlayService )  
hgs
parents: 49
diff changeset
   708
    { 
55
hgs
parents: 50
diff changeset
   709
        HbNotificationDialog* dlg = new HbNotificationDialog();
hgs
parents: 50
diff changeset
   710
        
hgs
parents: 50
diff changeset
   711
        connect( dlg, SIGNAL( aboutToClose() ), this, SLOT( serviceQuit() ) );
50
hgs
parents: 49
diff changeset
   712
        
hgs
parents: 49
diff changeset
   713
        switch ( errorCode )
hgs
parents: 49
diff changeset
   714
        {
hgs
parents: 49
diff changeset
   715
            case KErrNotSupported:
hgs
parents: 49
diff changeset
   716
            case KErrUnknown:
hgs
parents: 49
diff changeset
   717
            case KErrCorrupt:
hgs
parents: 49
diff changeset
   718
            case KErrTooBig:
hgs
parents: 49
diff changeset
   719
            {
hgs
parents: 49
diff changeset
   720
                dlg->setTitle( hbTrId( "txt_videos_info_invalid_clip_operation_canceled" ) );
hgs
parents: 49
diff changeset
   721
                break;
hgs
parents: 49
diff changeset
   722
            }
hgs
parents: 49
diff changeset
   723
            case KErrArgument:
hgs
parents: 49
diff changeset
   724
            case KErrBadName:
hgs
parents: 49
diff changeset
   725
            {
hgs
parents: 49
diff changeset
   726
                dlg->setTitle( hbTrId( "txt_videos_info_unable_to_connect_invalid_url" ) );
hgs
parents: 49
diff changeset
   727
                break;
hgs
parents: 49
diff changeset
   728
            }  
hgs
parents: 49
diff changeset
   729
            case KErrNotFound:
hgs
parents: 49
diff changeset
   730
            {
hgs
parents: 49
diff changeset
   731
                dlg->setTitle( hbTrId( "txt_videos_info_file_not_found" ) );
hgs
parents: 49
diff changeset
   732
                break;
hgs
parents: 49
diff changeset
   733
            } 
hgs
parents: 49
diff changeset
   734
            default:
hgs
parents: 49
diff changeset
   735
            {
hgs
parents: 49
diff changeset
   736
                const QString textToShow = mPlaybackWrapper->resloveErrorString(errorCode);
hgs
parents: 49
diff changeset
   737
                dlg->setTitle(textToShow);
hgs
parents: 49
diff changeset
   738
                break;
hgs
parents: 49
diff changeset
   739
            }
hgs
parents: 49
diff changeset
   740
        }
hgs
parents: 49
diff changeset
   741
        
hgs
parents: 49
diff changeset
   742
        dlg->show();                      
55
hgs
parents: 50
diff changeset
   743
 
50
hgs
parents: 49
diff changeset
   744
    }
hgs
parents: 49
diff changeset
   745
}
55
hgs
parents: 50
diff changeset
   746
hgs
parents: 50
diff changeset
   747
hgs
parents: 50
diff changeset
   748
// -------------------------------------------------------------------------------------------------
hgs
parents: 50
diff changeset
   749
// serviceQuit()
hgs
parents: 50
diff changeset
   750
// -------------------------------------------------------------------------------------------------
hgs
parents: 50
diff changeset
   751
//
hgs
parents: 50
diff changeset
   752
void VideoPlayerEngine::serviceQuit()
hgs
parents: 50
diff changeset
   753
{                    
hgs
parents: 50
diff changeset
   754
    MPX_DEBUG(_L("VideoPlayerEngine::serviceQuit()"));     
hgs
parents: 50
diff changeset
   755
    
hgs
parents: 50
diff changeset
   756
    qApp->quit();
hgs
parents: 50
diff changeset
   757
    XQServiceUtil::toBackground( false );
hgs
parents: 50
diff changeset
   758
}
hgs
parents: 50
diff changeset
   759
hgs
parents: 50
diff changeset
   760
30
hgs
parents:
diff changeset
   761
// End of file