videoplayerapp/videoplayerengine/src/videoplayerengine.cpp
changeset 50 21fe8338c6bf
parent 49 824471cb468a
child 55 4bfa887905cf
--- a/videoplayerapp/videoplayerengine/src/videoplayerengine.cpp	Fri Jul 23 11:10:06 2010 +0300
+++ b/videoplayerapp/videoplayerengine/src/videoplayerengine.cpp	Fri Aug 06 09:43:48 2010 +0300
@@ -15,7 +15,7 @@
 *
 */
 
-// Version : %version: 40 %
+// Version : %version: da1mmcf#42 %
 
 
 #include <QApplication>
@@ -27,6 +27,7 @@
 #include <hbview.h>
 #include <hbapplication.h>
 #include <hbactivitymanager.h>
+#include <hbdevicenotificationdialog.h>
 
 #include "videoplayerengine.h"
 #include "videoactivitystate.h"
@@ -543,7 +544,29 @@
     MPX_ENTER_EXIT(_L("VideoPlayerEngine::playMedia()"),
                    _L("filePath = %s"), filePath.data() );  
 	  	
-    mPlaybackWrapper->playMedia( filePath );
+    int result = mPlaybackWrapper->playMedia( filePath );
+    
+    if ( result != KErrNone )
+    {
+        handlePlaybackFailure(result);                       
+    }
+}
+
+// -------------------------------------------------------------------------------------------------
+// playURI()
+// -------------------------------------------------------------------------------------------------
+//
+void VideoPlayerEngine::playURI( QString uri )
+{
+    MPX_ENTER_EXIT(_L("VideoPlayerEngine::playURI()"),
+                   _L("uri = %s"), uri.data() );  
+	  	
+    int result = mPlaybackWrapper->playURI( uri );
+    
+    if ( result != KErrNone )
+    {
+        handlePlaybackFailure(result);                       
+    }    
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -554,7 +577,12 @@
 {
     MPX_ENTER_EXIT(_L("VideoPlayerEngine::playMedia( RFile )")); 
         
-    mPlaybackWrapper->playMedia( file );    
+    int result = mPlaybackWrapper->playMedia( file );   
+    
+    if ( result != KErrNone )
+    {
+        handlePlaybackFailure(result);                        
+    }    
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -612,7 +640,8 @@
         MPX_DEBUG(_L("VideoPlayerEngine::isPlayServiceInvoked() : interfaceName(%s)"), intface.data() );     
                         
         if ( intface.contains("IVideoView") ||
-             intface.contains("IFileView") )
+             intface.contains("IFileView")  ||
+             intface.contains("IUriView"))
         {
             result = true;
             mIsPlayService = true;
@@ -667,4 +696,53 @@
     return result;
 }
 
+
+// -------------------------------------------------------------------------------------------------
+// handlePlaybackFailure()
+// -------------------------------------------------------------------------------------------------
+//
+void VideoPlayerEngine::handlePlaybackFailure(int errorCode)
+{                    
+    MPX_DEBUG(_L("VideoPlayerEngine::handlePlaybackFailure()"));        
+            
+    if ( mIsPlayService )  
+    { 
+        HbDeviceNotificationDialog* dlg = new HbDeviceNotificationDialog(); 
+        
+        switch ( errorCode )
+        {
+            case KErrNotSupported:
+            case KErrUnknown:
+            case KErrCorrupt:
+            case KErrTooBig:
+            {
+                dlg->setTitle( hbTrId( "txt_videos_info_invalid_clip_operation_canceled" ) );
+                break;
+            }
+            case KErrArgument:
+            case KErrBadName:
+            {
+                dlg->setTitle( hbTrId( "txt_videos_info_unable_to_connect_invalid_url" ) );
+                break;
+            }  
+            case KErrNotFound:
+            {
+                dlg->setTitle( hbTrId( "txt_videos_info_file_not_found" ) );
+                break;
+            } 
+            default:
+            {
+                const QString textToShow = mPlaybackWrapper->resloveErrorString(errorCode);
+                dlg->setTitle(textToShow);
+                break;
+            }
+        }
+        
+        dlg->show();                      
+        
+        
+        qApp->quit();
+        XQServiceUtil::toBackground( false );  
+    }
+}
 // End of file