}
}
-void LottieView::loadFromData(const std::string &jsonData, const std::string &key)
+void LottieView::loadFromData(const std::string &jsonData, const std::string &key, const std::string &resourcePath)
{
- if (mPlayer = Animation::loadFromData(jsonData, key)) {
+ if (mPlayer = Animation::loadFromData(jsonData, key, resourcePath)) {
mFrameRate = mPlayer->frameRate();
mTotalFrame = mPlayer->totalFrame();
} else {
void setSize(int w, int h);
void setPos(int x, int y);
void setFilePath(const char *filePath);
- void loadFromData(const std::string &jsonData, const std::string &key);
+ void loadFromData(const std::string &jsonData, const std::string &key, const std::string &resourcePath="");
void show();
void hide();
void loop(bool loop);
* @internal
*/
static std::unique_ptr<Animation>
- loadFromData(std::string jsonData, const std::string &key);
+ loadFromData(std::string jsonData, const std::string &key, const std::string &resourcePath="");
/**
* @brief Returns default framerate of the Lottie resource.
*
* @param[in] data The JSON string data.
* @param[in] key the string that will be used to cache the JSON string data.
+ * @param[in] resource_path the path that will be used to load external resource needed by the JSON data.
*
* @return Animation object that can build the contents of the
* Lottie resource represented by JSON string data.
* @ingroup Lottie_Animation
* @internal
*/
-LOT_EXPORT Lottie_Animation *lottie_animation_from_data(const char *data, const char *key);
+LOT_EXPORT Lottie_Animation *lottie_animation_from_data(const char *data, const char *key, const char *resource_path);
/**
* @brief Free given Animation object resource.
}
}
-LOT_EXPORT Lottie_Animation_S *lottie_animation_from_data(const char *data, const char *key)
+LOT_EXPORT Lottie_Animation_S *lottie_animation_from_data(const char *data, const char *key, const char *resourcePath)
{
- if (auto animation = Animation::loadFromData(data, key) ) {
+ if (auto animation = Animation::loadFromData(data, key, resourcePath) ) {
Lottie_Animation_S *handle = new Lottie_Animation_S();
handle->mAnimation = std::move(animation);
return handle;
* @param path add the details
*/
std::unique_ptr<Animation>
-Animation::loadFromData(std::string jsonData, const std::string &key)
+Animation::loadFromData(std::string jsonData, const std::string &key, const std::string &resourcePath)
{
if (jsonData.empty()) {
vWarning << "jason data is empty";
}
LottieLoader loader;
- if (loader.loadFromData(std::move(jsonData), key)) {
+ if (loader.loadFromData(std::move(jsonData), key,
+ (resourcePath.empty() ? " " : resourcePath))) {
auto animation = std::unique_ptr<Animation>(new Animation);
animation->d->init(loader.model());
return animation;
return true;
}
-bool LottieLoader::loadFromData(std::string &&jsonData, const std::string &key)
+bool LottieLoader::loadFromData(std::string &&jsonData, const std::string &key, const std::string &resourcePath)
{
LottieFileCache &fileCache = LottieFileCache::get();
mModel = fileCache.find(key);
if (mModel) return true;
- LottieParser parser(const_cast<char *>(jsonData.c_str()));
+ LottieParser parser(const_cast<char *>(jsonData.c_str()), resourcePath.c_str());
mModel = parser.model();
fileCache.add(key, mModel);
{
public:
bool load(const std::string &filePath);
- bool loadFromData(std::string &&jsonData, const std::string &key);
+ bool loadFromData(std::string &&jsonData, const std::string &key, const std::string &resourcePath);
std::shared_ptr<LOTModel> model();
private:
std::shared_ptr<LOTModel> mModel;
class LottieParser {
public:
~LottieParser();
- LottieParser(char* str, const char *dir_path="");
+ LottieParser(char* str, const char *dir_path);
std::shared_ptr<LOTModel> model();
private:
LottieParserImpl *d;