package com.bytedance.ies.xelement.alphavideo;

import X.2sG;
import X.3DL;
import X.4Ms;
import X.7lW;
import X.7tl;
import X.7xU;
import X.7y5;
import X.86q;
import X.9lJ;
import X.C1114Pah;
import X.C3230QLb;
import X.C3231QLc;
import X.C4228Qjp;
import X.C4232Qjt;
import X.C4237Qjy;
import X.C4238Qjz;
import X.C4239Qk0;
import X.C4240Qk1;
import X.C4241Qk2;
import X.C4243Qk4;
import X.C4244Qk5;
import X.C4246Qk7;
import X.C4247Qk8;
import X.C4248Qk9;
import X.C4250QkB;
import X.C4251QkC;
import X.C4252QkD;
import X.C4253QkE;
import X.C4255QkG;
import X.C4256QkH;
import X.C4398QmZ;
import X.C4502QoF;
import X.C4513QoQ;
import X.Hwv;
import X.INQ;
import X.L8o;
import X.L8s;
import X.LAm;
import X.LBI;
import X.LC0;
import X.LDI;
import X.LVh;
import X.LXn;
import X.M12;
import X.P9E;
import X.PZN;
import X.Q39;
import X.QD9;
import X.QDF;
import X.QHV;
import X.QIL;
import X.QJW;
import X.QNL;
import X.QWV;
import X.QZZ;
import X.TlS;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.view.ViewGroup;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.google.gson.s;
import com.lynx.react.bridge.Callback;
import com.lynx.react.bridge.JavaOnlyMap;
import com.lynx.react.bridge.ReadableMap;
import com.lynx.tasm.base.LLog;
import com.lynx.tasm.behavior.ui.view.UISimpleView;
import com.ss.android.socialbase.downloader.model.DownloadTask;
import com.ss.android.ugc.aweme.live.alphaplayer.Configuration;
import com.ss.android.ugc.aweme.live.alphaplayer.controller.IPlayerController;
import com.ss.android.ugc.aweme.live.alphaplayer.controller.PlayerController;
import com.ss.android.ugc.aweme.live.alphaplayer.listener.AlphaPlayerAction;
import com.ss.android.ugc.aweme.live.alphaplayer.listener.IMonitor;
import com.ss.android.ugc.aweme.live.alphaplayer.model.DataSource;
import com.ss.android.ugc.aweme.live.alphaplayer.player.DefaultSystemPlayer;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import kotlin.h.b.n;
import kotlin.o.y;

public final class LynxAlphaVideo extends UISimpleView<C4241Qk2> {
    public static final C4256QkH LJIILJJIL = new C4256QkH((byte) 0);
    public IPlayerController LIZ;
    public DataSource LIZIZ;
    public boolean LIZJ = true;
    public boolean LIZLLL = true;
    public 3DL<L8o> LJ;
    public L8s LJFF;
    public boolean LJI;
    public Bitmap LJII;
    public String LJIIIIZZ = Q39.LIZJ;
    public long LJIIIZ;
    public boolean LJIIJ;
    public final List<Integer> LJIIJJI = new ArrayList();
    public final List<Integer> LJIIL = new ArrayList();
    public int LJIILIIL = -1;
    public Set<String> LJIILL;
    public TlS LJIILLIIL;
    public boolean LJIIZILJ;
    public boolean LJIJ;
    public final LDI LJIJI;

    static {
        Covode.recordClassIndex(32023);
    }

    public final void LIZ(String str, Map<String, Object> map) {
        C4398QmZ qmZ;
        C4513QoQ qoQ;
        Set<String> set = this.LJIILL;
        if (set != null) {
            String str2 = str;
            if (set.contains(str2) && (qmZ = this.mContext) != null && (qoQ = qmZ.LJFF) != null) {
                qoQ.LIZ((C4502QoF) new QWV(this, map, str2, getSign(), str2));
            }
        }
    }

    public final void onDetach() {
        super.onDetach();
        IPlayerController iPlayerController = this.LIZ;
        if (iPlayerController != null) {
            iPlayerController.detachAlphaView((ViewGroup) this.mView);
        }
    }

    private final JavaOnlyMap LIZ() {
        JavaOnlyMap javaOnlyMap = new JavaOnlyMap();
        javaOnlyMap.putBoolean("success", true);
        javaOnlyMap.putMap("data", new JavaOnlyMap());
        return javaOnlyMap;
    }

    public final void onAttach() {
        super.onAttach();
        IPlayerController iPlayerController = this.LIZ;
        if (iPlayerController != null && this.LIZJ) {
            iPlayerController.attachAlphaView((ViewGroup) this.mView);
        }
    }

    public final void onLayoutUpdated() {
        super.onLayoutUpdated();
        IPlayerController iPlayerController = this.LIZ;
        if (iPlayerController == null) {
            n.LIZ();
        }
        iPlayerController.getView().layout(0, 0, getWidth(), getHeight());
    }

    public final void destroy() {
        super.destroy();
        IPlayerController iPlayerController = this.LIZ;
        if (iPlayerController == null) {
            n.LIZ();
        }
        iPlayerController.release();
        IPlayerController iPlayerController2 = this.LIZ;
        if (iPlayerController2 == null) {
            n.LIZ();
        }
        iPlayerController2.detachAlphaView((ViewGroup) this.mView);
        ((C4241Qk2) this.mView).setMPoster((Bitmap) null);
        ((C4241Qk2) this.mView).setMLastFrame((Bitmap) null);
        IPlayerController iPlayerController3 = this.LIZ;
        if (!(iPlayerController3 instanceof PlayerController)) {
            iPlayerController3 = null;
        }
        PlayerController playerController = (PlayerController) iPlayerController3;
        if (playerController != null) {
            playerController.setFirstGLFrameListener((INQ) null);
        }
        IPlayerController iPlayerController4 = this.LIZ;
        if (iPlayerController4 != null) {
            iPlayerController4.withVideoAction((AlphaPlayerAction) null);
        }
        IPlayerController iPlayerController5 = this.LIZ;
        if (iPlayerController5 != null) {
            iPlayerController5.setMonitor((IMonitor) null);
        }
    }

    @QNL(LIZ = "frame-hold", LJFF = false)
    public final void setFrameHold(boolean z) {
        this.LJIIJ = z;
    }

    public static Context LIZ(C4398QmZ qmZ) {
        Context applicationContext = qmZ.getApplicationContext();
        if (7lW.LIZJ && applicationContext == null) {
            return 7lW.LIZ;
        }
        return applicationContext;
    }

    public static Context LIZIZ(Context context) {
        Context applicationContext = context.getApplicationContext();
        if (7lW.LIZJ && applicationContext == null) {
            return 7lW.LIZ;
        }
        return applicationContext;
    }

    public final void setEvents(Map<String, LC0> map) {
        Set<String> set;
        super.setEvents(map);
        if (map != null) {
            set = map.keySet();
        } else {
            set = null;
        }
        this.LJIILL = set;
    }

    @QNL(LIZ = "keep-last-frame", LJFF = false)
    public final void setKeepLastFrame(boolean z) {
        if (this.LJIJ != z) {
            DataSource dataSource = this.LIZIZ;
            if (dataSource != null) {
                dataSource.setAutoRelease(!z);
            }
            this.LJIJ = z;
        }
    }

    @QNL(LIZ = "loop", LJFF = false)
    public final void setLoop(boolean z) {
        this.LJIIZILJ = z;
        DataSource dataSource = this.LIZIZ;
        if (dataSource != null) {
            dataSource.setLoop(z);
        }
    }

    public static File LIZJ(Context context) {
        if (4Ms.LIZIZ != null && 4Ms.LJ) {
            return 4Ms.LIZIZ;
        }
        File cacheDir = context.getCacheDir();
        4Ms.LIZIZ = cacheDir;
        return cacheDir;
    }

    @QNL(LIZ = "autoplay", LJFF = true)
    public final void setAutoPlay(boolean z) {
        this.LIZJ = z;
        T t = this.mView;
        if (t != null) {
            ((C4241Qk2) t).setMAutoPlay(z);
            return;
        }
        throw new 7xU("null cannot be cast to non-null type com.bytedance.ies.xelement.alphavideo.LynxAlphaVideoView");
    }

    @QNL(LIZ = "last-frame")
    public final void setLastFrame(String str) {
        if (str != null) {
            C4232Qjt qjt = new C4232Qjt(new C4246Qk7(this, str));
            qjt.LIZ(new C4247Qk8(this));
            qjt.LIZIZ(new C4244Qk5(this, str));
        }
    }

    @QNL(LIZ = "poster")
    public final void setPoster(String str) {
        if (str != null) {
            C4232Qjt qjt = new C4232Qjt(new C4248Qk9(this, str));
            qjt.LIZ(new C4252QkD(this));
            qjt.LIZIZ(new C4250QkB(this, str));
        }
    }

    @QNL(LIZ = "src")
    public final void setSrc(String str) {
        if (!TextUtils.isEmpty(str)) {
            this.LIZIZ = null;
            this.LJIIIIZZ = Q39.LIZJ;
            if (this.LIZLLL) {
                str = LVh.LIZ(this.mContext, str);
            }
            String decode = URLDecoder.decode(str, "UTF-8");
            n.LIZ(decode, Q39.LIZJ);
            this.LJIIIIZZ = decode;
            3DL<L8o> r2 = this.LJ;
            if (r2 != null) {
                this.LJFF = null;
                r2.LIZ(decode, new LAm(this, decode), new LBI(this, decode));
                return;
            }
            LIZ(decode);
        }
    }

    public final String LIZJ(String str) {
        byte[] bArr;
        try {
            MessageDigest instance = MessageDigest.getInstance("MD5");
            Charset charset = 9lJ.LIZ;
            if (str != null) {
                byte[] bytes = str.getBytes(charset);
                n.LIZ(bytes, Q39.LIZJ);
                instance.update(bytes);
                bArr = instance.digest();
                n.LIZ(bArr, Q39.LIZJ);
                StringBuilder sb = new StringBuilder();
                for (byte b : bArr) {
                    String hexString = Integer.toHexString(b & 255);
                    if (hexString.length() < 2) {
                        hexString = "0".concat(String.valueOf(hexString));
                    }
                    sb.append(hexString);
                }
                String sb2 = sb.toString();
                n.LIZ(sb2, Q39.LIZJ);
                return sb2;
            }
            throw new 7xU("null cannot be cast to non-null type java.lang.String");
        } catch (NoSuchAlgorithmException unused) {
            Charset charset2 = 9lJ.LIZ;
            if (str != null) {
                bArr = str.getBytes(charset2);
                n.LIZ(bArr, Q39.LIZJ);
            } else {
                throw new 7xU("null cannot be cast to non-null type java.lang.String");
            }
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: LIZ */
    public C4241Qk2 createView(Context context) {
        Context context2;
        C4241Qk2 qk2 = new C4241Qk2(context);
        Configuration configuration = new Configuration();
        Context context3 = null;
        if (context != null) {
            context2 = LIZIZ(context);
        } else {
            context2 = null;
        }
        configuration.setContext(context2);
        configuration.setLifecycleOwner(qk2);
        configuration.setAlphaVideoViewType(1);
        C4240Qk1 qk1 = new C4240Qk1(this);
        C4243Qk4 qk4 = new C4243Qk4(this);
        try {
            if (context != null) {
                context3 = LIZIZ(context);
            }
            TlS tlS = new TlS(context3);
            this.LJIILLIIL = tlS;
            this.LIZ = PlayerController.get(configuration, tlS);
        } catch (Exception e) {
            LIZ("init CustomPlayerImpl failed and try to use DefaultSystemPlayer, the exception is ".concat(String.valueOf(e)), this.LJIIIIZZ, -10);
            this.LIZ = PlayerController.get(configuration, new DefaultSystemPlayer());
        }
        IPlayerController iPlayerController = this.LIZ;
        if (iPlayerController != null) {
            iPlayerController.withVideoAction(qk1);
        }
        IPlayerController iPlayerController2 = this.LIZ;
        if (iPlayerController2 != null) {
            iPlayerController2.setMonitor(qk4);
        }
        PlayerController playerController = this.LIZ;
        if (playerController instanceof PlayerController) {
            if (playerController != null) {
                playerController.setFirstGLFrameListener(new C4251QkC(this));
            } else {
                throw new 7xU("null cannot be cast to non-null type com.ss.android.ugc.aweme.live.alphaplayer.controller.PlayerController");
            }
        }
        IPlayerController iPlayerController3 = this.LIZ;
        if (iPlayerController3 != null) {
            iPlayerController3.setProgressListener(new C4238Qjz(this), 5);
        }
        return qk2;
    }

    public final void LIZ(String str) {
        try {
            this.LJI = false;
            LLog.LIZIZ("x-alpha-video", "legacySetSrc, directUrl is ".concat(String.valueOf(str)));
            if (str != null) {
                Uri parse = Uri.parse(str);
                this.LIZIZ = null;
                n.LIZ(parse, Q39.LIZJ);
                String scheme = parse.getScheme();
                if (scheme != null) {
                    int hashCode = scheme.hashCode();
                    if (hashCode != 3143036) {
                        if (hashCode != 3213448) {
                            if (hashCode == 99617003) {
                                if (!scheme.equals("https")) {
                                    return;
                                }
                            } else {
                                return;
                            }
                        } else if (!scheme.equals("http")) {
                            return;
                        }
                        if (y.LIZJ(str, ".zip", false)) {
                            DownloadTask with = QZZ.with(this.mContext);
                            with.url(str);
                            with.name(parse.getLastPathSegment());
                            C4398QmZ qmZ = this.mContext;
                            n.LIZ(qmZ, Q39.LIZJ);
                            Context LIZ2 = LIZ(qmZ);
                            n.LIZ(LIZ2, Q39.LIZJ);
                            File LIZJ2 = LIZJ(LIZ2);
                            n.LIZ(LIZJ2, Q39.LIZJ);
                            with.savePath(LIZJ2.getAbsolutePath());
                            with.mainThreadListener(new LXn(this, parse, str));
                            with.download();
                            return;
                        }
                        LIZ("resource type is not support", this.LJIIIIZZ, -13);
                    } else if (scheme.equals("file")) {
                        try {
                            if (y.LIZJ(str, ".zip", false)) {
                                String path = parse.getPath();
                                n.LIZ(path, Q39.LIZJ);
                                String path2 = parse.getPath();
                                n.LIZ(path2, Q39.LIZJ);
                                LIZ(path, path2);
                                return;
                            }
                            this.LIZIZ = LIZIZ(parse.getPath() + '/');
                            LIZ("ready", LIZ(1, "load resource success", (JavaOnlyMap) null));
                            if (this.LIZIZ != null && this.LIZJ) {
                                IPlayerController iPlayerController = this.LIZ;
                                if (iPlayerController == null) {
                                    n.LIZ();
                                }
                                iPlayerController.attachAlphaView((ViewGroup) this.mView);
                                IPlayerController iPlayerController2 = this.LIZ;
                                if (iPlayerController2 == null) {
                                    n.LIZ();
                                }
                                iPlayerController2.startWithLastFrameHold(this.LIZIZ, this.LJIIJ);
                            }
                        } catch (Exception e) {
                            LIZ("parse config.json failed, resource is " + str + ", error msg is " + e, this.LJIIIIZZ, -3);
                        }
                    }
                }
            }
        } catch (Exception e2) {
            LLog.LIZLLL("x-alpha-video", e2.toString());
        }
    }

    public final DataSource LIZIZ(String str) {
        MethodCollector.i(11309);
        StringBuilder sb = new StringBuilder();
        BufferedReader bufferedReader = new BufferedReader(new FileReader(str + "config.json"));
        try {
            BufferedReader bufferedReader2 = bufferedReader;
            2sG r1 = new 2sG();
            while (true) {
                String readLine = bufferedReader2.readLine();
                r1.element = readLine;
                if (readLine == null) {
                    break;
                }
                sb.append((String) r1.element);
                sb.append("\n");
            }
            7y5.LIZ(bufferedReader, (Throwable) null);
            try {
                C4255QkG qkG = (C4255QkG) P9E.LIZ().LIZ(sb.toString(), C4255QkG.class);
                if (qkG == null) {
                    LIZ("fileModel is null", this.LJIIIIZZ, -14);
                    MethodCollector.o(11309);
                    return null;
                }
                DataSource dataSource = new DataSource();
                if (qkG.LIZ != null) {
                    DataSource.DataInfo dataInfo = new DataSource.DataInfo(str + qkG.LIZ.LIZ);
                    dataInfo.setScaleType(qkG.LIZ.LIZIZ);
                    dataInfo.setVersion(qkG.LIZ.LIZJ);
                    dataInfo.setTotalFrame(qkG.LIZ.LIZLLL);
                    dataInfo.setVideoWidth(qkG.LIZ.LJI);
                    dataInfo.setVideoHeight(qkG.LIZ.LJII);
                    dataInfo.setActualWidth(qkG.LIZ.LJ);
                    dataInfo.setActualHeight(qkG.LIZ.LJFF);
                    dataInfo.setAlphaArea(qkG.LIZ.LJIIIIZZ);
                    dataInfo.setRgbArea(qkG.LIZ.LJIIIZ);
                    dataInfo.setMasks(qkG.LIZ.LJIIJ);
                    dataSource.setPortraitDataInfo(dataInfo);
                }
                if (qkG.LIZIZ != null) {
                    DataSource.DataInfo dataInfo2 = new DataSource.DataInfo(str + qkG.LIZIZ.LIZ);
                    dataInfo2.setScaleType(qkG.LIZIZ.LIZIZ);
                    dataInfo2.setVersion(qkG.LIZIZ.LIZJ);
                    dataInfo2.setTotalFrame(qkG.LIZIZ.LIZLLL);
                    dataInfo2.setVideoWidth(qkG.LIZIZ.LJI);
                    dataInfo2.setVideoHeight(qkG.LIZIZ.LJII);
                    dataInfo2.setActualWidth(qkG.LIZIZ.LJ);
                    dataInfo2.setActualHeight(qkG.LIZIZ.LJFF);
                    dataInfo2.setAlphaArea(qkG.LIZIZ.LJIIIIZZ);
                    dataInfo2.setRgbArea(qkG.LIZIZ.LJIIIZ);
                    dataInfo2.setMasks(qkG.LIZIZ.LJIIJ);
                    dataSource.setLandscapeDataInfo(dataInfo2);
                }
                if (n.LIZ(getProps().get("keep-last-frame"), true)) {
                    dataSource.setAutoRelease(false);
                }
                if (n.LIZ(getProps().get("loop"), true)) {
                    dataSource.setLoop(true);
                }
                MethodCollector.o(11309);
                return dataSource;
            } catch (s e) {
                LIZ("parse config.json failed, error msg is ".concat(String.valueOf(e)), this.LJIIIIZZ, -3);
            }
        } catch (Throwable th) {
            7y5.LIZ(bufferedReader, th);
            MethodCollector.o(11309);
            throw th;
        }
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public LynxAlphaVideo(C4398QmZ qmZ, String str) {
        super(qmZ);
        M12.LIZ(qmZ, str);
        this.LJIJI = new LDI(str);
    }

    public final void LIZ(String str, C3231QLc qLc) {
        M12.LIZ(str, qLc);
        String LIZ2 = LVh.LIZ(this.mContext, str);
        n.LIZ(LIZ2, Q39.LIZJ);
        QDF LIZ3 = QDF.LIZ(Uri.parse(LIZ2));
        QJW.LIZ(LIZ3);
        QIL<C1114Pah<QD9>> LIZIZ2 = QHV.LIZJ().LIZIZ(LIZ3.LIZ(), "x-alpha-video");
        if (LIZIZ2 == null) {
            qLc.LIZ();
            return;
        }
        CountDownLatch countDownLatch = new CountDownLatch(1);
        Hwv qLb = new C3230QLb(qLc, countDownLatch, LIZIZ2);
        LIZIZ2.LIZ(qLb, PZN.LIZ());
        try {
            if (!countDownLatch.await(3, TimeUnit.SECONDS)) {
                qLb.LIZIZ(LIZIZ2);
            }
        } catch (InterruptedException unused) {
            qLb.LIZIZ(LIZIZ2);
        }
    }

    @7tl
    public final void getDuration(ReadableMap readableMap, Callback callback) {
        M12.LIZ(readableMap, callback);
        JavaOnlyMap javaOnlyMap = new JavaOnlyMap();
        if (this.mView == null || this.LIZ == null) {
            javaOnlyMap.putString("message", "view is not exist");
            callback.invoke(new Object[]{1, javaOnlyMap});
            return;
        }
        try {
            javaOnlyMap.putBoolean("success", true);
            IPlayerController iPlayerController = this.LIZ;
            if (iPlayerController == null) {
                n.LIZ();
            }
            int duration = iPlayerController.getDuration();
            JavaOnlyMap javaOnlyMap2 = new JavaOnlyMap();
            javaOnlyMap2.putInt("duration", duration);
            javaOnlyMap.putMap("data", javaOnlyMap2);
            callback.invoke(new Object[]{0, javaOnlyMap});
        } catch (Exception e) {
            javaOnlyMap.putString("message:", e.getMessage());
            callback.invoke(new Object[]{1, javaOnlyMap});
        }
    }

    @7tl
    public final void isPlaying(ReadableMap readableMap, Callback callback) {
        M12.LIZ(readableMap, callback);
        JavaOnlyMap javaOnlyMap = new JavaOnlyMap();
        if (this.mView == null || this.LIZ == null) {
            javaOnlyMap.putString("message", "view is not exist");
            callback.invoke(new Object[]{1, javaOnlyMap});
            return;
        }
        try {
            javaOnlyMap.putBoolean("success", true);
            IPlayerController iPlayerController = this.LIZ;
            if (iPlayerController == null) {
                n.LIZ();
            }
            boolean isPlaying = iPlayerController.isPlaying();
            JavaOnlyMap javaOnlyMap2 = new JavaOnlyMap();
            javaOnlyMap2.putBoolean("isPlaying", isPlaying);
            javaOnlyMap.putMap("data", javaOnlyMap2);
            callback.invoke(new Object[]{0, javaOnlyMap});
        } catch (Exception e) {
            javaOnlyMap.putString("message:", e.getMessage());
            callback.invoke(new Object[]{1, javaOnlyMap});
        }
    }

    @7tl
    public final void pause(ReadableMap readableMap, Callback callback) {
        IPlayerController iPlayerController;
        M12.LIZ(readableMap, callback);
        JavaOnlyMap javaOnlyMap = new JavaOnlyMap();
        if (this.mView == null || (iPlayerController = this.LIZ) == null) {
            javaOnlyMap.putString("message", "view is not exist");
            callback.invoke(new Object[]{1, javaOnlyMap});
            return;
        }
        try {
            iPlayerController.pause();
            callback.invoke(new Object[]{0, javaOnlyMap});
        } catch (Exception e) {
            javaOnlyMap.putString("message:", e.getMessage());
            callback.invoke(new Object[]{1, javaOnlyMap});
        }
    }

    @7tl
    public final void play(ReadableMap readableMap, Callback callback) {
        IPlayerController iPlayerController;
        M12.LIZ(readableMap, callback);
        JavaOnlyMap javaOnlyMap = new JavaOnlyMap();
        if (this.mView == null || (iPlayerController = this.LIZ) == null) {
            javaOnlyMap.putString("message", "view is not exist");
            callback.invoke(new Object[]{1, javaOnlyMap});
            return;
        }
        try {
            if (iPlayerController.isPlaying() || this.LIZIZ == null) {
                callback.invoke(new Object[]{1, javaOnlyMap});
                return;
            }
            IPlayerController iPlayerController2 = this.LIZ;
            if (iPlayerController2 == null) {
                n.LIZ();
            }
            iPlayerController2.attachAlphaView((ViewGroup) this.mView);
            IPlayerController iPlayerController3 = this.LIZ;
            if (iPlayerController3 == null) {
                n.LIZ();
            }
            iPlayerController3.startWithLastFrameHold(this.LIZIZ, this.LJIIJ);
            callback.invoke(new Object[]{0, javaOnlyMap});
        } catch (Exception e) {
            javaOnlyMap.putString("message:", e.getMessage());
            callback.invoke(new Object[]{1, javaOnlyMap});
        }
    }

    @7tl
    public final void release(ReadableMap readableMap, Callback callback) {
        IPlayerController iPlayerController;
        M12.LIZ(readableMap, callback);
        JavaOnlyMap LIZ2 = LIZ();
        if (this.mView == null || (iPlayerController = this.LIZ) == null) {
            LIZ2.putString("message", "view is not exist");
            callback.invoke(new Object[]{1, LIZ2});
            return;
        }
        try {
            iPlayerController.release();
            callback.invoke(new Object[]{0, LIZ2});
        } catch (Exception e) {
            LIZ2.putString("message:", e.getMessage());
            callback.invoke(new Object[]{1, LIZ2});
        }
    }

    @7tl
    public final void resume(ReadableMap readableMap, Callback callback) {
        IPlayerController iPlayerController;
        M12.LIZ(readableMap, callback);
        JavaOnlyMap LIZ2 = LIZ();
        if (this.mView == null || (iPlayerController = this.LIZ) == null || iPlayerController.isPlaying()) {
            LIZ2.putString("message", "view is not exist");
            callback.invoke(new Object[]{1, LIZ2});
            return;
        }
        try {
            IPlayerController iPlayerController2 = this.LIZ;
            if (iPlayerController2 == null) {
                n.LIZ();
            }
            iPlayerController2.attachAlphaView((ViewGroup) this.mView);
            IPlayerController iPlayerController3 = this.LIZ;
            if (iPlayerController3 == null) {
                n.LIZ();
            }
            iPlayerController3.resume();
            callback.invoke(new Object[]{0, LIZ2});
        } catch (Exception e) {
            LIZ2.putString("message:", e.getMessage());
            callback.invoke(new Object[]{1, LIZ2});
        }
    }

    @7tl
    public final void stop(ReadableMap readableMap, Callback callback) {
        IPlayerController iPlayerController;
        M12.LIZ(readableMap, callback);
        JavaOnlyMap javaOnlyMap = new JavaOnlyMap();
        if (this.mView == null || (iPlayerController = this.LIZ) == null) {
            javaOnlyMap.putString("message", "view is not exist");
            callback.invoke(new Object[]{1, javaOnlyMap});
            return;
        }
        try {
            iPlayerController.stop();
            callback.invoke(new Object[]{0, javaOnlyMap});
        } catch (Exception e) {
            javaOnlyMap.putString("message:", e.getMessage());
            callback.invoke(new Object[]{1, javaOnlyMap});
        }
    }

    @7tl
    public final void subscribeUpdateEvent(ReadableMap readableMap, Callback callback) {
        M12.LIZ(readableMap);
        int i = readableMap.getInt("ms");
        LLog.LIZIZ("x-alpha-video", "subscribeUpdateEvent: ".concat(String.valueOf(i)));
        if (!this.LJIIJJI.contains(Integer.valueOf(i))) {
            this.LJIIJJI.add(Integer.valueOf(i));
            List<Integer> list = this.LJIIJJI;
            if (list.size() > 1) {
                86q.LIZ(list, new C4228Qjp());
            }
            if (callback != null) {
                callback.invoke(new Object[]{0});
            }
        } else if (callback != null) {
            callback.invoke(new Object[]{1, "already subscribeUpdateEvent with " + i + " milliseconds"});
        }
    }

    @7tl
    public final void unsubscribeUpdateEvent(ReadableMap readableMap, Callback callback) {
        M12.LIZ(readableMap);
        int i = readableMap.getInt("ms");
        if (this.LJIIJJI.contains(Integer.valueOf(i))) {
            this.LJIIJJI.remove(Integer.valueOf(i));
            if (callback != null) {
                callback.invoke(new Object[]{0});
            }
        } else if (callback != null) {
            callback.invoke(new Object[]{1, i + " milliseconds is not subscribed"});
        }
    }

    public final void LIZ(String str, String str2) {
        C4232Qjt qjt = new C4232Qjt(new C4237Qjy(this, str, str2));
        qjt.LIZ(new C4239Qk0(this));
        qjt.LIZIZ(new C4253QkE(this));
    }

    public final Map<String, Object> LIZ(int i, String str, JavaOnlyMap javaOnlyMap) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("code", Integer.valueOf(i));
        linkedHashMap.put("msg", str);
        if (javaOnlyMap != null) {
            linkedHashMap.put("data", javaOnlyMap);
        }
        return linkedHashMap;
    }

    public final void LIZ(String str, String str2, int i) {
        LIZ("error", LIZ(i, str, (JavaOnlyMap) null));
        this.LJIJI.LIZ(str2, str, i);
        LLog.LIZLLL("x-alpha-video", str);
    }
}
