Browse Source

Don't call resized() in VideoComponent::loadAsync() on platforms which don't have a proper implementation to allow the method to be called from user threads

tags/2021-05-28
ed 5 years ago
parent
commit
6b0ac50684
2 changed files with 25 additions and 20 deletions
  1. +22
    -20
      modules/juce_video/playback/juce_VideoComponent.cpp
  2. +3
    -0
      modules/juce_video/playback/juce_VideoComponent.h

+ 22
- 20
modules/juce_video/playback/juce_VideoComponent.cpp View File

@@ -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<void(const URL&, Result)> callback)
@@ -87,7 +70,7 @@ void VideoComponent::loadAsync (const URL& url, std::function<void(const URL&, R
#if JUCE_ANDROID || JUCE_IOS || JUCE_MAC
pimpl->loadAsync (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<class FileOrURL>
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

+ 3
- 0
modules/juce_video/playback/juce_VideoComponent.h View File

@@ -179,6 +179,9 @@ private:
void resized() override;
void timerCallback() override;
template<class FileOrURL>
Result loadInternal (const FileOrURL&, bool);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VideoComponent)
};


Loading…
Cancel
Save