#include "my_dubbing_callback.h"
#include <iostream>

using namespace DUBBING;
using namespace std;

void MyDubbbingCallBack::onDownload(int percent, int index, int count)
{
	std::cout << "download resources file count:" << count << " index: " << index << " percent: " << percent << std::endl;
}

void MyDubbbingCallBack::onComplete()
{
    std::cout << "end" << endl;
}

void MyDubbbingCallBack::onError()
{
    std::cout << "error" << endl;
}

void MyDubbbingCallBack::onActionResult(DubbingAction actionType, DubbingRetCode retCode, const std::string& msg)
{
    std::cout << "action result" << endl;
    if (actionType == PREPARE)
    {
        if (retCode == SUCCESS)
        {
            if (m_engine)
            {
                m_engine->start();
            }
        }
        else
        {
            std::cout << "PREPARE failed" << std::endl;
        }
    }
    else if (actionType == SET_VOICE)
    {
        if (retCode == SUCCESS)
        {
            m_hasSetVoice = true;
        }
        else
        {
            std::cout << "SET_VOICE failed" << std::endl;
        }
    }
}

void MyDubbbingCallBack::setDubbingEngine(IDubbingEngine* engine)
{
    m_engine = engine;
}

bool MyDubbbingCallBack::hasSetVoice()
{
    return m_hasSetVoice;
}
