[TIZENIOT-2414] Resume file form last played 53/254353/1 submit/tizen/20210302.074701 submit/tizen/20210310.071817
authoraman.jeph <aman.jeph@samsung.com>
Mon, 1 Mar 2021 07:36:29 +0000 (13:06 +0530)
committeraman.jeph <aman.jeph@samsung.com>
Mon, 1 Mar 2021 07:36:29 +0000 (13:06 +0530)
Change-Id: I1c1a4bf7829cb2031baffd4ef326b12835f0b184
Signed-off-by: aman.jeph <aman.jeph@samsung.com>
vp-main/src/vp-main.c

index 4dbe234e7befc3ebd10968f2d537e834d32a9937..0eaaf883181613ba0c87d33a366ea0db53a6fac7 100755 (executable)
@@ -21,6 +21,7 @@
 #include "vp-service-parser.h"
 #include "vp-play-log.h"
 #include "vp-play-view.h"
+#include "vp-playtime-db.h"
 
 static void __appResume(void *pUserData);
 
@@ -82,6 +83,31 @@ static bool __appCreate(void *pUserData)
        return TRUE;
 }
 
+static int _sqlite_table_data_cb(void *user_data, int count, char **col_data, char **colums) {
+       int *nPosition = (int*)user_data;
+       for(int i = 0; i<count; ++i) {
+               if(col_data[i]) {
+                       int current_duration = atoi(col_data[i]);
+                       if(current_duration <= 5000){
+                               *nPosition = 0;
+                       } else {
+                               *nPosition = current_duration - 5000;
+                       }
+               }
+       }
+       //always return zero , otherwise sqlite3_exec will abort the subsequent statements
+       return 0;
+}
+static void _get_playback_time_for_current_file(const char* url, void *data)
+{
+       if(url == NULL) {
+               VideoLogError("Failed to get url");
+               return;
+       }
+       vp_playtime_db_get_progress((const char*)url, _sqlite_table_data_cb, data);
+}
+
+
 /**
  *
  * @param data
@@ -386,6 +412,7 @@ static Eina_Bool __appControl_idler_cb(void *data)
                }
        } else {
                int nPosition = 0;
+               _get_playback_time_for_current_file(pAppData->pServiceData->pMediaUri, &nPosition);
                if (pAppData->pServiceData->bStoreDownload) {
                        nPosition = pAppData->pServiceData->nStorePlayedTime;
                }