package xyz.netfly.api;

import androidx.emoji2.text.v;
import com.google.android.gms.measurement.internal.u1;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import tv.danmaku.ijk.media.player.ui.BasePlayerView;

/* JADX INFO: loaded from: classes3.dex */
public final class c {

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static volatile c f34899g;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public ScheduledExecutorService f34902c;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public WeakReference f34905f;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f34901b = 10;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public String f34903d = "";

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f34904e = false;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ExecutorService f34900a = Executors.newFixedThreadPool(3);

    public static /* synthetic */ void a(c cVar) {
        cVar.getClass();
        HashMap map = new HashMap();
        WeakReference weakReference = cVar.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) cVar.f34905f.get()).getCurrentPosition()));
        }
        cVar.e("PLAY_HEARTBEAT", map);
    }

    public static c b() {
        if (f34899g == null) {
            synchronized (c.class) {
                try {
                    if (f34899g == null) {
                        f34899g = new c();
                    }
                } finally {
                }
            }
        }
        return f34899g;
    }

    public final void c() {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_ENDED", map);
    }

    public final void d(int i10, String str) {
        HashMap mapO = u1.o("err_msg", str);
        mapO.put("err_code", Integer.valueOf(i10));
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            mapO.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_ERROR", mapO);
    }

    public final void e(String str, HashMap map) {
        if (this.f34904e) {
            return;
        }
        this.f34900a.execute(new v(this, map, str, 13));
    }

    public final void f() {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_EXIT", map);
    }

    public final void g(String str, LinkedHashMap linkedHashMap) {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        map.put("representation", linkedHashMap);
        map.put("segment_file", str);
        e("PLAY_LOADED_DATA", map);
    }

    public final void h() {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_PAUSED", map);
    }

    public final void i() {
        e("PLAY_ABORT", new HashMap());
    }

    public final void j() {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_PLAYING", map);
    }

    public final void k(float f10) {
        HashMap map = new HashMap();
        map.put("playback_rate", Float.valueOf(f10));
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_RATE_CHANGED", map);
    }

    public final void l(HashMap map) {
        HashMap map2 = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map2.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        map2.put("representation", map);
        e("PLAY_REPRESENTATION_SWITCH", map2);
    }

    public final void m() {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_RESUMED", map);
    }

    public final void n() {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_SEEKED", map);
    }

    public final void o() {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_SEEKING", map);
    }

    public final void p(int i10, int i11, String str, String str2) {
        this.f34903d = str;
        HashMap map = new HashMap();
        if (i10 == 2) {
            map.put("video_type", "movie");
        } else if (i10 == 3) {
            map.put("video_type", "tv_episodes");
        } else if (i10 == 6) {
            map.put("video_type", "live");
        }
        map.put("video_link", str2);
        map.put("video_id", Integer.valueOf(i11));
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
            map.put("duration", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getDuration()));
            map.put("playback_rate", Float.valueOf(((BasePlayerView) this.f34905f.get()).getSpeed()));
        }
        e("PLAY_START", map);
    }

    public final void q() {
        HashMap map = new HashMap();
        WeakReference weakReference = this.f34905f;
        if (weakReference != null && weakReference.get() != null) {
            map.put("current_time", Integer.valueOf(((BasePlayerView) this.f34905f.get()).getCurrentPosition()));
        }
        e("PLAY_WAITING", map);
    }

    public final void r() {
        if (this.f34904e) {
            return;
        }
        ScheduledExecutorService scheduledExecutorService = this.f34902c;
        if (scheduledExecutorService == null || scheduledExecutorService.isShutdown()) {
            ScheduledExecutorService scheduledExecutorServiceNewSingleThreadScheduledExecutor = Executors.newSingleThreadScheduledExecutor();
            this.f34902c = scheduledExecutorServiceNewSingleThreadScheduledExecutor;
            scheduledExecutorServiceNewSingleThreadScheduledExecutor.scheduleWithFixedDelay(new a(this, 0), 0L, this.f34901b, TimeUnit.SECONDS);
        }
    }

    public final void s() {
        ScheduledExecutorService scheduledExecutorService = this.f34902c;
        if (scheduledExecutorService != null) {
            scheduledExecutorService.shutdownNow();
            this.f34902c = null;
        }
        WeakReference weakReference = this.f34905f;
        if (weakReference != null) {
            weakReference.clear();
            this.f34905f = null;
        }
    }
}
