package defpackage;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import androidx.media3.container.NalUnitUtil;
import com.strmr.ps.data.repository.PreferencesRepository;
import com.strmr.ps.ui.trailer.TrailerWebViewActivity;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\bÆ\u0002\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Ler9;", "", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public final class er9 {
    public static void a(Context context, String str, PreferencesRepository.TrailerPlayer trailerPlayer, String str2, String str3) {
        cr4.g(str, "videoKey");
        cr4.g(trailerPlayer, "player");
        if (trailerPlayer == PreferencesRepository.TrailerPlayer.WEBVIEW) {
            Intent intent = new Intent(context, (Class<?>) TrailerWebViewActivity.class);
            intent.putExtra("video_key", str);
            intent.putExtra("logo_url", str2);
            intent.putExtra("backdrop_url", str3);
            context.startActivity(intent);
            return;
        }
        try {
            context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("vnd.youtube://www.youtube.com/watch?v=".concat(str))));
        } catch (ActivityNotFoundException e) {
            Log.w("TrailerLauncher", "No app handles vnd.youtube scheme", e);
            try {
                context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://www.youtube.com/watch?v=".concat(str))));
            } catch (ActivityNotFoundException e2) {
                Log.w("TrailerLauncher", "No app handles YouTube HTTPS URL", e2);
                Log.w("TrailerLauncher", "No external app available, using in-app WebView for: ".concat(str));
                Intent intent2 = new Intent(context, (Class<?>) TrailerWebViewActivity.class);
                intent2.putExtra("video_key", str);
                intent2.putExtra("logo_url", str2);
                intent2.putExtra("backdrop_url", str3);
                context.startActivity(intent2);
            }
        }
    }
}
