-
-
Save Reputeless/3d527302d459792f7a5e1094d30d0529 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <Siv3D.hpp> // OpenSiv3D v0.6.3 | |
VideoTexture LoadVideoFromResource(const FilePathView resourcePath, const FilePathView temporaryFilePath, const Loop loop) | |
{ | |
# if SIV3D_PLATFORM(WINDOWS) | |
if (not FileSystem::Exists(temporaryFilePath)) | |
{ | |
Print << U"ファイルをコピー"; | |
BinaryReader reader{ resourcePath }; | |
if (not reader) | |
{ | |
return{}; | |
} | |
BinaryWriter writer{ temporaryFilePath }; | |
int64 copySize = reader.size(); | |
constexpr int64 BlockSize = (1024 * 64); | |
Array<Byte> buffer(BlockSize); | |
while (copySize) | |
{ | |
const int64 readSize = Min(copySize, BlockSize); | |
reader.read(buffer.data(), readSize); | |
writer.write(buffer.data(), readSize); | |
copySize -= readSize; | |
} | |
} | |
else | |
{ | |
Print << U"キャッシュが存在"; | |
} | |
return VideoTexture{ temporaryFilePath, loop }; | |
# else | |
return VideoTexture{ resourcePath, loop }; | |
# endif | |
} | |
void Main() | |
{ | |
const FilePath resourcePath = Resource(U"example/video/river.mp4"); | |
const FilePath temporaryFilePath = (FileSystem::TemporaryDirectoryPath() + U"MyApp/river.mp4"); | |
Print << resourcePath; | |
Print << temporaryFilePath; | |
const VideoTexture videoTexture = LoadVideoFromResource(resourcePath, temporaryFilePath, Loop::Yes); | |
while (System::Update()) | |
{ | |
videoTexture.advance(); | |
videoTexture.scaled(0.5).draw(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment