mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-04 00:15:53 +02:00
Merge pull request #4738 from IvanSavenko/external_audio
Loading separate audio file in place of audio stream embedded in video
This commit is contained in:
commit
7f6a80ed47
@ -608,9 +608,8 @@ std::pair<std::unique_ptr<ui8 []>, si64> CAudioInstance::extractAudio(const Vide
|
||||
bool CVideoPlayer::openAndPlayVideoImpl(const VideoPath & name, const Point & position, bool useOverlay, bool stopOnKey)
|
||||
{
|
||||
CVideoInstance instance;
|
||||
CAudioInstance audio;
|
||||
|
||||
auto extractedAudio = audio.extractAudio(name);
|
||||
auto extractedAudio = getAudio(name);
|
||||
int audioHandle = CCS->soundh->playSound(extractedAudio);
|
||||
|
||||
if (!instance.openInput(name))
|
||||
@ -684,6 +683,15 @@ std::unique_ptr<IVideoInstance> CVideoPlayer::open(const VideoPath & name, float
|
||||
|
||||
std::pair<std::unique_ptr<ui8[]>, si64> CVideoPlayer::getAudio(const VideoPath & videoToOpen)
|
||||
{
|
||||
AudioPath audioPath = videoToOpen.toType<EResType::SOUND>();
|
||||
AudioPath audioPathVideoDir = audioPath.addPrefix("VIDEO/");
|
||||
|
||||
if(CResourceHandler::get()->existsResource(audioPath))
|
||||
return CResourceHandler::get()->load(audioPath)->readAll();
|
||||
|
||||
if(CResourceHandler::get()->existsResource(audioPathVideoDir))
|
||||
return CResourceHandler::get()->load(audioPathVideoDir)->readAll();
|
||||
|
||||
CAudioInstance audio;
|
||||
return audio.extractAudio(videoToOpen);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user