diff --git a/modules/juce_video/playback/juce_VideoComponent.cpp b/modules/juce_video/playback/juce_VideoComponent.cpp index 07ce04f31b..6c8cce0874 100644 --- a/modules/juce_video/playback/juce_VideoComponent.cpp +++ b/modules/juce_video/playback/juce_VideoComponent.cpp @@ -51,29 +51,12 @@ VideoComponent::~VideoComponent() Result VideoComponent::load (const File& file) { - #if JUCE_ANDROID || JUCE_IOS - ignoreUnused (file); - jassertfalse; - return Result::fail ("load() is not supported on this platform. Use loadAsync() instead."); - #else - auto r = pimpl->load (file); - resized(); - return r; - #endif + return loadInternal (file, false); } Result VideoComponent::load (const URL& url) { - #if JUCE_ANDROID || JUCE_IOS - // You need to use loadAsync on Android & iOS. - ignoreUnused (url); - jassertfalse; - return Result::fail ("load() is not supported on this platform. Use loadAsync() instead."); - #else - auto r = pimpl->load (url); - resized(); - return r; - #endif + return loadInternal (url, false); } void VideoComponent::loadAsync (const URL& url, std::function callback) @@ -87,7 +70,7 @@ void VideoComponent::loadAsync (const URL& url, std::functionloadAsync (url, callback); #else - auto result = load (url); + auto result = loadInternal (url, true); callback (url, result); #endif } @@ -158,6 +141,25 @@ void VideoComponent::timerCallback() resized(); } +template +Result VideoComponent::loadInternal (const FileOrURL& fileOrUrl, bool async) +{ + #if JUCE_ANDROID || JUCE_IOS + ignoreUnused (fileOrUrl, async); + + // You need to use loadAsync on Android & iOS. + jassertfalse; + return Result::fail ("load() is not supported on this platform. Use loadAsync() instead."); + #else + auto result = pimpl->load (fileOrUrl); + + if (! async) + resized(); + + return result; + #endif +} + #endif } // namespace juce diff --git a/modules/juce_video/playback/juce_VideoComponent.h b/modules/juce_video/playback/juce_VideoComponent.h index a41c169f78..99f0a1473f 100644 --- a/modules/juce_video/playback/juce_VideoComponent.h +++ b/modules/juce_video/playback/juce_VideoComponent.h @@ -179,6 +179,9 @@ private: void resized() override; void timerCallback() override; + template + Result loadInternal (const FileOrURL&, bool); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VideoComponent) };