diff --git a/.gitignore b/.gitignore
index 259148f..7b430c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,9 +24,18 @@
*.lai
*.la
*.a
-*.lib
# Executables
*.exe
*.out
*.app
+
+*.dy
+*.pdb
+*.log
+*.tlog
+*.idb
+*.aps
+*.iobj
+/.vs
+/Temp
diff --git a/BVLoader.sln b/BVLoader.sln
index 8199016..5479359 100644
--- a/BVLoader.sln
+++ b/BVLoader.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32228.343
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BVLoader", "src\BVLoader\VideoLoader.vcxproj", "{8F011E58-EE97-4A49-95B6-F6A33D4759C0}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BVLoader", "src\BVLoader\BVLoader.vcxproj", "{8F011E58-EE97-4A49-95B6-F6A33D4759C0}"
ProjectSection(ProjectDependencies) = postProject
{06A01E97-333D-4309-A605-7D28324D750D} = {06A01E97-333D-4309-A605-7D28324D750D}
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
diff --git a/Bin/Debug/skin/cover.jpg b/Bin/Debug/skin/cover.jpg
deleted file mode 100644
index 9aa3d73..0000000
Binary files a/Bin/Debug/skin/cover.jpg and /dev/null differ
diff --git a/Bin/Debug/skin/cover.png b/Bin/Debug/skin/cover.png
new file mode 100644
index 0000000..a0830cd
Binary files /dev/null and b/Bin/Debug/skin/cover.png differ
diff --git a/Bin/Debug/skin/item_finish.xml b/Bin/Debug/skin/item_finish.xml
index 28da13a..b187c1a 100644
--- a/Bin/Debug/skin/item_finish.xml
+++ b/Bin/Debug/skin/item_finish.xml
@@ -1,18 +1,14 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/Bin/Debug/skin/item_loading.xml b/Bin/Debug/skin/item_loading.xml
index 319e4fa..f2d2e1e 100644
--- a/Bin/Debug/skin/item_loading.xml
+++ b/Bin/Debug/skin/item_loading.xml
@@ -10,11 +10,11 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/Bin/Debug/skin/public/scroll.png b/Bin/Debug/skin/public/scroll.png
new file mode 100644
index 0000000..81c7087
Binary files /dev/null and b/Bin/Debug/skin/public/scroll.png differ
diff --git a/Bin/Debug/skin/wnd_parse.xml b/Bin/Debug/skin/wnd_parse.xml
index 57d014e..0df9b1f 100644
--- a/Bin/Debug/skin/wnd_parse.xml
+++ b/Bin/Debug/skin/wnd_parse.xml
@@ -15,7 +15,7 @@
-
+
@@ -51,7 +51,7 @@
-
+
diff --git a/lib/Debug/libcurl.lib b/lib/Debug/libcurl.lib
new file mode 100644
index 0000000..d302838
Binary files /dev/null and b/lib/Debug/libcurl.lib differ
diff --git a/lib/Release/libcurl.lib b/lib/Release/libcurl.lib
new file mode 100644
index 0000000..d302838
Binary files /dev/null and b/lib/Release/libcurl.lib differ
diff --git a/lib/avcodec.lib b/lib/avcodec.lib
new file mode 100644
index 0000000..d0fae6e
Binary files /dev/null and b/lib/avcodec.lib differ
diff --git a/lib/avdevice.lib b/lib/avdevice.lib
new file mode 100644
index 0000000..66da08f
Binary files /dev/null and b/lib/avdevice.lib differ
diff --git a/lib/avfilter.lib b/lib/avfilter.lib
new file mode 100644
index 0000000..ddbb45b
Binary files /dev/null and b/lib/avfilter.lib differ
diff --git a/lib/avformat.lib b/lib/avformat.lib
new file mode 100644
index 0000000..6c70d0f
Binary files /dev/null and b/lib/avformat.lib differ
diff --git a/lib/avutil.lib b/lib/avutil.lib
new file mode 100644
index 0000000..f3df4b6
Binary files /dev/null and b/lib/avutil.lib differ
diff --git a/lib/libcrypto.lib b/lib/libcrypto.lib
new file mode 100644
index 0000000..487dbc2
Binary files /dev/null and b/lib/libcrypto.lib differ
diff --git a/lib/libmp3lame.lib b/lib/libmp3lame.lib
new file mode 100644
index 0000000..694cbf2
Binary files /dev/null and b/lib/libmp3lame.lib differ
diff --git a/lib/libssl.lib b/lib/libssl.lib
new file mode 100644
index 0000000..ddf5fb8
Binary files /dev/null and b/lib/libssl.lib differ
diff --git a/lib/postproc.lib b/lib/postproc.lib
new file mode 100644
index 0000000..540fe4f
Binary files /dev/null and b/lib/postproc.lib differ
diff --git a/lib/swresample.lib b/lib/swresample.lib
new file mode 100644
index 0000000..8310008
Binary files /dev/null and b/lib/swresample.lib differ
diff --git a/lib/swscale.lib b/lib/swscale.lib
new file mode 100644
index 0000000..92e90a9
Binary files /dev/null and b/lib/swscale.lib differ
diff --git a/lib/zlib.lib b/lib/zlib.lib
new file mode 100644
index 0000000..f41eded
Binary files /dev/null and b/lib/zlib.lib differ
diff --git a/src/BVLoader/VideoLoader.rc b/src/BVLoader/BVLoader.rc
similarity index 92%
rename from src/BVLoader/VideoLoader.rc
rename to src/BVLoader/BVLoader.rc
index b8fafd6..4906f68 100644
Binary files a/src/BVLoader/VideoLoader.rc and b/src/BVLoader/BVLoader.rc differ
diff --git a/src/BVLoader/VideoLoader.vcxproj b/src/BVLoader/BVLoader.vcxproj
similarity index 97%
rename from src/BVLoader/VideoLoader.vcxproj
rename to src/BVLoader/BVLoader.vcxproj
index c86dce0..9975be6 100644
--- a/src/BVLoader/VideoLoader.vcxproj
+++ b/src/BVLoader/BVLoader.vcxproj
@@ -22,7 +22,7 @@
16.0
Win32Proj
{8f011e58-ee97-4a49-95b6-f6a33d4759c0}
- VideoLoader
+ BVLoader
10.0
BVLoader
@@ -199,19 +199,16 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/src/BVLoader/VideoLoader.vcxproj.filters b/src/BVLoader/BVLoader.vcxproj.filters
similarity index 96%
rename from src/BVLoader/VideoLoader.vcxproj.filters
rename to src/BVLoader/BVLoader.vcxproj.filters
index 9e8db0a..4465bc2 100644
--- a/src/BVLoader/VideoLoader.vcxproj.filters
+++ b/src/BVLoader/BVLoader.vcxproj.filters
@@ -148,25 +148,22 @@
-
- 资源文件
-
+
+ service\download
+
+
-
+
资源文件
-
+
资源文件
-
-
-
-
- service\download
-
-
+
+ 资源文件
+
\ No newline at end of file
diff --git a/src/BVLoader/define/message_define.h b/src/BVLoader/define/message_define.h
index 22fc799..7370a2c 100644
--- a/src/BVLoader/define/message_define.h
+++ b/src/BVLoader/define/message_define.h
@@ -18,8 +18,9 @@ enum class MessageIconType {
enum {
WM_MAINWND_MSGBOX = kBaseWindowMessage + 1,
WM_MAINWND_DECODE,
+ WM_MAINWND_NOTIFY_STATUS,
};
enum MsgWparam {
- WPARAM_DELETE_LOADING_ITEM = 0,
+ WPARAM_DELETE_LIST_ITEM = 0,
};
\ No newline at end of file
diff --git a/src/BVLoader/define/soft_define.h b/src/BVLoader/define/soft_define.h
index 593927c..69ce130 100644
--- a/src/BVLoader/define/soft_define.h
+++ b/src/BVLoader/define/soft_define.h
@@ -3,8 +3,8 @@
static constexpr const wchar_t* kAppWindowClassName = L"GuiFoundationClass";
static constexpr const wchar_t* kAppWindowTitle = L"ع";
static constexpr const wchar_t* kAppInstanceMutex = L"{E33E6D86-55E3-496B-B961-A205582F84EC}";
-static constexpr const wchar_t* kAppExeName = L"VideoLoader.exe";
-static constexpr const wchar_t* kAppVersion = L"1.0.0";
+static constexpr const wchar_t* kAppExeName = L"BVLoader.exe";
+static constexpr const wchar_t* kAppVersion = L"1.0.1";
static constexpr const wchar_t* kAppName = L"DownloadTools";
static constexpr const char* kAppNameAscii = "DownloadTools";
@@ -16,4 +16,7 @@ static constexpr const char* kAppNameAscii = "DownloadTools";
static constexpr const wchar_t* kTextLoadPause = L"ͣ";
static constexpr const wchar_t* kTextLoadWaiting = L"ȴ";
static constexpr const wchar_t* kTextLoadFailed = L"ʧ";
-static constexpr const wchar_t* kTextLoadFinish = L"";
\ No newline at end of file
+static constexpr const wchar_t* kTextLoadFinish = L"";
+static constexpr const wchar_t* kTextDecoding = L"";
+
+static constexpr const wchar_t* kDefaultCover = L"cover.png";
\ No newline at end of file
diff --git a/src/BVLoader/main.cpp b/src/BVLoader/main.cpp
index b692bc5..f5689f4 100644
--- a/src/BVLoader/main.cpp
+++ b/src/BVLoader/main.cpp
@@ -1,4 +1,4 @@
-// VideoLoader.cpp : 定义应用程序的入口点。
+// BVLoader.cpp : 定义应用程序的入口点。
//
#include "pch.h"
@@ -72,7 +72,7 @@ void InitEasyLog()
SYSTEMTIME stCur;
::GetLocalTime(&stCur);
char current_date[128] = { 0 };
- sprintf_s(current_date, 128, "VideoLoader_%04d-%02d-%02d.log", stCur.wYear,
+ sprintf_s(current_date, 128, "BVLoader_%04d-%02d-%02d.log", stCur.wYear,
stCur.wMonth, stCur.wDay);
strcat_s(log_path, current_date);
std::string log_file(log_path);
diff --git a/src/BVLoader/VideoLoader.ico b/src/BVLoader/res/BVLoader.ico
similarity index 100%
rename from src/BVLoader/VideoLoader.ico
rename to src/BVLoader/res/BVLoader.ico
diff --git a/src/BVLoader/res/skin.zip b/src/BVLoader/res/skin.zip
index b8003fb..96f87e7 100644
Binary files a/src/BVLoader/res/skin.zip and b/src/BVLoader/res/skin.zip differ
diff --git a/src/BVLoader/small.ico b/src/BVLoader/res/small.ico
similarity index 100%
rename from src/BVLoader/small.ico
rename to src/BVLoader/res/small.ico
diff --git a/src/BVLoader/resource.h b/src/BVLoader/resource.h
index f4319e3..bae0971 100644
--- a/src/BVLoader/resource.h
+++ b/src/BVLoader/resource.h
@@ -1,11 +1,11 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
-// 供 VideoLoader.rc 使用
+// 供 BVLoader.rc 使用
//
#define IDC_MYICON 2
#define IDD_VIDEOLOADER_DIALOG 102
#define IDM_ABOUT 104
-#define IDI_VIDEOLOADER 107
+#define IDI_BVLOADER 107
#define IDI_SMALL 108
#define IDR_MAINFRAME 128
#define IDR_DAT1 129
diff --git a/src/BVLoader/service/download/download_service.cpp b/src/BVLoader/service/download/download_service.cpp
index 366e41b..2f495a4 100644
--- a/src/BVLoader/service/download/download_service.cpp
+++ b/src/BVLoader/service/download/download_service.cpp
@@ -204,7 +204,7 @@ namespace download {
if (task_mgr_->GetLoadingCount() < max_loading_count_) {
task->http = std::make_shared();
if (!task->http->Initialize(task->url, task->save_path)) {
- LOG(ERROR) << "ʼؿʧ";
+ LOG(ERROR) << "StartTask ʼؿʧ";
task->status = DownloadStatus::STATUS_FAILED;
task->http = nullptr;
NotifyStatus(task);
@@ -256,7 +256,7 @@ namespace download {
auto task = task_mgr_->NewTask(url, title, img, author, duration, ctime);
auto name = string_utils::GetFileNameByUrl(url);
if (name.empty()) {
- LOG(ERROR) << "ȡļʧܣurl: " << url;
+ LOG(ERROR) << "AddTask ȡļʧܣurl: " << url;
task_mgr_->FreeTask(std::move(task));
return nullptr;
}
@@ -274,11 +274,11 @@ namespace download {
Task* task_ptr = reinterpret_cast(task_id);
auto task = task_mgr_->FindLoadingTask(task_ptr);
if (!task) {
- LOG(ERROR) << "";
+ LOG(ERROR) << "StopTask ";
return false;
}
if (task->status != DownloadStatus::STATUS_LOADING) {
- LOG(ERROR) << "״̬ȷstatus: " << (int)task->status;
+ LOG(ERROR) << "StopTask ״̬ȷstatus: " << (int)task->status;
return false;
}
ClearTaskHttp(task);
@@ -292,12 +292,12 @@ namespace download {
Task* task_ptr = reinterpret_cast(task_id);
auto task = task_mgr_->FindLoadingTask(task_ptr);
if (!task) {
- LOG(ERROR) << "";
+ LOG(ERROR) << "ReloadTask ";
return false;
}
if (task->status != DownloadStatus::STATUS_PAUSE
&& task->status != DownloadStatus::STATUS_FAILED) {
- LOG(ERROR) << "״̬ȷstatus: " << (int)task->status;
+ LOG(ERROR) << "ReloadTask ״̬ȷstatus: " << (int)task->status;
return false;
}
StartTask(task);
@@ -309,7 +309,7 @@ namespace download {
Task* task_ptr = reinterpret_cast(task_id);
auto task = task_mgr_->FindLoadingTask(task_ptr);
if (!task) {
- LOG(ERROR) << "";
+ LOG(ERROR) << "DeleteLoadingTask ";
return false;
}
ClearTaskHttp(task);
@@ -318,5 +318,31 @@ namespace download {
return true;
}
+ bool DownloadService::DeleteFinishTask(UINT_PTR task_id)
+ {
+ Task* task_ptr = reinterpret_cast(task_id);
+ auto task = task_mgr_->FindFinishTask(task_ptr);
+ if (!task) {
+ LOG(ERROR) << "DeleteFinishTask ";
+ return false;
+ }
+ ClearTaskHttp(task);
+ task->Clear();
+ task_mgr_->DeleteFinishTask(task);
+ return true;
+ }
+
+ bool DownloadService::AddFinishTask(UINT_PTR task_id)
+ {
+ Task* task_ptr = reinterpret_cast(task_id);
+ auto task = task_mgr_->FindLoadingTask(task_ptr);
+ if (!task) {
+ LOG(ERROR) << "AddFinishTask ";
+ return false;
+ }
+ task_mgr_->AddFinishTask(std::move(task));
+ return true;
+ }
+
} // namespace download
diff --git a/src/BVLoader/service/download/download_service.h b/src/BVLoader/service/download/download_service.h
index 4494e75..b28bfe1 100644
--- a/src/BVLoader/service/download/download_service.h
+++ b/src/BVLoader/service/download/download_service.h
@@ -21,7 +21,10 @@ namespace download {
bool StopTask(UINT_PTR task_id) override;
bool ReloadTask(UINT_PTR task_id) override;
bool DeleteLoadingTask(UINT_PTR task_id) override;
- std::shared_ptr FindTask(UINT_PTR task_id) override;
+ bool DeleteFinishTask(UINT_PTR task_id) override;
+ std::shared_ptr FindLoadingTask(UINT_PTR task_id) override;
+ std::shared_ptr FindFinishTask(UINT_PTR task_id) override;
+ bool AddFinishTask(UINT_PTR task_id) override;
protected:
bool Init() override;
diff --git a/src/BVLoader/service/download/download_service.inl b/src/BVLoader/service/download/download_service.inl
index 437b092..fda6c7d 100644
--- a/src/BVLoader/service/download/download_service.inl
+++ b/src/BVLoader/service/download/download_service.inl
@@ -13,12 +13,20 @@ namespace download {
}
}
- inline std::shared_ptr DownloadService::FindTask(UINT_PTR task_id)
+ inline std::shared_ptr DownloadService::FindLoadingTask(UINT_PTR task_id)
{
Task* task_ptr = reinterpret_cast(task_id);
- auto task = task_mgr_->FindLoadingTask(task_ptr);
- if (task) {
- return task;
+ if (task_ptr == nullptr) {
+ return nullptr;
+ }
+ return task_mgr_->FindLoadingTask(task_ptr);
+ }
+
+ inline std::shared_ptr DownloadService::FindFinishTask(UINT_PTR task_id)
+ {
+ Task* task_ptr = reinterpret_cast(task_id);
+ if (task_ptr == nullptr) {
+ return nullptr;
}
return task_mgr_->FindFinishTask(task_ptr);
}
diff --git a/src/BVLoader/service/download/task_manager.cpp b/src/BVLoader/service/download/task_manager.cpp
index f27ec42..0ce0b6a 100644
--- a/src/BVLoader/service/download/task_manager.cpp
+++ b/src/BVLoader/service/download/task_manager.cpp
@@ -38,6 +38,26 @@ namespace download {
return nullptr;
}
+ void TaskManager::AddFinishTask(const std::shared_ptr& task)
+ {
+ auto iter = std::find(loading_list_.begin(), loading_list_.end(), task);
+ if (iter == loading_list_.end()) {
+ return;
+ }
+ finish_list.emplace_back(task);
+ loading_list_.erase(iter);
+ }
+
+ void TaskManager::AddFinishTask(std::shared_ptr&& task)
+ {
+ auto iter = std::find(loading_list_.begin(), loading_list_.end(), task);
+ if (iter == loading_list_.end()) {
+ return;
+ }
+ finish_list.emplace_back(std::move(task));
+ loading_list_.erase(iter);
+ }
+
std::shared_ptr TaskManager::FindFinishTask(Task* task_ptr)
{
for (auto& task : finish_list) {
@@ -94,4 +114,15 @@ namespace download {
free_list_.emplace_back(std::move(temp_task));
}
+ void TaskManager::DeleteFinishTask(const std::shared_ptr& task)
+ {
+ auto iter = std::find(finish_list.begin(), finish_list.end(), task);
+ if (iter == finish_list.end()) {
+ return;
+ }
+ auto temp_task = *iter;
+ finish_list.erase(iter);
+ free_list_.emplace_back(std::move(temp_task));
+ }
+
}// namespace download
\ No newline at end of file
diff --git a/src/BVLoader/service/download/task_manager.h b/src/BVLoader/service/download/task_manager.h
index 9c1cd70..821b21f 100644
--- a/src/BVLoader/service/download/task_manager.h
+++ b/src/BVLoader/service/download/task_manager.h
@@ -12,23 +12,23 @@ namespace download {
std_cwstr_ref author, int duration, __int64 ctime);
void FreeTask(std::shared_ptr&& task);
void FreeTask(const std::shared_ptr& task);
- void DeleteLoadingTask(const std::shared_ptr& task);
void AddLoadigTask(const std::shared_ptr& task);
+ std::shared_ptr FindLoadingTask(Task* task_ptr);
+ void DeleteLoadingTask(const std::shared_ptr& task);
int GetLoadingCount();
- std::shared_ptr FindLoadingTask(Task* task_ptr);
+ void AddFinishTask(const std::shared_ptr& task);
+ void AddFinishTask(std::shared_ptr&& task);
std::shared_ptr FindFinishTask(Task* task_ptr);
+ void DeleteFinishTask(const std::shared_ptr& task);
protected:
void Reserve(int count);
-
private:
std::list> loading_list_;
std::list> finish_list;
-
- std::list> temp_list_;
std::list> free_list_;
};
}// namespace download
\ No newline at end of file
diff --git a/src/BVLoader/service/service.h b/src/BVLoader/service/service.h
index a7d949a..80a79cf 100644
--- a/src/BVLoader/service/service.h
+++ b/src/BVLoader/service/service.h
@@ -8,6 +8,7 @@ class IService {
virtual void Exit() = 0;
};
+// 첽ӿ
class IAsyncServiceDelegate;
class IAsyncService
: public IService {
@@ -17,6 +18,7 @@ class IAsyncService
virtual void AddDecodeTask(UINT_PTR task_id, std_cwstr_ref video_path, std_cwstr_ref mp3_path) = 0;
};
+// طӿ
namespace download {
class IDownloadServiceDelegate;
}
@@ -29,9 +31,13 @@ class IDownloadService
virtual bool StopTask(UINT_PTR task_id) = 0;
virtual bool ReloadTask(UINT_PTR task_id) = 0;
virtual bool DeleteLoadingTask(UINT_PTR task_id) = 0;
- virtual std::shared_ptr FindTask(UINT_PTR task_id) = 0;
+ virtual bool DeleteFinishTask(UINT_PTR task_id) = 0;
+ virtual std::shared_ptr FindLoadingTask(UINT_PTR task_id) = 0;
+ virtual std::shared_ptr FindFinishTask(UINT_PTR task_id) = 0;
+ virtual bool AddFinishTask(UINT_PTR task_id) = 0;
};
+// ӿ
class IAudioServiceDelegate;
class IAudioService
: public IService {
diff --git a/src/BVLoader/wnd/wnd_base.cpp b/src/BVLoader/wnd/wnd_base.cpp
index 298f4fd..fae8624 100644
--- a/src/BVLoader/wnd/wnd_base.cpp
+++ b/src/BVLoader/wnd/wnd_base.cpp
@@ -54,7 +54,7 @@ LRESULT WndBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandle
LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE);
styleValue &= ~WS_CAPTION;
::SetWindowLong(m_hWnd, GWL_STYLE, styleValue);
- SetIcon(IDI_VIDEOLOADER);
+ SetIcon(IDI_BVLOADER);
m_pm.Init(m_hWnd);
CDialogBuilder builder;
CDuiString strXmlPath = GetXmlPath();
diff --git a/src/BVLoader/wnd/wnd_main.cpp b/src/BVLoader/wnd/wnd_main.cpp
index 8987de6..887ef2b 100644
--- a/src/BVLoader/wnd/wnd_main.cpp
+++ b/src/BVLoader/wnd/wnd_main.cpp
@@ -62,6 +62,8 @@ LRESULT WndMain::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
return OnMsgMsgbox(wParam, lParam);
case WM_MAINWND_DECODE:
return OnMsgDecode(wParam, lParam);
+ case WM_MAINWND_NOTIFY_STATUS:
+ return OnMsgNotifyStatus(wParam, lParam);
default:
break;
}
@@ -77,33 +79,38 @@ void WndMain::NotifyStatus(const std::shared_ptr& task, void* pa
UINT_PTR task_id = (UINT_PTR)task.get();
auto iter = map_loading_items_.find(task_id);
if (iter == map_loading_items_.end()) {
- LOG(ERROR) << "NotifyStatus δҵض";
+ LOG(ERROR) << "NotifyStatus δҵؽڵ";
return;
}
auto label_state = iter->second->FindSubControl(L"lbl_state");
assert(label_state);
- auto btn_start = iter->second->FindSubControl(L"btn_start_loading");
+ auto btn_start = iter->second->FindSubControl(L"btn_loading_start");
assert(btn_start);
- auto btn_stop = iter->second->FindSubControl(L"btn_stop_loading");
+ auto btn_stop = iter->second->FindSubControl(L"btn_loading_stop");
assert(btn_stop);
+ auto btn_size = iter->second->FindSubControl(L"lbl_size");
+ assert(btn_size);
switch (task->status)
{
case download::DownloadStatus::STATUS_LOADING: {
label_state->SetText(kTextLoading);
btn_start->SetVisible(false);
btn_stop->SetVisible();
+ btn_size->SetVisible();
break;
}
case download::DownloadStatus::STATUS_PAUSE: {
label_state->SetText(kTextLoadPause);
btn_start->SetVisible();
btn_stop->SetVisible(false);
+ btn_size->SetVisible(false);
break;
}
case download::DownloadStatus::STATUS_WAITTING: {
label_state->SetText(kTextLoadWaiting);
btn_start->SetVisible(false);
btn_stop->SetVisible();
+ btn_size->SetVisible(false);
break;
}
case download::DownloadStatus::STATUS_FAILED: {
@@ -113,6 +120,7 @@ void WndMain::NotifyStatus(const std::shared_ptr& task, void* pa
progress->SetForeImage(L"pro_error.png");
btn_start->SetVisible(false);
btn_stop->SetVisible();
+ btn_size->SetVisible(false);
break;
}
case download::DownloadStatus::STATUS_DOWNLOAD_SUCCESS: {
@@ -120,11 +128,33 @@ void WndMain::NotifyStatus(const std::shared_ptr& task, void* pa
auto progress = dynamic_cast(iter->second->FindSubControl(L"progress"));
assert(progress);
progress->SetValue(100);
- auto ctrl = iter->second->FindSubControl(L"lbl_size");
- assert(ctrl);
- ctrl->SetText(string_utils::SecondsToString(task->duration).c_str());
+ btn_size->SetVisible();
+ btn_size->SetText(string_utils::SecondsToString(task->duration).c_str());
//
+ task->status = download::DownloadStatus::STATUS_DECODE;
ASYNC_SERVICE()->AddDecodeTask(task_id, task->save_path, task->audio_path);
+ ::PostMessage(m_hWnd, WM_MAINWND_NOTIFY_STATUS, (WPARAM)task_id, (LPARAM)param);
+ break;
+ }
+ case download::DownloadStatus::STATUS_DECODE: {
+ label_state->SetText(kTextDecoding);
+ btn_stop->SetVisible(false);
+ auto btn_delete = iter->second->FindSubControl(L"btn_loading_delete");
+ assert(btn_delete);
+ btn_delete->SetVisible(false);
+ break;
+ }
+ case download::DownloadStatus::STATUS_FINISH: {
+ // ɺб
+ list_loading_->Remove(iter->second);
+ map_loading_items_.erase(iter);
+ auto task = DOWNLOAD_SERVICE()->FindLoadingTask(task_id);
+ if (task == nullptr) {
+ break;
+ }
+ if (DOWNLOAD_SERVICE()->AddFinishTask(task_id)) {
+ AddFinishItem(task);
+ }
break;
}
default:
@@ -168,26 +198,6 @@ void WndMain::OnDecodeComplete(UINT_PTR task_id, DecodeErrorCode code, void* dat
::PostMessage(m_hWnd, WM_MAINWND_DECODE, (WPARAM)task_id, (LPARAM)code);
}
-bool WndMain::OnNotifyClose(void* param)
-{
- TNotifyUI* notify = reinterpret_cast(param);
- if (notify->sType == DUI_MSGTYPE_CLICK) {
- Close();
- }
- return true;
-}
-
-bool WndMain::OnNotifyDownload(void* param)
-{
- TNotifyUI* notify = reinterpret_cast(param);
- if (notify->sType == DUI_MSGTYPE_CLICK) {
- assert(wnd_parse_);
- wnd_parse_->CenterWindow();
- wnd_parse_->ShowWindow();
- }
- return true;
-}
-
void WndMain::Notify(TNotifyUI& msg)
{
if (msg.sType == DUI_MSGTYPE_SELECTCHANGED) {
@@ -206,14 +216,29 @@ void WndMain::Notify(TNotifyUI& msg)
void WndMain::OnClick(TNotifyUI& msg)
{
- if (msg.pSender->GetName().Compare(L"btn_start_loading") == 0) {
- OnClickStartLoading(msg.pSender);
+ auto& name = msg.pSender->GetName();
+ if (wcsncmp(name.GetData(), L"btn_loading", 11) == 0) {
+ if (name.Compare(L"btn_loading_start") == 0) {
+ OnClickStartLoading(msg.pSender);
+ }
+ else if (name.Compare(L"btn_loading_stop") == 0) {
+ OnClickStopLoading(msg.pSender);
+ }
+ else if (name.Compare(L"btn_loading_delete") == 0) {
+ OnClickDeleteLoading(msg.pSender);
+ }
+ return;
}
- else if (msg.pSender->GetName().Compare(L"btn_stop_loading") == 0) {
- OnClickStopLoading(msg.pSender);
+ if (name.Compare(L"btn_finish_delete") == 0) {
+ OnClickFinishLoading(msg.pSender);
}
- else if (msg.pSender->GetName().Compare(L"btn_delete_loading") == 0) {
- OnClickDeleteLoading(msg.pSender);
+ else if (name.Compare(L"btn_close") == 0) {
+ Close();
+ }
+ else if (name.Compare(L"btn_download") == 0) {
+ assert(wnd_parse_);
+ wnd_parse_->CenterWindow();
+ wnd_parse_->ShowWindow();
}
}
@@ -224,20 +249,20 @@ bool WndMain::AddLoadingItem(const shared_ptr& task)
assert(item);
UINT_PTR task_ptr = (UINT_PTR)task.get();
item->SetTag(task_ptr);
- CControlUI* pCtrl = NULL;
- pCtrl = item->FindSubControl(L"lbl_name");
- if (pCtrl) {
- pCtrl->SetText(task->title.c_str());
- pCtrl->SetToolTip(task->title.c_str());
- }
- pCtrl = item->FindSubControl(L"lbl_icon");
- if (pCtrl) {
+ CControlUI* ctrl = NULL;
+ ctrl = item->FindSubControl(L"lbl_name");
+ if (ctrl) {
+ ctrl->SetText(task->title.c_str());
+ ctrl->SetToolTip(task->title.c_str());
+ }
+ ctrl = item->FindSubControl(L"lbl_icon");
+ if (ctrl) {
if (PathFileExists(task->img.c_str()))
- pCtrl->SetBkImage(task->img.c_str());
+ ctrl->SetBkImage(task->img.c_str());
}
- pCtrl = item->FindSubControl(L"lbl_state");
- if (pCtrl)
- pCtrl->SetText(L"ڲѯϢ");
+ ctrl = item->FindSubControl(L"lbl_state");
+ if (ctrl)
+ ctrl->SetText(L"ڲѯϢ");
//Ϣ
item->OnNotify += MakeDelegate(this, &WndMain::OnNotifyListItem);
list_loading_->Add(item);
@@ -249,6 +274,36 @@ bool WndMain::AddLoadingItem(const shared_ptr& task)
return true;
}
+bool WndMain::AddFinishItem(const shared_ptr& task)
+{
+ CDialogBuilder builder;
+ auto item = dynamic_cast(builder.Create(L"item_finish.xml", (LPCTSTR)0, this, &m_pm));
+ assert(item);
+ UINT_PTR task_ptr = (UINT_PTR)task.get();
+ item->SetTag(task_ptr);
+ CControlUI* ctrl = NULL;
+ ctrl = item->FindSubControl(L"lbl_name");
+ if (ctrl) {
+ ctrl->SetText(task->title.c_str());
+ ctrl->SetToolTip(task->title.c_str());
+ }
+ ctrl = item->FindSubControl(L"lbl_icon");
+ if (ctrl) {
+ if (PathFileExists(task->img.c_str()))
+ ctrl->SetBkImage(task->img.c_str());
+ }
+ ctrl = item->FindSubControl(L"lbl_size");
+ if (ctrl) {
+ ctrl->SetText(string_utils::SecondsToString(task->duration).c_str());
+ }
+ ctrl = item->FindSubControl(L"lbl_date");
+ if (ctrl) {
+ ctrl->SetText(string_utils::TimeStampToString(task->ctime, false).c_str());
+ }
+ list_finish_->Add(item);
+ return true;
+}
+
bool WndMain::OnNotifySelectLoadingListItem(void* param)
{
TNotifyUI* notify = reinterpret_cast(param);
@@ -274,7 +329,12 @@ void WndMain::OnClickStopLoading(CControlUI* sender)
void WndMain::OnClickDeleteLoading(CControlUI* sender)
{
- ::PostMessage(m_hWnd, WM_MAINWND_MSGBOX, WPARAM_DELETE_LOADING_ITEM, (LPARAM)sender);
+ ::PostMessage(m_hWnd, WM_MAINWND_MSGBOX, WPARAM_DELETE_LIST_ITEM, (LPARAM)sender);
+}
+
+void WndMain::OnClickFinishLoading(CControlUI* sender)
+{
+ ::PostMessage(m_hWnd, WM_MAINWND_MSGBOX, WPARAM_DELETE_LIST_ITEM, (LPARAM)sender);
}
bool WndMain::OnNotifyListItem(void* param)
@@ -296,8 +356,8 @@ LRESULT WndMain::OnMsgMsgbox(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
- case MsgWparam::WPARAM_DELETE_LOADING_ITEM:
- OnWparamDeleteLoadingItem(lParam);
+ case MsgWparam::WPARAM_DELETE_LIST_ITEM:
+ OnWparamDeleteItem(lParam);
break;
default:
break;
@@ -305,17 +365,23 @@ LRESULT WndMain::OnMsgMsgbox(WPARAM wParam, LPARAM lParam)
return 0;
}
-LRESULT WndMain::OnWparamDeleteLoadingItem(LPARAM lParam)
+LRESULT WndMain::OnWparamDeleteItem(LPARAM lParam)
{
- UINT result = ShowMsgBox(MessageIconType::ICON_ASK, L"ȷɾأ");
+ UINT result = ShowMsgBox(MessageIconType::ICON_ASK, L"ȷɾ");
if (result == IDOK) {
auto sender = reinterpret_cast(lParam);
assert(sender);
auto item = sender->GetParent();
assert(item);
UINT_PTR task_id = (UINT_PTR)lParam;
- DOWNLOAD_SERVICE()->DeleteLoadingTask(task_id);
- list_loading_->Remove(item);
+ if (list_loading_->GetItemIndex(item) > -1) {
+ DOWNLOAD_SERVICE()->DeleteLoadingTask(task_id);
+ list_loading_->Remove(item);
+ }
+ else {
+ DOWNLOAD_SERVICE()->DeleteFinishTask(task_id);
+ list_finish_->Remove(item);
+ }
}
return 0;
}
@@ -326,14 +392,34 @@ LRESULT WndMain::OnMsgDecode(WPARAM wParam, LPARAM lParam)
DecodeErrorCode code = static_cast(lParam);
auto iter = map_loading_items_.find(task_id);
if (iter == map_loading_items_.end()) {
- LOG(ERROR) << "NotifyStatus δҵض";
+ LOG(ERROR) << "NotifyStatus δҵؽڵ";
+ return -1;
+ }
+ auto task = DOWNLOAD_SERVICE()->FindLoadingTask(task_id);
+ if (task == nullptr) {
+ LOG(ERROR) << "OnMsgNotifyStatus ûҵض";
return -1;
}
if (code == DecodeErrorCode::ERROR_SUCCESS) {
-
+ task->status = download::DownloadStatus::STATUS_FINISH;
}
else {
+ task->status = download::DownloadStatus::STATUS_FAILED;
+ }
+ // ״̬
+ ::PostMessage(m_hWnd, WM_MAINWND_NOTIFY_STATUS, (WPARAM)task_id, (LPARAM)0);
+ return 0;
+}
+LRESULT WndMain::OnMsgNotifyStatus(WPARAM wParam, LPARAM lParam)
+{
+ UINT_PTR task_id = (UINT_PTR)wParam;
+ void* param = (void*)lParam;
+ auto task = DOWNLOAD_SERVICE()->FindLoadingTask(task_id);
+ if (task == nullptr) {
+ LOG(ERROR) << "OnMsgNotifyStatus ûҵض";
+ return -1;
}
+ NotifyStatus(task, param);
return 0;
}
diff --git a/src/BVLoader/wnd/wnd_main.h b/src/BVLoader/wnd/wnd_main.h
index ebb7eb9..1c38af4 100644
--- a/src/BVLoader/wnd/wnd_main.h
+++ b/src/BVLoader/wnd/wnd_main.h
@@ -43,25 +43,26 @@ class WndMain
DECLARE_CTRL_TYPE(list_finish_, CListUI, L"list_finish")
END_INIT_CTRL
BEGIN_BIND_CTRL
- BIND_CTRL(L"btn_close", &WndMain::OnNotifyClose)
- BIND_CTRL(L"btn_download", &WndMain::OnNotifyDownload)
END_BIND_CTRL
- bool OnNotifyClose(void* param);
- bool OnNotifyDownload(void* param);
+
void Notify(TNotifyUI& msg) override;
void OnClick(TNotifyUI& msg) override;
bool AddLoadingItem(const shared_ptr& task);
+ bool AddFinishItem(const shared_ptr& task);
+
bool OnNotifySelectLoadingListItem(void* param);
void OnClickStartLoading(CControlUI* sender);
void OnClickStopLoading(CControlUI* sender);
void OnClickDeleteLoading(CControlUI* sender);
+ void OnClickFinishLoading(CControlUI* sender);
bool OnNotifyListItem(void* param);
UINT ShowMsgBox(MessageIconType icon, LPCWSTR info);
LRESULT OnMsgMsgbox(WPARAM wParam, LPARAM lParam);
- LRESULT OnWparamDeleteLoadingItem(LPARAM lParam);
+ LRESULT OnWparamDeleteItem(LPARAM lParam);
LRESULT OnMsgDecode(WPARAM wParam, LPARAM lParam);
+ LRESULT OnMsgNotifyStatus(WPARAM wParam, LPARAM lParam);
private:
bool need_exit_ = false;
diff --git a/src/BVLoader/wnd/wnd_parse.cpp b/src/BVLoader/wnd/wnd_parse.cpp
index 8b8b956..855906d 100644
--- a/src/BVLoader/wnd/wnd_parse.cpp
+++ b/src/BVLoader/wnd/wnd_parse.cpp
@@ -210,6 +210,9 @@ void WndParse::OnTaskGetSelectPlayerUrl(LPARAM lParam)
combobox_->RemoveAll();
auto service = DOWNLOAD_SERVICE();
service->AddTask(info->url, video_info_->title, image_path_, video_info_->author, video_info_->duration, video_info_->ctime);
+ url_edit_->SetText(L"");
+ cover_->SetBkImage(kDefaultCover);
+ ShowWindow(false, false);
}
void WndParse::OnTaskDownloadCover(LPARAM lParam)