mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +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:
@ -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)
|
bool CVideoPlayer::openAndPlayVideoImpl(const VideoPath & name, const Point & position, bool useOverlay, bool stopOnKey)
|
||||||
{
|
{
|
||||||
CVideoInstance instance;
|
CVideoInstance instance;
|
||||||
CAudioInstance audio;
|
|
||||||
|
|
||||||
auto extractedAudio = audio.extractAudio(name);
|
auto extractedAudio = getAudio(name);
|
||||||
int audioHandle = CCS->soundh->playSound(extractedAudio);
|
int audioHandle = CCS->soundh->playSound(extractedAudio);
|
||||||
|
|
||||||
if (!instance.openInput(name))
|
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)
|
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;
|
CAudioInstance audio;
|
||||||
return audio.extractAudio(videoToOpen);
|
return audio.extractAudio(videoToOpen);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user