Mirro1871
(Mirro1871)
1
/**
*
*/
class AsyncVideoPlayThreadTask : public FNonAbandonableTask {
public:
AsyncVideoPlayThreadTask(FGuid Id, FString Ul, FString Plat, UVideoPlayParam* Param);
~AsyncVideoPlayThreadTask();
// Required by UE4!
FORCEINLINE TStatId GetStatId() const {
RETURN_QUICK_DECLARE_CYCLE_STAT(AsyncVideoPlayThreadTask, STATGROUP_ThreadPoolAsyncTasks);
}
public:
void DoWork();
public:
FGuid UUid;
FString Url;
FString PlatType;
TSharedPtr<UVideoPlayParam, ESPMode::ThreadSafe> PlayParam;
};
AsyncVideoPlayThreadTask::AsyncVideoPlayThreadTask(FGuid Id, FString Ul, FString Plat, UVideoPlayParam* Param) {
UUid = Id;
Url = Ul;
PlatType = Plat;
PlayParam = MakeShareable(Param);
}
AsyncVideoPlayThreadTask::~AsyncVideoPlayThreadTask() {
//UE_LOG(LogTemp, Warning, TEXT("AsyncTaskDone"));
}
void AsyncVideoPlayThreadTask::DoWork() {
if (!IsInGameThread())
{
//
const TCHAR* tsUUid = *(UUid.ToString());
const TCHAR* tsUrl = *(Url);
const TCHAR* tsPlatType = *(PlatType);
//PlayParam->PlayHandle = Video_Decode_Play(TCHAR_TO_UTF8(tsUUid), TCHAR_TO_UTF8(tsUrl), nullptr, TCHAR_TO_UTF8(tsPlatType), &PlayParam->PstPlayReq);
//
AsyncTask(ENamedThreads::GameThread, [=]()
{
});
}
}
(new FAutoDeleteAsyncTask<AsyncVideoPlayThreadTask>(UUid, Url, PlatType, VideoPlay))->StartBackgroundTask();
Emaer
(Emaer)
2
Don’t use smart pointers with UObject
s.
If you need to hold UObject
pointer in non-UObject context then use TWeakObjectPtr
.