package com.tencent.mm.plugin.appbrand.jsapi.video;

import android.view.View;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.appbrand.jsapi.base.c;
import com.tencent.mm.plugin.appbrand.jsapi.coverview.CoverViewContainer;
import com.tencent.mm.plugin.appbrand.jsapi.e;
import com.tencent.mm.sdk.platformtools.ab;
import org.json.JSONException;
import org.json.JSONObject;

public final class j extends c {
    private static final int CTRL_INDEX = 87;
    public static final String NAME = "updateVideoPlayer";

    public final int r(JSONObject jSONObject) {
        AppMethodBeat.i(126568);
        int optInt = jSONObject.optInt("videoPlayerId");
        AppMethodBeat.o(126568);
        return optInt;
    }

    public final boolean c(e eVar, int i, View view, JSONObject jSONObject) {
        AppMethodBeat.i(126569);
        ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView : videoPlayerId=%d", new Object[]{Integer.valueOf(i)});
        if (view instanceof CoverViewContainer) {
            AppBrandVideoView appBrandVideoView = (AppBrandVideoView) ((CoverViewContainer) view).ah(AppBrandVideoView.class);
            if (appBrandVideoView == null) {
                ab.e("MicroMsg.JsApiUpdateVideoPlayer", "view not AppBrandVideoView");
                AppMethodBeat.o(126569);
                return false;
            }
            try {
                if (jSONObject.has("showDanmuBtn")) {
                    appBrandVideoView.setShowDanmakuBtn(jSONObject.getBoolean("showDanmuBtn"));
                }
            } catch (JSONException e) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"showDanmuBtn", e.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("danmuList")) {
                    appBrandVideoView.setDanmakuItemList(jSONObject.getJSONArray("danmuList"));
                }
            } catch (JSONException e2) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"danmuList", e2.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("objectFit")) {
                    appBrandVideoView.setObjectFit(jSONObject.getString("objectFit"));
                }
            } catch (JSONException e22) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"objectFit", e22.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("autoplay")) {
                    appBrandVideoView.setAutoPlay(jSONObject.getBoolean("autoplay"));
                }
            } catch (JSONException e222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"autoplay", e222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("showBasicControls")) {
                    appBrandVideoView.setIsShowBasicControls(jSONObject.getBoolean("showBasicControls"));
                }
            } catch (JSONException e2222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"showBasicControls", e2222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("poster")) {
                    appBrandVideoView.setCover$16da05f7(jSONObject.getString("poster"));
                }
            } catch (JSONException e22222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"poster", e22222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("direction")) {
                    appBrandVideoView.setFullScreenDirection(jSONObject.getInt("direction"));
                }
            } catch (Exception e3) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"direction", e3.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("muted")) {
                    appBrandVideoView.setMute(jSONObject.getBoolean("muted"));
                }
            } catch (JSONException e222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"muted", e222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("loop")) {
                    appBrandVideoView.setLoop(jSONObject.getBoolean("loop"));
                }
            } catch (JSONException e2222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"loop", e2222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("data")) {
                    appBrandVideoView.setCookieData(jSONObject.getString("data"));
                }
            } catch (JSONException e22222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"data", e22222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("pageGesture")) {
                    appBrandVideoView.setPageGesture(jSONObject.getBoolean("pageGesture"));
                }
            } catch (JSONException e222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"pageGesture", e222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("pageGestureInFullscreen")) {
                    appBrandVideoView.setPageGestureInFullscreen(jSONObject.getBoolean("pageGestureInFullscreen"));
                }
            } catch (JSONException e2222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"pageGestureInFullscreen", e2222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("showControlProgress")) {
                    appBrandVideoView.setShowControlProgress(jSONObject.getBoolean("showControlProgress"));
                }
            } catch (JSONException e22222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"showControlProgress", e22222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("showProgress")) {
                    appBrandVideoView.setShowProgress(jSONObject.getBoolean("showProgress"));
                }
            } catch (JSONException e222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"showProgress", e222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("showFullScreenBtn")) {
                    appBrandVideoView.setShowFullScreenBtn(jSONObject.getBoolean("showFullScreenBtn"));
                }
            } catch (JSONException e2222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"showFullScreenBtn", e2222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("showPlayBtn")) {
                    appBrandVideoView.setShowPlayBtn(jSONObject.getBoolean("showPlayBtn"));
                }
            } catch (JSONException e22222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"showPlayBtn", e22222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("showCenterPlayBtn")) {
                    appBrandVideoView.setShowCenterPlayBtn(jSONObject.getBoolean("showCenterPlayBtn"));
                }
            } catch (JSONException e222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"showCenterPlayBtn", e222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("enableProgressGesture")) {
                    appBrandVideoView.eq(jSONObject.getBoolean("enableProgressGesture"));
                }
            } catch (JSONException e2222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"enableProgressGesture", e2222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("duration")) {
                    appBrandVideoView.setDuration(jSONObject.getInt("duration"));
                }
            } catch (JSONException e22222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"disableScroll", e22222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("hide") && jSONObject.getBoolean("hide")) {
                    ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView hide stop");
                    appBrandVideoView.stop();
                }
            } catch (JSONException e222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"hide", e222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("initialTime")) {
                    appBrandVideoView.setInitialTime((double) jSONObject.getInt("initialTime"));
                }
            } catch (JSONException e2222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"initialTime", e2222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("needEvent")) {
                    if (jSONObject.getBoolean("needEvent")) {
                        int i2;
                        if (appBrandVideoView.hZf != null) {
                            i2 = 1;
                        } else {
                            i2 = 0;
                        }
                        if (i2 == 0) {
                            appBrandVideoView.setCallback(new k(appBrandVideoView, eVar));
                        }
                    } else {
                        appBrandVideoView.setCallback(null);
                    }
                }
            } catch (JSONException e22222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"needEvent", e22222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("showMuteBtn")) {
                    appBrandVideoView.setShowMuteBtn(jSONObject.getBoolean("showMuteBtn"));
                }
            } catch (JSONException e222222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"showMuteBtn", e222222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("title")) {
                    appBrandVideoView.setTitle(jSONObject.getString("title"));
                }
            } catch (JSONException e2222222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"title", e2222222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("playBtnPosition")) {
                    appBrandVideoView.setPlayBtnPosition(jSONObject.getString("playBtnPosition"));
                }
            } catch (JSONException e22222222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"playBtnPosition", e22222222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("enablePlayGesture")) {
                    appBrandVideoView.setEnablePlayGesture(jSONObject.getBoolean("enablePlayGesture"));
                }
            } catch (JSONException e222222222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"enablePlayGesture", e222222222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("autoPauseIfOpenNative")) {
                    appBrandVideoView.setAutoPauseIfOpenNative(jSONObject.getBoolean("autoPauseIfOpenNative"));
                }
            } catch (JSONException e2222222222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"autoPauseIfOpenNative", e2222222222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("autoPauseIfNavigate")) {
                    appBrandVideoView.setAutoPauseIfNavigate(jSONObject.getBoolean("autoPauseIfNavigate"));
                }
            } catch (JSONException e22222222222222222222222222) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"autoPauseIfNavigate", e22222222222222222222222222.getLocalizedMessage()});
            }
            try {
                if (jSONObject.has("filePath")) {
                    appBrandVideoView.e(jSONObject.getString("filePath"), jSONObject.optBoolean("live"), jSONObject.optInt("duration"));
                }
            } catch (JSONException e4) {
                ab.i("MicroMsg.JsApiUpdateVideoPlayer", "onUpdateView param=%s exp=%s", new Object[]{"filePath", e4.getLocalizedMessage()});
            }
            AppMethodBeat.o(126569);
            return true;
        }
        ab.w("MicroMsg.JsApiUpdateVideoPlayer", "the view(%s) is not a instance of CoverViewContainer", new Object[]{Integer.valueOf(i)});
        AppMethodBeat.o(126569);
        return false;
    }
}
