lottie/example: use loadfromData() api in demo app. 82/188382/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Tue, 4 Sep 2018 10:10:32 +0000 (19:10 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Tue, 4 Sep 2018 10:10:32 +0000 (19:10 +0900)
Change-Id: I8e5ce194f1795ca30ac8aad319ba25706a6023cf

example/demo.cpp
example/lottieview.cpp
example/lottieview.h

index 4bd2b8e..19a7180 100644 (file)
@@ -2,6 +2,8 @@
 #include "lottieview.h"
 #include<iostream>
 #include <stdio.h>
+#include <fstream>
+#include <sstream>
 using namespace std;
 
 static void
@@ -27,8 +29,14 @@ main(void)
    std::string filePath = DEMO_DIR;
    filePath +="mask.json";
 
+   std::ifstream f;
+   f.open(filePath);
+   std::stringstream buf;
+   buf << f.rdbuf();
+   f.close();
+
    LottieView *view = new LottieView(app->evas());
-   view->setFilePath(filePath.c_str());
+   view->loadFromData(buf.str().data(), "test_key");
    view->setPos(0, 0);
    view->setSize(800, 800);
    view->show();
index 4a1254c..cb8ce89 100644 (file)
@@ -242,6 +242,13 @@ void LottieView::setFilePath(const char *filePath)
     mTotalFrame = mPlayer->totalFrame();
 }
 
+void LottieView::loadFromData(const char *jsonData, const char *key)
+{
+    mPlayer->loadFromData(jsonData, key);
+    mFrameRate = mPlayer->frameRate();
+    mTotalFrame = mPlayer->totalFrame();
+}
+
 void LottieView::setSize(int w, int h)
 {
     if (mRenderMode) {
index c94247c..30098ff 100644 (file)
@@ -29,6 +29,7 @@ public:
     void setSize(int w, int h);
     void setPos(int x, int y);
     void setFilePath(const char *filePath);
+    void loadFromData(const char *jsonData, const char *key);
     void show();
     void hide();
     void loop(bool loop);