mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Fix handling of missing video files
This commit is contained in:
parent
540bd16e7b
commit
31349f3052
@ -79,12 +79,17 @@ static std::unique_ptr<CInputStream> findVideoData(const VideoPath & videoToOpen
|
||||
if(CResourceHandler::get()->existsResource(lowQualityVideo))
|
||||
return CResourceHandler::get()->load(lowQualityVideo);
|
||||
|
||||
return CResourceHandler::get()->load(lowQualityVideoWithDir);
|
||||
if(CResourceHandler::get()->existsResource(lowQualityVideoWithDir))
|
||||
return CResourceHandler::get()->load(lowQualityVideoWithDir);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void FFMpegStream::openInput(const VideoPath & videoToOpen)
|
||||
bool FFMpegStream::openInput(const VideoPath & videoToOpen)
|
||||
{
|
||||
input = findVideoData(videoToOpen);
|
||||
|
||||
return input != nullptr;
|
||||
}
|
||||
|
||||
void FFMpegStream::openContext()
|
||||
@ -436,7 +441,8 @@ int FFMpegStream::findVideoStream()
|
||||
|
||||
std::pair<std::unique_ptr<ui8 []>, si64> CAudioInstance::extractAudio(const VideoPath & videoToOpen)
|
||||
{
|
||||
openInput(videoToOpen);
|
||||
if (!openInput(videoToOpen))
|
||||
return { nullptr, 0};
|
||||
openContext();
|
||||
openCodec(findAudioStream());
|
||||
|
||||
@ -523,7 +529,9 @@ bool CVideoPlayer::openAndPlayVideoImpl(const VideoPath & name, const Point & po
|
||||
auto extractedAudio = audio.extractAudio(name);
|
||||
int audioHandle = CCS->soundh->playSound(extractedAudio);
|
||||
|
||||
instance.openInput(name);
|
||||
if (!instance.openInput(name))
|
||||
return true;
|
||||
|
||||
instance.openVideo();
|
||||
instance.prepareOutput(scale, useOverlay);
|
||||
|
||||
@ -589,7 +597,9 @@ std::unique_ptr<IVideoInstance> CVideoPlayer::open(const VideoPath & name, bool
|
||||
{
|
||||
auto result = std::make_unique<CVideoInstance>();
|
||||
|
||||
result->openInput(name);
|
||||
if (!result->openInput(name))
|
||||
return nullptr;
|
||||
|
||||
result->openVideo();
|
||||
result->prepareOutput(scaleToScreen, false);
|
||||
result->loadNextFrame(); // prepare 1st frame
|
||||
|
@ -57,7 +57,7 @@ protected:
|
||||
public:
|
||||
virtual ~FFMpegStream();
|
||||
|
||||
void openInput(const VideoPath & fname);
|
||||
bool openInput(const VideoPath & fname);
|
||||
};
|
||||
|
||||
class CAudioInstance final : public FFMpegStream
|
||||
|
@ -154,6 +154,7 @@ std::string EResTypeHelper::getEResTypeAsString(EResType type)
|
||||
MAP_ENUM(TTF_FONT)
|
||||
MAP_ENUM(IMAGE)
|
||||
MAP_ENUM(VIDEO)
|
||||
MAP_ENUM(VIDEO_LOW_QUALITY)
|
||||
MAP_ENUM(SOUND)
|
||||
MAP_ENUM(ARCHIVE_ZIP)
|
||||
MAP_ENUM(ARCHIVE_LOD)
|
||||
|
Loading…
Reference in New Issue
Block a user