From: aman.jeph Date: Tue, 29 Sep 2020 12:21:02 +0000 (+0530) Subject: [TIZENIOT-1761] Implemented progress tracker for video files X-Git-Tag: submit/tizen/20201001.111612~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8057ccce0a57f3b9e1e543310c4c0a8dc18d7006;p=profile%2Fiot%2Fapps%2Fnative%2Fvideo-player.git [TIZENIOT-1761] Implemented progress tracker for video files Change-Id: Ia30396653e3963e2df8ca7e5cb4cf1d80d4b5abd Signed-off-by: aman.jeph --- diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 343ae85..4ebd5d1 100755 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -13,6 +13,7 @@ SET(SRCS src/vp-util.c src/vp-file-util.c src/vp-pinch-zoom.c + src/vp-playtime-db.c ) INCLUDE_DIRECTORIES( diff --git a/common/include/vp-playtime-db.h b/common/include/vp-playtime-db.h new file mode 100755 index 0000000..dd57e12 --- /dev/null +++ b/common/include/vp-playtime-db.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __VP_PLAYTIME_DB_H__ +#define __VP_PLAYTIME_DB_H__ + +#ifdef _cplusplus +extern "C" { +#endif + + typedef int (*table_data_cb)(void *user_data ,int count, char **data ,char **colums); + + int vp_playtime_db_create(); + int vp_playtime_db_insert_row(const char *url, int progress); + int vp_playtime_db_select_all(table_data_cb callback, void *data); + int vp_playtime_db_get_progress(const char *url, table_data_cb callback, void *data); + int vp_playtime_db_remove_entries(void *data); + +#ifdef _cplusplus +} +#endif + +#endif // __VP_PLAYTIME_DB_H__ diff --git a/common/src/vp-playtime-db.c b/common/src/vp-playtime-db.c new file mode 100755 index 0000000..978c6cd --- /dev/null +++ b/common/src/vp-playtime-db.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "vp-db-common.h" +#include "vp-db-util.h" +#include "vp-file-util.h" + +#include "vp-media-content-util.h" + +#include "vp-playtime-db.h" +#include "app_common.h" + + + +static char *db_path = NULL; +static char sql_query[4096] = {0, }; + +const char* _vp_playtime_db_get_path() +{ + if(db_path == NULL) { + char *path = app_get_data_path(); + if(path == NULL) { + vp_dbgE("failed to get shared resource path"); + return NULL; + } + int len = strlen(path)+strlen("playtime.db")+5; + db_path = calloc(len, sizeof(char)); + if(db_path == NULL) { + vp_dbgE("failed to allocate memorey for db file path"); + return NULL; + } + snprintf(db_path, len, "%s%s", path, "playtime.db"); + vp_dbgW("db path: %s", db_path); + free(path); + } + return db_path; +} + +static void _vp_playtime_db_errlog_cb(void *data, int err_code, const char *msg) +{ + vp_dbgE("Sqlite Error: [code: %d] [Msg: %s]", err_code, msg); +} + +static int _vp_playtime_db_select_cd(void *user_data, int count, char **data, char **colums) +{ + vp_dbgW("There are %d colums in this select set", count); + + for(int i = 0; ipPlayerHandle, &nPosition)) { VideoLogError("vp_mm_player_get_position is fail"); } + int nTotalDuration = pNormalView->nDuration; + + if(nPosition > 0 && nTotalDuration > 0 && nPosition <= nTotalDuration ) { + //in case video is completed we need to push progress as zero because video need to start again. + if((nTotalDuration - nPosition) < ONE_SEC_IN_MILLI_SEC) { + vp_playtime_db_insert_row(pNormalView->szMediaURL, 0); + } else { + vp_playtime_db_insert_row(pNormalView->szMediaURL, nPosition); + } + } + } else if (pNormalView->nLaunchingType == VIDEO_PLAY_TYPE_MULTI_PATH) { if (!vp_mm_player_get_position (pNormalView->pPlayerHandle, &nPosition)) { diff --git a/project_def.prop b/project_def.prop index f50183c..5692362 100755 --- a/project_def.prop +++ b/project_def.prop @@ -9,7 +9,7 @@ type = app profile = mobile-3.0 # C Sources -USER_SRCS = playview/src/widget/vp-play-more.c playview/src/core/vp-avrcp.c playview/src/widget/vp-play-button.c src/common/mp-rotate-ctrl.c src/feature/mp-util-move.c src/common/mp-util-preference.c playview/src/feature/vp-subtitle-size.c src/view/mp-video-list-view-normal.c src/common/mp-video-info-ctrl.c src/viewMgr/videos-view-mgr.c playview/src/feature/vp-subtitle-color.c playview/src/core/vp-hollic.c src/view/mp-video-list-view-thumbnail.c src/view/mp-video-list-folder-share-via-view.c common/src/vp-chapter-db.c playview/src/core/vp-image-util.c playview/src/core/vp-multi-path.c playview/src/feature/vp-subtitle-edge.c src/view/mp-video-list-view-folder.c playview/src/widget/vp-play-volume-popup.c src/common/mp-util-media-service.c playview/src/core/vp-media-contents.c playview/src/feature/vp-play-speed.c src/widget/mp-video-list-sort-ctrl.c src/widget/mp-external-ug.c src/widget/mp-footer-toolbar.c playview/src/feature/vp-repeat.c playview/src/feature/vp-subtitle-bg-color.c common/src/vp-preview-db.c playview/src/core/vp-sensor.c src/widget/mp-video-view-popup-ctrl.c src/view/mp-video-list-view-main.c playview/src/core/vp-device.c src/feature/mp-launching-video-displayer.c playview/src/feature/vp-audio-track.c src/view/mp-video-list-view-item-of-folder.c playview/src/feature/vp-subtitle.c playview/src/feature/vp-share.c common/src/vp-thumb-db.c playview/src/feature/vp-detail.c src/view/mp-video-list-personal-view.c playview/src/feature/vp-capture.c playview/src/core/vp-media-key.c src/common/mp-util.c playview/src/widget/vp-play-loading-ani.c src/common/mp-drm-ctrl.c playview/src/widget/vp-play-progressbar.c src/video-player.c src/view/mp-video-list-share-via-view.c src/common/mp-util-config.c playview/src/view/vp-play-normal-view.c src/view/mp-video-list-remove-view.c src/widget/mp-util-widget-ctrl.c playview/src/widget/vp-play-subtitle.c common/src/vp-util.c src/view/mp-video-list-view-select.c playview/src/feature/vp-setting.c core/src/vp-drm.c video-downloader/src/VppDownload.c src/view/mp-video-list-personal-ctrl.c src/widget/mp-video-list-option-ctrl.c playview/src/common/vp-play-util.c playview/src/widget/vp-play-popup.c playview/src/common/vp-play-ug.c playview/src/vp-play-view.c common/src/vp-file-util.c playview/src/feature/vp-sound-path.c playview/src/common/vp-play-preference.c common/src/vp-pinch-zoom.c src/view/mp-video-list-remove-ctrl.c src/view/mp-library-view-mgr.c common/src/vp-media-content-util.c common/src/vp-db-util.c playview/src/widget/vp-play-bookmark.c playview/src/feature/vp-subtitle-select.c playview/src/widget/vp-play-volume.c src/view/mp-video-detail-view.c playview/src/feature/vp-zoom-guide.c src/view/mp-video-search-view.c playview/src/feature/vp-subtitle-font.c src/common/mp-video-util-db-controller.c playview/src/core/vp-mm-player.c playview/src/feature/vp-subtitle-track.c src/widget/mp-video-rename-ctrl.c playview/src/core/vp-device-language.c playview/src/core/vp-sound.c playview/src/feature/vp-subtitle-alignment.c src/widget/mp-video-list-view-as-ctrl.c playview/src/widget/vp-play-brightness-popup.c playview/src/feature/vp-sound-alive.c playview/src/common/vp-play-config.c src/view/mp-video-list-view-common.c playview/src/feature/vp-subtitle-sync.c src/widget/mp-video-nocontent-layout.c src/widget/mp-video-list-auto-play-ctrl.c playview/src/widget/vp-play-minicontroller.c playview/src/widget/vp-play-lockscreenmc.c +USER_SRCS = playview/src/widget/vp-play-more.c playview/src/core/vp-avrcp.c playview/src/widget/vp-play-button.c src/common/mp-rotate-ctrl.c src/feature/mp-util-move.c src/common/mp-util-preference.c playview/src/feature/vp-subtitle-size.c src/view/mp-video-list-view-normal.c src/common/mp-video-info-ctrl.c src/viewMgr/videos-view-mgr.c playview/src/feature/vp-subtitle-color.c playview/src/core/vp-hollic.c src/view/mp-video-list-view-thumbnail.c src/view/mp-video-list-folder-share-via-view.c common/src/vp-chapter-db.c playview/src/core/vp-image-util.c playview/src/core/vp-multi-path.c playview/src/feature/vp-subtitle-edge.c src/view/mp-video-list-view-folder.c playview/src/widget/vp-play-volume-popup.c src/common/mp-util-media-service.c playview/src/core/vp-media-contents.c playview/src/feature/vp-play-speed.c src/widget/mp-video-list-sort-ctrl.c src/widget/mp-external-ug.c src/widget/mp-footer-toolbar.c playview/src/feature/vp-repeat.c playview/src/feature/vp-subtitle-bg-color.c common/src/vp-preview-db.c playview/src/core/vp-sensor.c src/widget/mp-video-view-popup-ctrl.c src/view/mp-video-list-view-main.c playview/src/core/vp-device.c src/feature/mp-launching-video-displayer.c playview/src/feature/vp-audio-track.c src/view/mp-video-list-view-item-of-folder.c playview/src/feature/vp-subtitle.c playview/src/feature/vp-share.c common/src/vp-thumb-db.c playview/src/feature/vp-detail.c src/view/mp-video-list-personal-view.c playview/src/feature/vp-capture.c playview/src/core/vp-media-key.c src/common/mp-util.c playview/src/widget/vp-play-loading-ani.c src/common/mp-drm-ctrl.c playview/src/widget/vp-play-progressbar.c src/video-player.c src/view/mp-video-list-share-via-view.c src/common/mp-util-config.c playview/src/view/vp-play-normal-view.c src/view/mp-video-list-remove-view.c src/widget/mp-util-widget-ctrl.c playview/src/widget/vp-play-subtitle.c common/src/vp-util.c src/view/mp-video-list-view-select.c playview/src/feature/vp-setting.c core/src/vp-drm.c video-downloader/src/VppDownload.c src/view/mp-video-list-personal-ctrl.c src/widget/mp-video-list-option-ctrl.c playview/src/common/vp-play-util.c playview/src/widget/vp-play-popup.c playview/src/common/vp-play-ug.c playview/src/vp-play-view.c common/src/vp-file-util.c playview/src/feature/vp-sound-path.c playview/src/common/vp-play-preference.c common/src/vp-pinch-zoom.c src/view/mp-video-list-remove-ctrl.c src/view/mp-library-view-mgr.c common/src/vp-media-content-util.c common/src/vp-db-util.c playview/src/widget/vp-play-bookmark.c playview/src/feature/vp-subtitle-select.c playview/src/widget/vp-play-volume.c src/view/mp-video-detail-view.c playview/src/feature/vp-zoom-guide.c src/view/mp-video-search-view.c playview/src/feature/vp-subtitle-font.c src/common/mp-video-util-db-controller.c playview/src/core/vp-mm-player.c playview/src/feature/vp-subtitle-track.c src/widget/mp-video-rename-ctrl.c playview/src/core/vp-device-language.c playview/src/core/vp-sound.c playview/src/feature/vp-subtitle-alignment.c src/widget/mp-video-list-view-as-ctrl.c playview/src/widget/vp-play-brightness-popup.c playview/src/feature/vp-sound-alive.c playview/src/common/vp-play-config.c src/view/mp-video-list-view-common.c playview/src/feature/vp-subtitle-sync.c src/widget/mp-video-nocontent-layout.c src/widget/mp-video-list-auto-play-ctrl.c playview/src/widget/vp-play-minicontroller.c playview/src/widget/vp-play-lockscreenmc.c common/src/vp-playtime-db.c # EDC Sources USER_EDCS = diff --git a/src/common/mp-util-media-service.c b/src/common/mp-util-media-service.c index bc06b2e..f0c5e94 100755 --- a/src/common/mp-util-media-service.c +++ b/src/common/mp-util-media-service.c @@ -474,11 +474,11 @@ bool mp_util_svc_extract_video_list_from_folder(char *szFolderPath, case MP_LIST_VIEW_ALL: if (!mp_util_get_personal_status()) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101) and FOLDER_PATH = \"%s\" and FOLDER_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101) and FOLDER_PATH = \'%s\' and FOLDER_PATH NOT LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\'", szFolderPath); } break; @@ -486,11 +486,11 @@ bool mp_util_svc_extract_video_list_from_folder(char *szFolderPath, case MP_LIST_VIEW_PHONE: if (!mp_util_get_personal_status()) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and FOLDER_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and FOLDER_PATH NOT LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\'", szFolderPath); } break; @@ -498,11 +498,11 @@ bool mp_util_svc_extract_video_list_from_folder(char *szFolderPath, case MP_LIST_VIEW_CLOUD: if (!mp_util_get_personal_status()) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101) and MEDIA_STORAGE_TYPE = 101 and FOLDER_PATH = \"%s\" and FOLDER_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101) and MEDIA_STORAGE_TYPE = 101 and FOLDER_PATH = \'%s\' and FOLDER_PATH NOT LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_STORAGE_TYPE = 101 and FOLDER_PATH = \"%s\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_STORAGE_TYPE = 101 and FOLDER_PATH = \'%s\'", szFolderPath); } break; @@ -510,11 +510,11 @@ bool mp_util_svc_extract_video_list_from_folder(char *szFolderPath, default: if (!mp_util_get_personal_status()) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101) and FOLDER_PATH = \"%s\" and FOLDER_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101) and FOLDER_PATH = \'%s\' and FOLDER_PATH NOT LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\'", szFolderPath); } break; @@ -717,6 +717,73 @@ char *mp_util_get_folder_thumbnail(int nVideoFolderIndex, int nSortType) return szThumbnailPath; } +static bool mp_util_svc_iterate_for_video_url_cb(media_info_h pMediaItem, void *pUserData) +{ + media_content_type_e nMediaType = MEDIA_CONTENT_TYPE_OTHERS; + if (!pMediaItem) { + return TRUE; + } + Eina_List **pList = (Eina_List **) pUserData; + media_info_get_media_type(pMediaItem, &nMediaType); + + if (nMediaType == MEDIA_CONTENT_TYPE_VIDEO) { + // this will be deallocated when the eina list is deallocated. + char *szTmpItemFilePath = NULL; + + media_info_get_file_path(pMediaItem, &szTmpItemFilePath); + VideoLogInfo("URL: %s", szTmpItemFilePath); + + if (szTmpItemFilePath == NULL) { + VideoLogError("Fail to get file path of media item."); + return TRUE; + } + *pList = eina_list_append(*pList, szTmpItemFilePath); + } + VideoLogError("EinaList size: %d", eina_list_count(*pList)); + return TRUE; +} + + +void mp_util_svc_extract_video_url_by_item_type(void *list) +{ + VideoLogError(""); + filter_h m_FilterHandle = NULL; + media_content_order_e nOrderType = MEDIA_CONTENT_ORDER_DESC; + char szTmpStr[STR_LEN_MAX] = { 0, }; + char szOrderObj[STR_LEN_MAX] = { 0, }; + + strncpy(szOrderObj, MEDIA_ADDED_TIME, STR_LEN_MAX - 1); + snprintf(szTmpStr, STR_LEN_MAX, + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_PATH not like \'%s%%\'", + VIDEO_UTIL_PERSONAL_HEAD_STR); + if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { + VideoLogInfo("Fail to create media filter handle."); + return; + } + if (media_filter_set_condition(m_FilterHandle, szTmpStr, MEDIA_CONTENT_COLLATE_DEFAULT) != MEDIA_CONTENT_ERROR_NONE) { + VideoLogError("Fail to set filter condition."); + media_filter_destroy(m_FilterHandle); + return; + } + + if (media_filter_set_order(m_FilterHandle, MEDIA_CONTENT_ORDER_DESC, szOrderObj, MEDIA_CONTENT_COLLATE_NOCASE) != MEDIA_CONTENT_ERROR_NONE) { + VideoLogError("Fail to set order."); + media_filter_destroy(m_FilterHandle); + return; + } + + if (media_info_foreach_media_from_db(m_FilterHandle, mp_util_svc_iterate_for_video_url_cb, list) != MEDIA_CONTENT_ERROR_NONE) { + VideoLogError("Fail to get video item list with filter condition."); + media_filter_destroy(m_FilterHandle); + return; + } + + if (media_filter_destroy(m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { + VideoLogError("Fail to destroy media filter handle."); + return; + } +} + /** * Get video list by item type * @param nSortType : sort type @@ -776,7 +843,7 @@ bool mp_util_svc_extract_video_list_by_item_type(int nSortType, case MP_LIST_VIEW_ALL: if (!mp_util_get_personal_status()) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_PATH not like \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_PATH not like \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, @@ -787,7 +854,7 @@ bool mp_util_svc_extract_video_list_by_item_type(int nSortType, case MP_LIST_VIEW_PHONE: if (!mp_util_get_personal_status()) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH not like \"%s%%\"", + "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH not like \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, @@ -799,7 +866,7 @@ bool mp_util_svc_extract_video_list_by_item_type(int nSortType, case MP_LIST_VIEW_CLOUD: if (!mp_util_get_personal_status()) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101) and MEDIA_STORAGE_TYPE = 101 and MEDIA_PATH not like \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101) and MEDIA_STORAGE_TYPE = 101 and MEDIA_PATH not like \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, @@ -811,7 +878,7 @@ bool mp_util_svc_extract_video_list_by_item_type(int nSortType, default: if (!mp_util_get_personal_status()) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_PATH not like \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_PATH not like \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, @@ -1030,7 +1097,7 @@ bool mp_util_svc_get_video_id_by_video_url(const char *szPath, bRet = FALSE; } - snprintf(szTmpStr, STR_LEN_MAX, "MEDIA_PATH = \"%s\"", szPath); + snprintf(szTmpStr, STR_LEN_MAX, "MEDIA_PATH = \'%s\'", szPath); if (media_filter_set_condition(m_FilterHandle, szTmpStr, MEDIA_CONTENT_COLLATE_DEFAULT) != @@ -1100,7 +1167,7 @@ char *mp_util_svc_get_video_Thumbnail_by_video_url(const char *szMediaUri) memset(szTmpStr, 0, STR_LEN_MAX); snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \'%s\'", szMediaUri); if (media_filter_set_condition (m_FilterHandle, szTmpStr, @@ -1162,7 +1229,7 @@ void mp_util_svc_set_video_last_played_time_by_url(char *szMediaUri, } snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \'%s\'", szMediaUri); if (media_filter_set_condition (m_FilterHandle, szTmpStr, @@ -1581,11 +1648,11 @@ bool mp_util_svc_extract_personal_video_folder_list(int nSortType, if (bPersonal == FALSE) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } if (media_filter_set_condition @@ -1964,7 +2031,7 @@ void mp_util_svc_update_thumbnail_info(const int nVideoItemIndex) memset(szTmpStr, 0, STR_LEN_MAX); snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \'%s\'", szMediaUri); if (media_filter_set_condition (m_FilterHandle, szTmpStr, @@ -2357,7 +2424,7 @@ bool mp_util_svc_get_video_detail_by_video_url(const char *szPath, } snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \'%s\'", szPath); if (media_filter_set_condition (m_FilterHandle, szTmpStr, @@ -2488,11 +2555,11 @@ bool mp_util_svc_extract_video_list_from_folder_by_personal(char case MP_LIST_VIEW_ALL: if (nViewType == 0) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and MEDIA_PATH NOT LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and MEDIA_PATH LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } break; @@ -2500,11 +2567,11 @@ bool mp_util_svc_extract_video_list_from_folder_by_personal(char case MP_LIST_VIEW_PHONE: if (nViewType == 0) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and MEDIA_PATH NOT LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and MEDIA_PATH LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } break; @@ -2512,11 +2579,11 @@ bool mp_util_svc_extract_video_list_from_folder_by_personal(char case MP_LIST_VIEW_CLOUD: if (nViewType == 0) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and MEDIA_PATH NOT LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and MEDIA_PATH LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } break; @@ -2524,11 +2591,11 @@ bool mp_util_svc_extract_video_list_from_folder_by_personal(char default: if (nViewType == 0) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and MEDIA_PATH NOT LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \"%s\" and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and FOLDER_PATH = \'%s\' and MEDIA_PATH LIKE \'%s%%\'", szFolderPath, VIDEO_UTIL_PERSONAL_HEAD_STR); } break; @@ -2672,11 +2739,11 @@ bool mp_util_svc_extract_video_list_by_personal(int nSortType, case MP_LIST_VIEW_ALL: if (nViewType == 0) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } break; @@ -2684,11 +2751,11 @@ bool mp_util_svc_extract_video_list_by_personal(int nSortType, case MP_LIST_VIEW_PHONE: if (nViewType == 0) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } @@ -2697,11 +2764,11 @@ bool mp_util_svc_extract_video_list_by_personal(int nSortType, case MP_LIST_VIEW_CLOUD: if (nViewType == 0) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } @@ -2710,11 +2777,11 @@ bool mp_util_svc_extract_video_list_by_personal(int nSortType, default: if (nViewType == 0) { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH NOT LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } else { snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \"%s%%\"", + "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=2) and MEDIA_PATH LIKE \'%s%%\'", VIDEO_UTIL_PERSONAL_HEAD_STR); } break; diff --git a/src/video-player.c b/src/video-player.c index 0af492d..f287773 100755 --- a/src/video-player.c +++ b/src/video-player.c @@ -18,6 +18,7 @@ #include #include #include +#include "vp-playtime-db.h" #include "video-player.h" #include "videos-view-mgr.h" #include "mp-util.h" @@ -36,6 +37,8 @@ static bool appCreate(void *pUserData) { VideoLogWarning("== APP CREATE =="); + vp_playtime_db_create(); + return TRUE; } diff --git a/src/view/mp-video-list-remove-view.c b/src/view/mp-video-list-remove-view.c index f4eb6bb..d74210f 100755 --- a/src/view/mp-video-list-remove-view.c +++ b/src/view/mp-video-list-remove-view.c @@ -19,6 +19,8 @@ #include #include +#include "vp-file-util.h" +#include "vp-playtime-db.h" #include "mp-util.h" #include "mp-video-log.h" #include "mp-external-ug.h" @@ -33,11 +35,11 @@ #include "mp-video-list-view-item-of-folder.h" #include "mp-video-util-db-controller.h" #include "mp-util-widget-ctrl.h" -#include "vp-file-util.h" #include "mp-rotate-ctrl.h" #include "videos-view-mgr.h" #include "mp-video-list-view-main.h" + #define VIDEO_SELECTED_INFO_TIMER 4.0 #define GENGRID_ITEM_WIDTH 304 // Width is ICON(280) + LEFT_PADDING(12) RIGHT_PADDING(12) #define GENGRID_ITEM_HEIGHT 256 //Height is ICON(160) + TEXT_PART(56) + Bottom_PADDING(40) @@ -884,6 +886,40 @@ static Evas_Object *__mp_remove_folder_view_get_grid_icon_cb(void *pUserData, Ev return NULL; } +static int __mp_remove_view_sqlite_table_data_cb(void *user_data, int count, char **col_data, char **colums) { + stGengridItemData *item_data = (stGengridItemData*)user_data; + if(item_data == NULL ) { + VideoLogError("Item data is invalid"); + return 0; + } + VideoLogInfo("Search Set Count : %d [Must not greater than one]", count); + for(int i = 0; i [Col: %s] [Data: %s]", i, colums[i], col_data[i]); + int total_duration = mp_util_svc_get_video_duration_time(item_data->itemIndex); + if(col_data[i]) { + int current_duration = atoi(col_data[i]); + if(current_duration > 0 && total_duration > 0 && current_duration <= total_duration) { + double progress = ((double)current_duration/(double)total_duration); + edje_object_part_drag_value_set(elm_layout_edje_get(item_data->progress_layout), "elm.cur.progressbar", progress, 0.0); + } + } + } + //always return zero , otherwise sqlite3_exec will abort the subsequent statements + return 0; +} +static void __mp_remove_view_set_playback_progress(int videoIndex, void *data) +{ + char *url = mp_util_svc_get_video_url(videoIndex); + if(url == NULL) { + VideoLogError("Failed to get url"); + return; + } + vp_playtime_db_get_progress((const char*)url, __mp_remove_view_sqlite_table_data_cb, data); + free(url); + url = NULL; +} + + /** * * @param pUserData @@ -939,10 +975,11 @@ static Evas_Object *__mp_remove_view_get_grid_icon_cb(void *pUserData, Evas_Obje VideoLogInfo("layout file set %s %s",(ret? "Successful": "Failed"), pPart); evas_object_size_hint_weight_set(progessbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(progessbar, EVAS_HINT_FILL, EVAS_HINT_FILL); - double value = (((double) rand() ) / RAND_MAX ); - edje_object_part_drag_value_set(elm_layout_edje_get(progessbar), "elm.cur.progressbar", value, 0.0); - //__mp_thumbnail_view_get_playback_progress(nVideoItemIndex); + edje_object_part_drag_value_set(elm_layout_edje_get(progessbar), "elm.cur.progressbar", 0.0, 0.0); item_data->progress_layout = progessbar; + + __mp_remove_view_set_playback_progress(nVideoItemIndex, item_data); + return progessbar; } else if(!strcmp(pPart, "elm.check")) diff --git a/src/view/mp-video-list-share-via-view.c b/src/view/mp-video-list-share-via-view.c index 9ba6f76..ea753a2 100755 --- a/src/view/mp-video-list-share-via-view.c +++ b/src/view/mp-video-list-share-via-view.c @@ -19,8 +19,9 @@ #include #include -#include "mp-util.h" +#include "vp-playtime-db.h" #include "vp-file-util.h" +#include "mp-util.h" #include "mp-video-log.h" #include "mp-external-ug.h" #include "mp-video-string-define.h" @@ -899,6 +900,41 @@ static char *__mp_share_view_get_label_of_grid_item_cb(void #endif #ifdef VS_FEATURE_THUMBNAIL_VIEW + +static int __mp_share_view_sqlite_table_data_cb(void *user_data, int count, char **col_data, char **colums) { + stGengridItemData *item_data = (stGengridItemData*)user_data; + if(item_data == NULL ) { + VideoLogError("Item data is invalid"); + return 0; + } + VideoLogInfo("Search Set Count : %d [Must not greater than one]", count); + for(int i = 0; i [Col: %s] [Data: %s]", i, colums[i], col_data[i]); + int total_duration = mp_util_svc_get_video_duration_time(item_data->itemIndex); + if(col_data[i]) { + int current_duration = atoi(col_data[i]); + if(current_duration > 0 && total_duration > 0 && current_duration <= total_duration) { + double progress = ((double)current_duration/(double)total_duration); + edje_object_part_drag_value_set(elm_layout_edje_get(item_data->progress_layout), "elm.cur.progressbar", progress, 0.0); + } + } + } + //always return zero , otherwise sqlite3_exec will abort the subsequent statements + return 0; +} +static void __mp_share_view_set_playback_progress(int videoIndex, void *data) +{ + char *url = mp_util_svc_get_video_url(videoIndex); + if(url == NULL) { + VideoLogError("Failed to get url"); + return; + } + vp_playtime_db_get_progress((const char*)url, __mp_share_view_sqlite_table_data_cb, data); + free(url); + url = NULL; +} + + /** * * @param pUserData @@ -955,10 +991,11 @@ static Evas_Object *__mp_share_view_get_grid_icon_cb(void *pUserData, VideoLogInfo("layout file set %s %s",(ret? "Successful": "Failed"), pPart); evas_object_size_hint_weight_set(progessbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(progessbar, EVAS_HINT_FILL, EVAS_HINT_FILL); - double value = (((double) rand() ) / RAND_MAX ); - edje_object_part_drag_value_set(elm_layout_edje_get(progessbar), "elm.cur.progressbar", value, 0.0); - //__mp_thumbnail_view_get_playback_progress(nVideoItemIndex); + edje_object_part_drag_value_set(elm_layout_edje_get(progessbar), "elm.cur.progressbar", 0.0, 0.0); item_data->progress_layout = progessbar; + + __mp_share_view_set_playback_progress(nVideoItemIndex, item_data); + return progessbar; } else if(!strcmp(pPart, "elm.check")) diff --git a/src/view/mp-video-list-view-item-of-folder.c b/src/view/mp-video-list-view-item-of-folder.c index 256a4df..526ecc8 100755 --- a/src/view/mp-video-list-view-item-of-folder.c +++ b/src/view/mp-video-list-view-item-of-folder.c @@ -16,6 +16,7 @@ #include +#include "vp-playtime-db.h" #include "vp-util.h" #include "vp-file-util.h" #include "mp-video-log.h" @@ -252,6 +253,40 @@ static void __mp_folder_item_view_delete_btn_cb(void *pUserData, } #endif +static int __mp_folder_item_view_sqlite_table_data_cb(void *user_data, int count, char **col_data, char **colums) { + stGengridItemData *item_data = (stGengridItemData*)user_data; + if(item_data == NULL ) { + VideoLogError("Item data is invalid"); + return 0; + } + VideoLogInfo("Search Set Count : %d [Must not be greater than one]", count); + for(int i = 0; i [Col: %s] [Data: %s]", i, colums[i], col_data[i]); + int total_duration = mp_util_svc_get_video_duration_time(item_data->videoIndex); + if(col_data[i]) { + int current_duration = atoi(col_data[i]); + if(current_duration > 0 && total_duration > 0 && current_duration <= total_duration) { + double progress = ((double)current_duration/(double)total_duration); + edje_object_part_drag_value_set(elm_layout_edje_get(item_data->progress_layout), "elm.cur.progressbar", progress, 0.0); + } + } + } + //always return zero , otherwise sqlite3_exec will abort the subsequent statements + return 0; +} +static void __mp_folder_item_view_set_playback_progress(int videoIndex, void *data) +{ + char *url = mp_util_svc_get_video_url(videoIndex); + if(url == NULL) { + VideoLogError("Failed to get url"); + return; + } + vp_playtime_db_get_progress((const char*)url, __mp_folder_item_view_sqlite_table_data_cb, data); + free(url); + url = NULL; +} + + /** * * @param pUserData @@ -315,11 +350,10 @@ Evas_Object *__mp_folder_item_view_get_icon_of_video_item_cb(void VideoLogInfo("layout file set %s %s",(ret? "Successful": "Failed"), pPart); evas_object_size_hint_weight_set(progessbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(progessbar, EVAS_HINT_FILL, EVAS_HINT_FILL); - // TO DO: remove this once we are able to get the elapsed time for video file. - double value = (((double) rand() ) / RAND_MAX ); - edje_object_part_drag_value_set(elm_layout_edje_get(progessbar), "elm.cur.progressbar", value, 0.0); - //__mp_thumbnail_view_get_playback_progress(nVideoItemIndex); + edje_object_part_drag_value_set(elm_layout_edje_get(progessbar), "elm.cur.progressbar", 0.0, 0.0); item_data->progress_layout = progessbar; + + __mp_folder_item_view_set_playback_progress(nVideoItemIndex, item_data); return progessbar; } return NULL; @@ -1449,18 +1483,19 @@ static void __mp_folder_item_view_soft_back_button_cb(void *data, Evas_Object * elm_naviframe_item_pop(g_pFolderViewHandle->pNaviFrameHandle); } -static void __mp_folder_item_view_back_button_cb(void *data, Elm_Object_Item *item) +static Eina_Bool __mp_folder_item_view_back_button_cb(void *data, Elm_Object_Item *item) { if(g_pFolderViewHandle == NULL) { VideoLogError("g_pFolderViewHandle is invalid"); - return; + return EINA_FALSE; } VideoLogInfo(""); g_pFolderViewHandle->bExist = true; mp_folder_view_set_is_item_view(false); evas_object_smart_callback_add(g_pFolderViewHandle->pNaviFrameHandle, "transition,finished", __mp_folder_item_view_trans_finished_cb, NULL); mp_folder_item_view_pop(); + return EINA_TRUE; } static Evas_Object* _create_gengrid(Evas_Object *parent) diff --git a/src/view/mp-video-list-view-main.c b/src/view/mp-video-list-view-main.c index dce12d1..935f6c1 100755 --- a/src/view/mp-video-list-view-main.c +++ b/src/view/mp-video-list-view-main.c @@ -21,7 +21,7 @@ #include #include - +#include "vp-playtime-db.h" #include "mp-util.h" #include "vp-util.h" #include "mp-video-log.h" @@ -64,6 +64,7 @@ #include "mp-util-config.h" + #define TOOLBAR_BUTTON_VIDEOS "Videos" #define TOOLBAR_BUTTOn_FOLDERS "Folders" @@ -692,6 +693,64 @@ static void __mp_list_view_result_view_update_cb(void) } +static int __mp_list_view_playtime_db_select_all_cb(void *user_data, int count, char **data, char **colums) { + Eina_List **list = (Eina_List **)user_data; + for(int i = 0; i 0) { + vp_playtime_db_remove_entries(playdb_url_list); + } +} + /** * * @param nUpdateStyle @@ -705,6 +764,10 @@ static void __mp_list_view_db_update(int nUpdateStyle) } mp_util_db_run_backup_fun_except_lev0(NULL, NULL, NULL, NULL); + + // Update playtime db before update list so that , it will reflect the updated progress. + __mp_list_view_playtime_db_update(); + __mp_list_view_update_list(g_pMainViewHandle->nListTabType, LIST_UPDATE_TYPE_ALL); diff --git a/src/view/mp-video-list-view-thumbnail.c b/src/view/mp-video-list-view-thumbnail.c index 986ef4f..8ebf8a1 100755 --- a/src/view/mp-video-list-view-thumbnail.c +++ b/src/view/mp-video-list-view-thumbnail.c @@ -22,7 +22,7 @@ #include #include -#include "vp-play-log.h" +#include "vp-playtime-db.h" #include "vp-util.h" #include "vp-file-util.h" #include "vp-pinch-zoom.h" @@ -296,7 +296,6 @@ bool mp_thumbnail_view_arrange_list_item(void *pMainViewHandle, UpdateListItemsCbFunc pUpdateVideoListUserCb) { - srand((unsigned int)time(NULL)); VideoLogInfo(""); if (!pMainViewHandle || !pMainViewWidget || !pUpdateVideoListUserCb) { @@ -821,12 +820,7 @@ static void __mp_thumbnail_view_gengrid_realize_cb(void *pUserData, * @param pPart * @return */ -static char *__mp_thumbnail_view_get_label_of_grid_item_cb(const void - *pUserData, - Evas_Object * - pObject, - const char - *pPart) +static char *__mp_thumbnail_view_get_label_of_grid_item_cb(void *pUserData, Evas_Object *pObject, const char *pPart) { const stGengridItemData *item_data = pUserData; int nVideoItemIndex = item_data->videoIndex; @@ -848,17 +842,38 @@ static char *__mp_thumbnail_view_get_label_of_grid_item_cb(const void return NULL; } -// static double __mp_thumbnail_view_get_playback_progress(int videoIndex) -// { - // char *path = mp_util_svc_get_video_url(videoIndex); - // int width = 0, height = 0; - // unsigned int duration = 0, playedtime = 0; - // char *title = NULL; - // mp_util_svc_get_video_detail_by_video_url((const char*)path, &width, &height, &title, &duration, &playedtime); - // VideoLogInfo(" =====> VideoURL : %s", path); - // VideoLogInfo(" =====> [W: %d] [H: %d] [Title: %s]", width, height, title); - // VideoLogInfo(" =====> [Dur: %u] [ELA: %U] ", duration, playedtime); -// } +static int __mp_thumbnail_view_sqlite_table_data_cb(void *user_data, int count, char **col_data, char **colums) { + stGengridItemData *item_data = (stGengridItemData*)user_data; + if(item_data == NULL ) { + VideoLogError("Item data is invalid"); + return 0; + } + VideoLogInfo("Search Set Count : %d [Must not greater than one]", count); + for(int i = 0; i [Col: %s] [Data: %s]", i, colums[i], col_data[i]); + int total_duration = mp_util_svc_get_video_duration_time(item_data->videoIndex); + if(col_data[i]) { + int current_duration = atoi(col_data[i]); + if(current_duration > 0 && total_duration > 0 && current_duration <= total_duration) { + double progress = ((double)current_duration/(double)total_duration); + edje_object_part_drag_value_set(elm_layout_edje_get(item_data->progress_layout), "elm.cur.progressbar", progress, 0.0); + } + } + } + //always return zero , otherwise sqlite3_exec will abort the subsequent statements + return 0; +} +static void __mp_thumbnail_view_set_playback_progress(int videoIndex, void *data) +{ + char *url = mp_util_svc_get_video_url(videoIndex); + if(url == NULL) { + VideoLogError("Failed to get url"); + return; + } + vp_playtime_db_get_progress((const char*)url, __mp_thumbnail_view_sqlite_table_data_cb, data); + free(url); + url = NULL; +} /** * @@ -867,9 +882,7 @@ static char *__mp_thumbnail_view_get_label_of_grid_item_cb(const void * @param pPart * @return */ -static Evas_Object *__mp_thumbnail_view_get_grid_icon_cb(const void *pUserData, - Evas_Object *pObject, - const char *pPart) +static Evas_Object *__mp_thumbnail_view_get_grid_icon_cb(void *pUserData, Evas_Object *pObject, const char *pPart) { stGengridItemData *item_data = (void*)pUserData; int nVideoItemIndex = item_data->videoIndex; @@ -913,10 +926,11 @@ static Evas_Object *__mp_thumbnail_view_get_grid_icon_cb(const void *pUserData, VideoLogInfo("layout file set %s %s",(ret? "Successful": "Failed"), pPart); evas_object_size_hint_weight_set(progessbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(progessbar, EVAS_HINT_FILL, EVAS_HINT_FILL); - double value = (((double) rand() ) / RAND_MAX ); - edje_object_part_drag_value_set(elm_layout_edje_get(progessbar), "elm.cur.progressbar", value, 0.0); - //__mp_thumbnail_view_get_playback_progress(nVideoItemIndex); + edje_object_part_drag_value_set(elm_layout_edje_get(progessbar), "elm.cur.progressbar", 0.0, 0.0); item_data->progress_layout = progessbar; + + __mp_thumbnail_view_set_playback_progress(nVideoItemIndex, item_data); + return progessbar; } return NULL; @@ -1015,10 +1029,8 @@ static void __mp_thumbnail_view_append_gengrid_items(Evas_Object *pGengrid) { g_pThumbnailView->pVideolistGIC = elm_gengrid_item_class_new(); g_pThumbnailView->pVideolistGIC->item_style = "videolist"; - g_pThumbnailView->pVideolistGIC->func.text_get = - (void *) __mp_thumbnail_view_get_label_of_grid_item_cb; - g_pThumbnailView->pVideolistGIC->func.content_get = - (void *) __mp_thumbnail_view_get_grid_icon_cb; + g_pThumbnailView->pVideolistGIC->func.text_get = __mp_thumbnail_view_get_label_of_grid_item_cb; + g_pThumbnailView->pVideolistGIC->func.content_get = __mp_thumbnail_view_get_grid_icon_cb; g_pThumbnailView->pVideolistGIC->func.state_get = NULL; g_pThumbnailView->pVideolistGIC->func.del = NULL; } diff --git a/vp-main/project_def.prop b/vp-main/project_def.prop index 176e77a..0804025 100755 --- a/vp-main/project_def.prop +++ b/vp-main/project_def.prop @@ -9,7 +9,7 @@ type = app profile = mobile-3.0 # C Sources -USER_SRCS = src/serviceParser/vp-service-parser.c src/vp-main.c ../playview/src/core/vp-media-key.c ../src/view/mp-library-view-mgr.c ../playview/src/feature/vp-subtitle-size.c ../playview/src/feature/vp-share.c ../common/src/vp-pinch-zoom.c ../src/view/mp-video-list-remove-ctrl.c ../playview/src/feature/vp-audio-track.c ../playview/src/widget/vp-play-brightness-popup.c ../src/widget/mp-video-view-popup-ctrl.c ../playview/src/core/vp-image-util.c ../src/widget/mp-external-ug.c ../src/view/mp-video-list-view-common.c ../playview/src/core/vp-multi-path.c ../src/feature/mp-launching-video-displayer.c ../src/view/mp-video-list-view-thumbnail.c ../playview/src/common/vp-play-config.c ../src/view/mp-video-list-personal-view.c ../src/view/mp-video-detail-view.c ../playview/src/feature/vp-sound-alive.c ../src/view/mp-video-list-view-folder.c ../playview/src/vp-play-view.c ../src/view/mp-video-list-view-item-of-folder.c ../playview/src/feature/vp-subtitle-sync.c ../playview/src/feature/vp-sound-path.c ../common/src/vp-media-content-util.c ../playview/src/common/vp-play-preference.c ../playview/src/widget/vp-play-volume-popup.c ../playview/src/core/vp-media-contents.c ../common/src/vp-db-util.c ../src/widget/mp-video-list-option-ctrl.c ../playview/src/feature/vp-repeat.c ../playview/src/core/vp-avrcp.c ../playview/src/feature/vp-subtitle-alignment.c ../playview/src/widget/vp-play-subtitle.c ../common/src/vp-util.c ../src/widget/mp-video-list-sort-ctrl.c ../src/view/mp-video-list-personal-ctrl.c ../common/src/vp-file-util.c ../playview/src/feature/vp-subtitle-bg-color.c ../src/common/mp-util-media-service.c ../playview/src/widget/vp-play-bookmark.c ../playview/src/feature/vp-subtitle-select.c ../src/widget/mp-util-widget-ctrl.c ../playview/src/feature/vp-subtitle-font.c ../common/src/vp-chapter-db.c ../src/view/mp-video-list-view-normal.c ../src/common/mp-util-config.c ../playview/src/common/vp-play-util.c ../playview/src/widget/vp-play-minicontroller.c ../playview/src/widget/vp-play-lockscreenmc.c ../playview/src/widget/vp-play-popup.c ../src/common/mp-rotate-ctrl.c ../src/common/mp-util-preference.c ../playview/src/feature/vp-detail.c ../playview/src/widget/vp-play-progressbar.c ../playview/src/feature/vp-subtitle-edge.c ../src/widget/mp-video-nocontent-layout.c ../src/view/mp-video-list-share-via-view.c ../src/viewMgr/videos-view-mgr.c ../src/widget/mp-footer-toolbar.c ../playview/src/core/vp-sound.c ../playview/src/common/vp-play-ug.c ../playview/src/core/vp-device-language.c ../playview/src/feature/vp-play-speed.c ../src/view/mp-video-list-folder-share-via-view.c ../playview/src/feature/vp-subtitle-track.c ../playview/src/feature/vp-subtitle-color.c ../playview/src/core/vp-hollic.c ../src/view/mp-video-list-view-select.c ../playview/src/core/vp-mm-player.c ../src/view/mp-video-list-remove-view.c ../playview/src/widget/vp-play-volume.c ../playview/src/widget/vp-play-loading-ani.c ../playview/src/view/vp-play-normal-view.c ../playview/src/core/vp-device.c ../src/view/mp-video-list-view-main.c ../playview/src/widget/vp-play-button.c ../playview/src/widget/vp-play-more.c ../src/widget/mp-video-rename-ctrl.c ../common/src/vp-preview-db.c ../src/widget/mp-video-list-view-as-ctrl.c ../src/widget/mp-video-list-auto-play-ctrl.c ../src/feature/mp-util-move.c ../src/view/mp-video-search-view.c ../playview/src/feature/vp-capture.c ../src/common/mp-drm-ctrl.c ../src/common/mp-video-info-ctrl.c ../playview/src/feature/vp-subtitle.c ../src/common/mp-video-util-db-controller.c ../common/src/vp-thumb-db.c ../src/common/mp-util.c ../playview/src/core/vp-sensor.c ../playview/src/feature/vp-zoom-guide.c ../playview/src/feature/vp-setting.c +USER_SRCS = src/serviceParser/vp-service-parser.c src/vp-main.c ../playview/src/core/vp-media-key.c ../src/view/mp-library-view-mgr.c ../playview/src/feature/vp-subtitle-size.c ../playview/src/feature/vp-share.c ../common/src/vp-pinch-zoom.c ../src/view/mp-video-list-remove-ctrl.c ../playview/src/feature/vp-audio-track.c ../playview/src/widget/vp-play-brightness-popup.c ../src/widget/mp-video-view-popup-ctrl.c ../playview/src/core/vp-image-util.c ../src/widget/mp-external-ug.c ../src/view/mp-video-list-view-common.c ../playview/src/core/vp-multi-path.c ../src/feature/mp-launching-video-displayer.c ../src/view/mp-video-list-view-thumbnail.c ../playview/src/common/vp-play-config.c ../src/view/mp-video-list-personal-view.c ../src/view/mp-video-detail-view.c ../playview/src/feature/vp-sound-alive.c ../src/view/mp-video-list-view-folder.c ../playview/src/vp-play-view.c ../src/view/mp-video-list-view-item-of-folder.c ../playview/src/feature/vp-subtitle-sync.c ../playview/src/feature/vp-sound-path.c ../common/src/vp-media-content-util.c ../playview/src/common/vp-play-preference.c ../playview/src/widget/vp-play-volume-popup.c ../playview/src/core/vp-media-contents.c ../common/src/vp-db-util.c ../src/widget/mp-video-list-option-ctrl.c ../playview/src/feature/vp-repeat.c ../playview/src/core/vp-avrcp.c ../playview/src/feature/vp-subtitle-alignment.c ../playview/src/widget/vp-play-subtitle.c ../common/src/vp-util.c ../src/widget/mp-video-list-sort-ctrl.c ../src/view/mp-video-list-personal-ctrl.c ../common/src/vp-file-util.c ../playview/src/feature/vp-subtitle-bg-color.c ../src/common/mp-util-media-service.c ../playview/src/widget/vp-play-bookmark.c ../playview/src/feature/vp-subtitle-select.c ../src/widget/mp-util-widget-ctrl.c ../playview/src/feature/vp-subtitle-font.c ../common/src/vp-chapter-db.c ../src/view/mp-video-list-view-normal.c ../src/common/mp-util-config.c ../playview/src/common/vp-play-util.c ../playview/src/widget/vp-play-minicontroller.c ../playview/src/widget/vp-play-lockscreenmc.c ../playview/src/widget/vp-play-popup.c ../src/common/mp-rotate-ctrl.c ../src/common/mp-util-preference.c ../playview/src/feature/vp-detail.c ../playview/src/widget/vp-play-progressbar.c ../playview/src/feature/vp-subtitle-edge.c ../src/widget/mp-video-nocontent-layout.c ../src/view/mp-video-list-share-via-view.c ../src/viewMgr/videos-view-mgr.c ../src/widget/mp-footer-toolbar.c ../playview/src/core/vp-sound.c ../playview/src/common/vp-play-ug.c ../playview/src/core/vp-device-language.c ../playview/src/feature/vp-play-speed.c ../src/view/mp-video-list-folder-share-via-view.c ../playview/src/feature/vp-subtitle-track.c ../playview/src/feature/vp-subtitle-color.c ../playview/src/core/vp-hollic.c ../src/view/mp-video-list-view-select.c ../playview/src/core/vp-mm-player.c ../src/view/mp-video-list-remove-view.c ../playview/src/widget/vp-play-volume.c ../playview/src/widget/vp-play-loading-ani.c ../playview/src/view/vp-play-normal-view.c ../playview/src/core/vp-device.c ../src/view/mp-video-list-view-main.c ../playview/src/widget/vp-play-button.c ../playview/src/widget/vp-play-more.c ../src/widget/mp-video-rename-ctrl.c ../common/src/vp-preview-db.c ../src/widget/mp-video-list-view-as-ctrl.c ../src/widget/mp-video-list-auto-play-ctrl.c ../src/feature/mp-util-move.c ../src/view/mp-video-search-view.c ../playview/src/feature/vp-capture.c ../src/common/mp-drm-ctrl.c ../src/common/mp-video-info-ctrl.c ../playview/src/feature/vp-subtitle.c ../src/common/mp-video-util-db-controller.c ../common/src/vp-thumb-db.c ../src/common/mp-util.c ../playview/src/core/vp-sensor.c ../playview/src/feature/vp-zoom-guide.c ../playview/src/feature/vp-setting.c ../common/src/vp-playtime-db.c # EDC Sources USER_EDCS =