videoplayback/hbvideoplaybackview/viewsrc/hbvideobaseplaybackview.cpp
changeset 38 ff53afa8ad05
parent 37 4eb2df7f7cbe
child 40 13331705e488
--- a/videoplayback/hbvideoplaybackview/viewsrc/hbvideobaseplaybackview.cpp	Fri Apr 30 09:52:11 2010 +0300
+++ b/videoplayback/hbvideoplaybackview/viewsrc/hbvideobaseplaybackview.cpp	Fri May 14 15:14:51 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: da1mmcf#38 %
+// Version : %version: da1mmcf#40 %
 
 
 
@@ -116,9 +116,11 @@
 void HbVideoBasePlaybackView::handleActivateView()
 {
     MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleActivateView()"));
-    
+
     TRAP_IGNORE( mVideoMpxWrapper = CMPXVideoViewWrapper::NewL( this ) ); 
-    
+
+    QCoreApplication::instance()->installEventFilter( this );
+
     //
     //  Request the needed Media from the Playback Plugin
     //
@@ -128,11 +130,12 @@
 
     //
     // Landscape orientation
-    //
-    hbInstance->allMainWindows()[0]->setOrientation( Qt::Horizontal );  
+    // Workaround: Disable orientation transition effect 
+	// since orbit couldn't emit the orientationChanged signal with transition effect
+	// 
+    hbInstance->allMainWindows()[0]->setOrientation( Qt::Horizontal, false );  
 
     mActivated = true;   
-       
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -143,6 +146,8 @@
 {
     MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleDeactivateView()"));
 
+    QCoreApplication::instance()->removeEventFilter( this );
+
     mActivated = false;
 
     // 
@@ -306,7 +311,11 @@
 void HbVideoBasePlaybackView::issuePlayCommand()
 {
     MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::issuePlayCommand()"));
-    TRAPD(err, mVideoMpxWrapper->CreateGeneralPlaybackCommandL( EPbCmdPlay ));
+
+    int err = KErrNone;
+
+    TRAP( err, mVideoMpxWrapper->CreateGeneralPlaybackCommandL( EPbCmdPlay ));
+
     MPX_DEBUG(_L("HbVideoBasePlaybackView::issuePlayCommand() error = %d"), err);
 }
 
@@ -326,7 +335,6 @@
 void HbVideoBasePlaybackView::handleBufferingState()
 {
     MPX_DEBUG(_L("HbVideoBasePlaybackView::handleBufferingState()"));
-
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -340,28 +348,37 @@
     mTimerForClosingView->start( 0 );    
 }
 
-// -------------------------------------------------------------------------------------------------
-//   HbVideoBasePlaybackView::event()
-// -------------------------------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// HbVideoBasePlaybackView::eventFilter
+// ---------------------------------------------------------------------------
 //
-bool HbVideoBasePlaybackView::event( QEvent *event )
+bool HbVideoBasePlaybackView::eventFilter( QObject *object, QEvent *event )
 {
-    bool consumed = false;
+    Q_UNUSED( object );
 
-    if ( event->type() == QEvent::WindowActivate && mActivated )
+    switch ( event->type() )
     {
-        TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( true ) );
-    }
-    else if ( event->type() == QEvent::WindowDeactivate && mActivated )
-    {
-        TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( false ) );
-    }
-    else
-    {
-         consumed = QGraphicsWidget::event( event );
+        case QEvent::ApplicationActivate:
+        {
+            if ( mActivated )
+            {
+                MPX_DEBUG(_L("HbVideoBasePlaybackView::eventFilter foreground()") );
+                TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( true ) );
+            }
+            break;
+        }
+        case QEvent::ApplicationDeactivate:
+        {
+            if ( mActivated )
+            {
+                MPX_DEBUG(_L("HbVideoBasePlaybackView::eventFilter background()") );
+                TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( false ) );
+            }
+            break;
+        }
     }
 
-    return consumed;
+    return QObject::eventFilter( object, event );
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -409,5 +426,4 @@
     handleClosePlaybackView();
 }
 
-
 // EOF