using Assets.scripts.Datas;
using Assets.scripts.utils;
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class replayerBack : MonoBehaviour, IEventHandler
{

    Dictionary<string, EventChildItemBack> childEventHandlers = new Dictionary<string, EventChildItemBack>();
    protected GameScenUserInfo nowGameScenUser = null;
    NotifyEmptParam onByCloseHandler = null;
    private bool showAd = false;
    int playIdx = -1;
    private int mp4OperNext = -1;
    void onEvent(string name, EventChildItemBack func)
    {
        utilsTools.onEvent(this, name);
        childEventHandlers.Add(name, func);
    }
    public float betY = 0.5f;
    public GameObject mainShowView = null;
    // Start is called before the first frame update
    void Start()
    {
        utilsTools.resetGameObjectTreeSize(gameObject,(String path) =>
        {
            if (path.EndsWith("downButton")) return 1;
            if (path.EndsWith("playButton")) return 1;
            if (path.EndsWith("shareButton")) return 1;
            return 0;
        });
        onEvent("initViewShowData", onInitViewShowDataEvent);
        onEvent("gameViewOnInitEnd", onGameViewOnInitEndEvent);
        onEvent("onClick_saveOptions_msg", onClick_saveOptions_msg_Event);
        string json = "{\"append\":\"\",\"classId\":\"1,8,10,14\",\"displayDate\":\"20221102\",\"enterType\":\"0\",\"extraJson\":\"{\\\"cut_height\\\": 0, \\\"refer_drawer\\\": \\\"DoMyzu\\\"}\",\"extraType\":0,\"file\":\"https://d21z6ifg4bbv2v.cloudfront.net/tsgame/cc--EDgRpc_nHQru7H.zip\",\"highImg\":\"https://d21z6ifg4bbv2v.cloudfront.net/tspng/cc--EDgRpc_nHQru7H.png\",\"hybridType\":64,\"id\":\"cc--EDgRpc_nHQru7H\",\"originalJson\":\"https://d21z6ifg4bbv2v.cloudfront.net/tsjson/cc--EDgRpc_nHQru7H.json\",\"picAssets\":\"{\\\"pictureBin\\\": \\\"ccv1/production-pic/20221027/cc--EDgRpc_nHQru7H/zsD2ySwS4pJ25frj.p\\\", \\\"pictureThn4\\\": \\\"ccv1/production-pic/20221027/cc--EDgRpc_nHQru7H/V8ZvUuDlOEB7mifd.png\\\", \\\"pictureColorThn4\\\": \\\"ccv1/production-pic/20221027/cc--EDgRpc_nHQru7H/IDdMO8yT0fPPhUtU.jpg?x-oss-process\\u003dstyle/cc400\\\", \\\"pictureWallThn8\\\": \\\"ccv1/production-pic/20221027/cc--EDgRpc_nHQru7H/oWqHjCo5mQvXIVP_.png\\\", \\\"pictureWallColorThn8\\\": \\\"ccv1/production-pic/20221027/cc--EDgRpc_nHQru7H/IDdMO8yT0fPPhUtU.jpg?x-oss-process\\u003dstyle/cc800\\\"}\",\"pictureBin\":\"https://d21z6ifg4bbv2v.cloudfront.net/tsgame/cc--EDgRpc_nHQru7H_pictureBin.p\",\"pictureColorThn4\":\"https://d21z6ifg4bbv2v.cloudfront.net/tsgame/cc--EDgRpc_nHQru7H_pictureColorThn4.jpg\",\"pictureThn4\":\"https://d21z6ifg4bbv2v.cloudfront.net/tsgame/cc--EDgRpc_nHQru7H_pictureThn4.png\",\"schedule\":0,\"seriesName\":\"\",\"sid\":2967,\"sort\":80,\"type\":6}";
        utilsTools.setGDataByKey("NativeGameData", JsonUtility.FromJson<netLableImageItem>(json));
        utilsTools.addTimer_Update(gameObject, "_", (string n) =>
        {
            initData();
            return false;
        }, 5);
        string tuijian = "{\"status\":200,\"msg\":\"请求成功\",\"sign\":\"\",\"result\":{\"data\":[";
        for (int i = 0; i < 8; i++)
        {
            tuijian = tuijian + json + ",";
        }
        tuijian = tuijian + json + "],\"extras\":null},\"enc\":null,\"security\":\"\"}";
        utilsTools.addTimer_Sec(gameObject, "__", (string _) =>
        {
            onTuiJianBack(tuijian);
            return false;
        }, 1);
        transform.Find("gameEndOperBase/gameShowBase/btnsBase/saveOptions").gameObject.SetActive(false);
        showPageByJinDu(false);
        transform.Find("clear").gameObject.SetActive(false);
    }
    
    //GroupByAreaPtInfos.mapAllDatas
    protected void onTuiJianBack(string data)
    {
        NetLabelTypeData netLabelTypeData = JsonUtility.FromJson<NetLabelTypeData>(data);
        if (netLabelTypeData.status.Equals(200))
        {
            //netLabelTypeData.result.data;
            gridView grid = transform.Find("list").GetComponent<gridView>();//.gameObject.SetActive(true);
            grid.setData(netLabelTypeData.result.data.Count,(GameObject item,int idx, ListViewBackTypeEnum lvbt) =>
            {

            }, false);
        }
    }
    protected void initData()
    {
        netLableImageItem jsonData = utilsTools.getGDataByKey<netLableImageItem>("NativeGameData", null);
        if (jsonData == null)
        {
            Debug.LogError("no valid data");
            return;
        }
        utilsTools.setGDataByKey("imgId", jsonData.sid.ToString());
        utilsTools.setGameScenUserInfo(jsonData.id, jsonData.getLineUrl(), jsonData.getColorUrl(), jsonData.getJsonUrl(), jsonData.file);
        //utilsTools.httpGET(this, "{0}/app/v1/game/ts/imgSchedule?zygt=hzwz&tgtk=1&imgId={1}&uid={2}", true, (string id, string url, bool isSuccess, System.Object data) =>
        //{
        //    if (isSuccess)
        //    {
        //        HistoryClick historyClick = JsonUtility.FromJson<HistoryClick>(data as string);
        //        Debug.Log(data as string);
        //        utilsTools.sendEvent("updateSchedules");
        //        if (historyClick == null) return 0;
        //        string history = historyClick.getHistory();
        //        gameScenUserInfo.setShowAreaids(history);
        //        return 0;
        //    }
        //    else
        //    {
        //        return 1;
        //    }
        //}, utilsTools.getGDataByKey<String>("urlRoot", ""), jsonData.sid, utilsTools.getGDataByKey<String>("uid", "123456"));
        GameScenUserInfo gameScenUser = utilsTools.getGameScenUserInfo(jsonData.id);
        if (gameScenUser == null)
        {
            return;
        }
        if (jsonData != null)
        {
            gameScenUser.thumbnailUrl = jsonData.getSmallLineUrl();
        }
        utilsTools.sendEventObjectParams("initViewShowData", gameScenUser);
    }
    //onGameViewOnInitEndEvent
    void onGameViewOnInitEndEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects)
    {
        //Texture2D texture2D = mainShowView.GetComponent<Image>().sprite.texture;
        Color[] color = (Color[])objects[0]; // texture2D.GetPixels();
        short width = (short)objects[1];
        short height = (short)objects[2];
        //utilsTools.checkResetYuanJiao(color, width,height, 125);
        List<int> ints = utilsTools.getResetYuanJiaoOutList(width, height, 125);
        mainGameOneImageView mgoiv = transform.Find("gameEndOperBase/gameShowBase").GetComponent<mainGameOneImageView>();
        var finalAll = mgoiv.getfinalAllColor();
        Dictionary<int,bool> keyValuePairs = new Dictionary<int,bool>();
        for (int i = 0; i < ints.Count; i++)
        {
            int idx = ints[i];
            keyValuePairs.Add(idx, true );
        }
        List<Vector2Int> removeLists = new List<Vector2Int>();
        foreach (var item in GroupByAreaPtInfos.mapAllDatas)//因为有特意裁处空白保持圆角和长的非1:2
        {
            for (int i = 0; i < item.Value.Count; i++)
            {
                int idx = (int)item.Value[i];
                
                if (keyValuePairs.ContainsKey(idx))
                {
                    finalAll[idx].a = 0f;
                    color[idx].a = 0f;
                    removeLists.Add(new Vector2Int(item.Key, idx));
                }
            }
        }
        foreach (var item in removeLists)
        {
            short key = (short)item.x;
            GroupByAreaPtInfos.mapAllDatas[key].Remove(item.y);
        }
        onPlayButton(true);
    }
    void onInitViewShowDataEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects)
    {
        utilsTools.setGDataByKey("firstT", utilsTools.getTotalMillisecond());
        GameScenUserInfo gameScenUser = (GameScenUserInfo)objects[0];
        nowGameScenUser = gameScenUser;
        string zpath = utilsTools.getWritableByPath("outFiles/" + gameScenUser.id + ".zip");
        if (utilsTools.IsPhone == false)
            zpath = zpath.Replace("/", "\\");
        string suoluetu = gameScenUser.getColorImgLocalPath();//gameScenUser.getLocalThumbnailPath();
        Image image = mainShowView.GetComponent<Image>();
        image.color = new Color(1, 1, 1, 0);//未加载出来时候就透明化
        string key = gameScenUser.id + "_showAd";
        showAd = utilsDB.getDBBoolDataByKey(key, showAd);
        if (utilsTools.IsExistIO(suoluetu) == false)
        {
            utilsTools.httpDOWNIMG(this, gameScenUser.thumbnailUrl, suoluetu, (string id, string url, bool isSuccess, System.Object data) =>
            {
                return onDownColorImgHandler(id, url, isSuccess, data, suoluetu);
            });
        }
        else
        {
            utilsTools.loadLocalImage(this, suoluetu, (string id, string url, bool isSuccess, System.Object data) =>
            {
                if (isSuccess)
                {
                    Texture2D texture2d = data as Texture2D;
                    Texture2D texture2dpng;
                    RectTransform rectTransform = image.GetComponent<RectTransform>();
                    utilsTools.TextureJpg2Png(texture2d, out texture2dpng);//, (int)rectTransform.rect.width, (int)(rectTransform.rect.height * 1.45f));
                    Destroy(texture2d);
                    Sprite sprite = Sprite.Create(texture2dpng, new Rect(0, 0, texture2dpng.width, texture2dpng.height), new Vector2(0.5f, 0.5f));
                    image.sprite = sprite;
                    image.color = new Color(1, 1, 1, 1);
                    handlerLoadingPosition(image);
                }
                return 0;
            });
        }
        string outPath = GameScenUserInfo.getAllRoot();
        if (utilsTools.IsPhone == false)
        {
            outPath = outPath.Replace("/", "\\");
        }
        if(utilsTools.IsExistIO(gameScenUser.getLineImgLocalPath()) == false)
        {
            ZipUtility.unzipFileUrl(gameScenUser.file, zpath, outPath, this, (bool isOk) =>
            {
                onUnZipEndHandler(gameScenUser);
            }, "");
        }
        else
        {
            onUnZipEndHandler(gameScenUser);
        }
    }
    private void handlerLoadingPosition(Image image)
    {
        float width = image.sprite.texture.width;
        float height = image.sprite.texture.height;
        float bet = width / height;
        RectTransform rectTransform = image.GetComponent<RectTransform>();
        Vector2 offsetOutSize = new Vector2(10, 10);//new Vector2(7,7))
        RectTransform baseTransform = rectTransform.transform.parent.GetComponent<RectTransform>();
        Color[] colors = image.sprite.texture.GetPixels();
        transform.Find("gameEndOperBase/gameShowBase/btnsBase/downButton/ad").gameObject.SetActive(showAd);
        transform.Find("gameEndOperBase/gameShowBase/btnsBase/shareButton/ad").gameObject.SetActive(showAd);
        if (width.Equals(height))
        {
            utilsTools.addTimer_Update(gameObject, "_1", (String na) =>
            {
                RoundedRectangle roundedRectangle = transform.Find("gameEndOperBase/back").GetComponent<RoundedRectangle>();
                roundedRectangle.resetSize(new Vector2(width + offsetOutSize.x, height + offsetOutSize.y));
                return false;
            });
            
            utilsTools.checkResetYuanJiao(colors, image.sprite.texture.width, image.sprite.texture.height, 25);
            image.sprite.texture.SetPixels(colors);
            image.sprite.texture.Apply();
            return;
        }
        int offsetY = (int)(rectTransform.rect.width * betY);
        utilsTools.checkResetYuanJiao(colors, image.sprite.texture.width, image.sprite.texture.height, 25, 0, 0);// offsetY);
        image.sprite.texture.SetPixels(colors);
        image.sprite.texture.Apply();
        image.type = Image.Type.Sliced;
        Vector2 size = new Vector2(rectTransform.rect.width * 0.7f, rectTransform.rect.width * 1.4f);// rectTransform.rect.width, rectTransform.rect.width * 1.45f);
        rectTransform.sizeDelta = new Vector2(rectTransform.rect.width ,rectTransform.rect.width);
        rectTransform.localScale = new Vector3(0.7f, rectTransform.rect.width * 1.4f / rectTransform.rect.height);
        //rectTransform.localScale = new Vector2(1, 1.45f / 2.0f);
        //var rectTransform1 = transform.Find("Continue").GetComponent<RectTransform>();
        //float diff = rectTransform1.localPosition.y - rectTransform.localPosition.y;
        //rectTransform.localPosition = new Vector2(0, 0);
        //rectTransform1.sizeDelta = new Vector2(rectTransform1.sizeDelta.x, 100f);
        //rectTransform1.localPosition = new Vector2(0, 0 - size.y / 2 - 50);
        utilsTools.addTimer_Update(gameObject, "_1", (String na) =>
        {
            RoundedRectangle roundedRectangle = transform.Find("gameEndOperBase/back").GetComponent<RoundedRectangle>();
            roundedRectangle.resetSize(size + offsetOutSize);//7,7
            return false;
        },1);
        
    }
    int onDownColorImgHandler(string id, string url, bool isSuccess, System.Object data, string localpath)
    {
        if (isSuccess == false)
        {
            utilsTools.addTimer_Update(gameObject, "tryDownColorImg", (String name1) =>
            {
                utilsTools.httpDOWNIMG(this, url, localpath, (string id, string url, bool isSuccess, System.Object data) =>
                {
                    return onDownColorImgHandler(id, url, isSuccess, data, localpath);
                });
                return false;
            }, 60);
        }
        else
        {
            utilsTools.delTimeHandler(gameObject, "tryDownColorImg");
            Image image = mainShowView.GetComponent<Image>();
            Texture2D texture2d = data as Texture2D;
            Texture2D texture2dpng;
            RectTransform rectTransform = image.GetComponent<RectTransform>();
            utilsTools.TextureJpg2Png(texture2d, out texture2dpng,(int)rectTransform.rect.width*2,(int)rectTransform.rect.height*2);
            Destroy(texture2d);
            Sprite sprite = Sprite.Create(texture2dpng, new Rect(0, 0, texture2dpng.width, texture2dpng.height), new Vector2(0.5f, 0.5f));
            image.sprite = sprite;
            image.color = new Color(1, 1, 1, 1);
            this.handlerLoadingPosition(image);
        }
        return 0;
    }
    void onUnZipEndHandler(GameScenUserInfo gameScenUser)
    {
        mainGameOneImageView mgoiv = transform.Find("gameEndOperBase/gameShowBase").GetComponent<mainGameOneImageView>();
        mgoiv.loadGameImgId(gameScenUser,false);
    }
    // Update is called once per frame
    void Update()
    {   
    }
    public void onBack()
    {
        if(onByCloseHandler != null)
        {
            onByCloseHandler();
            onByCloseHandler = null;
        }
        showPageByJinDu(false);
    }
    public void onDelete()
    {
    }
    public void onReset()
    {
        if(nowGameScenUser != null)
        {
            string key = nowGameScenUser.id + "_showAd";
            utilsDB.setDBBoolDataByKey(key, false);
        }
    }
    public void onContinue()
    {
        utilsTools.sendEvent("CloseScenePrve");
        utilsTools.addTimer_Update(gameObject, "close", (String name) =>
        {
            Debug.Log("关闭");
            var gameBackJavaData = utilsTools.getGDataByKey<GameBackJavaData>("gameBackJavaData", null);
            gameBackJavaData.name = "replayer";
            if (gameBackJavaData == null)
            {
                utilsTools.setGDataByKey("NativeTempData", "error");
            }
            else
            {
                string tempJsondata = JsonUtility.ToJson(gameBackJavaData);
                utilsTools.setGDataByKey("NativeTempData", tempJsondata);
                Debug.Log(tempJsondata);
            }
            mainGameOneImageView mgoiv = transform.Find("gameEndOperBase/gameShowBase").GetComponent<mainGameOneImageView>();
            mgoiv.onClear();
            SceneManager.LoadScene("Scenes/MainGame");
            return false;
        }, 40);
    }
    
    public void onPlayButton(bool isfirst = false)
    {
        mainGameOneImageView mgoiv = transform.Find("gameEndOperBase/gameShowBase").GetComponent<mainGameOneImageView>();
        if (playIdx > 0)
        {
            utilsTools.delTimeHandler(gameObject, "play_123");
            mgoiv.showAllArea();
            playIdx = -1;
            return;
        }
        if (nowGameScenUser.areaInfoUseData.Count == 0 && isfirst == true)
        {
            nowGameScenUser.areaInfoUseData = new List<AreaInfoUseData>();
            foreach (var item in GroupByAreaPtInfos.mapAllDatas)
            {
                AreaInfoUseData area = new AreaInfoUseData();
                area.id = item.Key;
                nowGameScenUser.areaInfoUseData.Add(area);
            }
        }
        
        mgoiv.showAreaPrveClear(isfirst);
        utilsTools.delTimeHandler(gameObject, "play_123");
        playIdx = -1;
        int aa1 = utilsTools.getTotalMillisecond();
        utilsTools.addTimer_Update(gameObject, "play_123", (String _) =>
        {
            int setp = 6;
            for (int i = 0; i < setp; i++)
            {
                playIdx++;
                if (playIdx >= nowGameScenUser.areaInfoUseData.Count)
                {
                    playIdx = -1;
                    mgoiv.Apply();
                    return false;
                }
                short areaId = nowGameScenUser.areaInfoUseData[playIdx].id;
                mgoiv.showArea(areaId, null, false);
            }
            mgoiv.Apply();
            
            return true;
        }, 3, nowGameScenUser.areaInfoUseData.Count+2);
    }
    public void onShareBunttionNativeHandler(string json)
    {

    }
    public void onDownButton()
    {
        if (showAd)
        {
            utilsTools.showAd("inter", gameObject.name, "onShareBunttionNativeHandler");
            string key = nowGameScenUser.id + "_showAd";
            utilsDB.setDBBoolDataByKey(key, false);
            transform.Find("gameEndOperBase/gameShowBase/btnsBase/downButton/ad").gameObject.SetActive(false);
            transform.Find("gameEndOperBase/gameShowBase/btnsBase/shareButton/ad").gameObject.SetActive(false);
            
            return;
        }
        var saveOptions = transform.Find("gameEndOperBase/gameShowBase/btnsBase/saveOptions");
        var self = transform.Find("gameEndOperBase/gameShowBase/btnsBase/downButton");
        saveOptions.localPosition = new Vector3(self.localPosition.x, saveOptions.localPosition.y);
        saveOptions.gameObject.SetActive(true);
        mp4OperNext = 2;
    }
    public void onShareButton()
    {
        if (showAd)
        {
            utilsTools.showAd("inter",gameObject.name, "onShareBunttionNativeHandler");
            string key = nowGameScenUser.id + "_showAd";
            utilsDB.setDBBoolDataByKey(key, false);
            transform.Find("gameEndOperBase/gameShowBase/btnsBase/downButton/ad").gameObject.SetActive(false);
            transform.Find("gameEndOperBase/gameShowBase/btnsBase/shareButton/ad").gameObject.SetActive(false);
            return;
        }
        var saveOptions = transform.Find("gameEndOperBase/gameShowBase/btnsBase/saveOptions");
        var self = transform.Find("gameEndOperBase/gameShowBase/btnsBase/shareButton");
        saveOptions.localPosition = new Vector3(self.localPosition.x, saveOptions.localPosition.y);
        saveOptions.gameObject.SetActive(true);
        mp4OperNext = 1;
    }
    public void showPageByJinDu(bool isJinDu)
    {
        transform.Find("MoreLikeThis").gameObject.SetActive(!isJinDu);
        transform.Find("list").gameObject.SetActive(!isJinDu);
        transform.Find("gameEndOperBase/gameShowBase/btnsBase").gameObject.SetActive(!isJinDu);
        transform.Find("Continue").gameObject.SetActive(!isJinDu);
        transform.Find("close").gameObject.SetActive(isJinDu);
        transform.Find("inSaveProgress").gameObject.SetActive(isJinDu);
        var trans = transform.Find("gameEndOperBase").GetComponent<RectTransform>();
        Vector2 tempShejiPos = new Vector2(0, 151);
        if(isJinDu == false)
        {
            trans.localScale = new Vector3(1, 1);
        }
        else
        {
            trans.localScale = new Vector3(1.44f, 1.02f);
            tempShejiPos.y = -31;
        }
        Vector2 outPos1;
        utilsTools.DeviceAdaptationSize(tempShejiPos, out outPos1);
        trans.localPosition = outPos1;
    }
    private void onSaveToMp4Handler()
    {
        mainGameOneImageView mgoiv = transform.Find("gameEndOperBase/gameShowBase").GetComponent<mainGameOneImageView>();
        int width = 0;
        int height = 0;
        mgoiv.getSize(out width,out height);
        VideoHelp.Open("tempVideo", "E:\\test1.mp4", width, height, 5);
        onByCloseHandler = () =>
        {
            utilsTools.delTimeHandler(gameObject, "saveToMp4");
            mgoiv.showAllArea();
            playIdx = -1;
            VideoHelp.Close("tempVideo");
        };
        utilsTools.delTimeHandler(gameObject, "play_123");
        playIdx = -1;
        mgoiv.showAreaPrveClear(false);
        int idxflg = 0;
        showPageByJinDu(true);
        float size = (float)nowGameScenUser.areaInfoUseData.Count;
        gameObject.transform.Find("inSaveProgress/fore").gameObject.SetActive(true);
        gameObject.transform.Find("inSaveProgress/end").gameObject.SetActive(false);
        gameObject.transform.Find("inSaveProgress/progress").GetComponent<Image>().fillAmount = 0.0f;
        utilsTools.addTimer_Update(gameObject, "saveToMp4", (string name) =>
        {
            int aid = nowGameScenUser.areaInfoUseData[idxflg].id;
            float jindu = idxflg / size;
            idxflg++;
            mgoiv.showArea(aid, null);
            gameObject.transform.Find("inSaveProgress/progress").GetComponent<Image>().fillAmount = jindu;
            if(idxflg % 20 == 1)
                VideoHelp.PushColors("tempVideo", mgoiv.getColorByKey());
            if (idxflg == nowGameScenUser.areaInfoUseData.Count)
            {
                //showPageByJinDu(false);
                VideoHelp.PushColors("tempVideo", mgoiv.getColorByKey());
                VideoHelp.Close("tempVideo");
                onByCloseHandler = null;
                onCloseMp4Save(true);
            }
            return true;
        }, 5, nowGameScenUser.areaInfoUseData.Count);
    }
    public void onCloseMp4Save(bool isSuccesss = false)
    {
        if (isSuccesss == false)
        {
            mp4OperNext = -1;
        }
        else
        {
            if (mp4OperNext == 1)
            {
                Debug.Log("分享中");
                gameObject.transform.Find("inSaveProgress").gameObject.SetActive(false);
                utilsTools.share("", gameObject.name,"");
            }
            else
            {
                gameObject.transform.Find("inSaveProgress/fore").gameObject.SetActive(false);
                gameObject.transform.Find("inSaveProgress/end").gameObject.SetActive(true);
                Debug.Log("保存完成");
            }
        }
    }

    public void onEventHandler(string eventName, List<UnityEngine.Object> uobjects, List<System.Object> objects)
    {
        if (childEventHandlers.ContainsKey(eventName))
        {
            childEventHandlers[eventName](uobjects, objects);
        }
    }
    public void onClick_saveOptions_msg_Event(List<UnityEngine.Object> uobjects,List<System.Object> objects)
    {
        int typeId = (int)objects[0];
        if (typeId.Equals(0))
        {
            transform.Find("gameEndOperBase/gameShowBase/btnsBase/saveOptions").gameObject.SetActive(false);
        }else if (typeId.Equals(1))
        {

        }else if(typeId.Equals(2))
        {
            onSaveToMp4Handler();
        }
    }
}
