目的:想在世界里,寻找已有的FileMediaSource,运行时动态加载入媒体地址url,然后正常播放媒体。现状:从xml中读取媒体地址,打算用迭代器获得世界中所需的FileMediaSource,然后传入地址,再执行play。
问题:使用TObjectIterator遍历世界时,编译器总会显示以下内容
============================output============================
Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:E:\UnrealEngine-release\Engine\Source\Runtime\Core\Public\Containers/Array.h] [Line: 596]
Array index out of bounds: 1 from an array of size 1
UE4Editor.exe has triggered a breakpoint.
============================output============================
源码时这样的:
==========================-==code=============================
============================h=============================
#include "CoreMinimal.h"
#include "XmlParser.h"
#include "FileMediaSource.h"
#include "GameFramework/GameModeBase.h"
#include "PathChangeModeBase.generated.h"
UCLASS()
class VR_TEST1_API APathChangeModeBase : public AGameModeBase
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "Xml")
void ReadXmlParser(const FString &_XmlPath);
UFUNCTION(BlueprintCallable, Category = "Xml")
FString GetXmlPath();
UFUNCTION(BlueprintCallable, Category = "Xml")
void GetFileMediaFromUrl(const FString &_MediaPath);
private:
//FString MediaPath;
};
========================cpp==================================
void APathChangeModeBase::GetFileMediaFromUrl(const FString &_MediaPath)
{
for (TObjectIterator<UFileMediaSource> Iterator; Iterator ; ++Iterator)
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, "I find you!");
//Iterator->FilePath = _MediaPath;
}
}
==========================-==code=============================
补充:已经排除其他函数问题,加入迭代器后才出现问题的~
求解:这问题如何解决?或者有没有其他方法实现目的···(表示已经被坑好些天了┭┮﹏┭┮)
|