正在查看: Barstool v5.21.2 应用的 BarstoolVideoService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Barstool v5.21.2 应用的 BarstoolVideoService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.barstoolsports.videoservice;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import android.view.ViewGroup;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.media3.common.AdViewProvider;
import androidx.media3.common.MediaItem;
import androidx.media3.common.Player;
import androidx.media3.common.util.Util;
import androidx.media3.datasource.DataSource;
import androidx.media3.datasource.DefaultDataSourceFactory;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.ima.ImaAdsLoader;
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory;
import androidx.media3.exoplayer.source.MediaSource;
import androidx.media3.exoplayer.source.ads.AdsLoader;
import androidx.media3.session.MediaSession;
import androidx.media3.ui.PlayerView;
import com.barstoolsports.components.MediaPauseReceiver;
import com.barstoolsports.components.MediaPauseReceiverKt;
import com.barstoolsports.videoservice.BarstoolVideoService;
import com.google.ads.interactivemedia.v3.api.AdErrorEvent;
import com.google.ads.interactivemedia.v3.api.AdEvent;
import com.google.ads.mediation.facebook.FacebookMediationAdapter;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
@Metadata(d1 = {"\u0000v\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0006\n\u0002\u0010\t\n\u0002\b\u0004\b\u0007\u0018\u0000 >2\u00020\u0001:\u0002=>B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\b\u0010-\u001a\u00020.H\u0016J\u0012\u0010/\u001a\u0002002\b\u00101\u001a\u0004\u0018\u000102H\u0016J\u0012\u00103\u001a\u0002042\b\u00101\u001a\u0004\u0018\u000102H\u0016J\b\u00105\u001a\u00020.H\u0016J6\u00106\u001a\u00020.2\u0006\u00107\u001a\u00020\u00052\u0006\u00108\u001a\u00020\u00052\n\b\u0002\u00109\u001a\u0004\u0018\u00010\u00052\b\b\u0002\u0010:\u001a\u00020;2\b\u0010<\u001a\u0004\u0018\u00010\u0013R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\u0006\u001a\u00020\u0007X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\b\u0010\t\"\u0004\b\n\u0010\u000bR\u001c\u0010\f\u001a\u0004\u0018\u00010\rX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000e\u0010\u000f\"\u0004\b\u0010\u0010\u0011R\u0010\u0010\u0012\u001a\u0004\u0018\u00010\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u0014\u001a\u00060\u0015R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R\u001c\u0010\u0016\u001a\u0004\u0018\u00010\u0017X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0018\u0010\u0019\"\u0004\b\u001a\u0010\u001bR\u0010\u0010\u001c\u001a\u0004\u0018\u00010\u001dX\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\u001e\u001a\u00020\u001f8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\"\u0010#\u001a\u0004\b \u0010!R\u001b\u0010$\u001a\u00020%8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b(\u0010#\u001a\u0004\b&\u0010'R\u0011\u0010)\u001a\u00020*¢\u0006\b\n\u0000\u001a\u0004\b+\u0010,¨\u0006?"}, d2 = {"Lcom/barstoolsports/videoservice/BarstoolVideoService;", "Landroid/app/Service;", "<init>", "()V", "latestUri", "", "exoPlayer", "Landroidx/media3/exoplayer/ExoPlayer;", "getExoPlayer", "()Landroidx/media3/exoplayer/ExoPlayer;", "setExoPlayer", "(Landroidx/media3/exoplayer/ExoPlayer;)V", "adsLoader", "Landroidx/media3/exoplayer/ima/ImaAdsLoader;", "getAdsLoader", "()Landroidx/media3/exoplayer/ima/ImaAdsLoader;", "setAdsLoader", "(Landroidx/media3/exoplayer/ima/ImaAdsLoader;)V", "player", "Landroidx/media3/ui/PlayerView;", "binder", "Lcom/barstoolsports/videoservice/BarstoolVideoService$VideoServiceBinder;", "adEventSink", "Lcom/barstoolsports/videoservice/AdEventSink;", "getAdEventSink", "()Lcom/barstoolsports/videoservice/AdEventSink;", "setAdEventSink", "(Lcom/barstoolsports/videoservice/AdEventSink;)V", "mediaSession", "Landroidx/media3/session/MediaSession;", "dataSourceFactory", "Landroidx/media3/datasource/DataSource$Factory;", "getDataSourceFactory", "()Landroidx/media3/datasource/DataSource$Factory;", "dataSourceFactory$delegate", "Lkotlin/Lazy;", "mediaSourceFactory", "Landroidx/media3/exoplayer/source/MediaSource$Factory;", "getMediaSourceFactory", "()Landroidx/media3/exoplayer/source/MediaSource$Factory;", "mediaSourceFactory$delegate", "pauseReceiver", "Lcom/barstoolsports/components/MediaPauseReceiver;", "getPauseReceiver", "()Lcom/barstoolsports/components/MediaPauseReceiver;", "onCreate", "", "onBind", "Landroid/os/IBinder;", "intent", "Landroid/content/Intent;", "onUnbind", "", "onDestroy", "prepare", FacebookMediationAdapter.KEY_ID, "uri", "adTag", "startPos", "", "playerView", "VideoServiceBinder", "Companion", "videoservice_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public final class BarstoolVideoService extends Service {
public static final Companion INSTANCE = new Companion(null);
private AdEventSink adEventSink;
private ImaAdsLoader adsLoader;
public ExoPlayer exoPlayer;
private String latestUri;
private MediaSession mediaSession;
private PlayerView player;
private final VideoServiceBinder binder = new VideoServiceBinder();
private final Lazy dataSourceFactory = LazyKt.lazy(new Function0() {
public final Object invoke() {
DefaultDataSourceFactory dataSourceFactory_delegate$lambda$0;
dataSourceFactory_delegate$lambda$0 = BarstoolVideoService.dataSourceFactory_delegate$lambda$0(BarstoolVideoService.this);
return dataSourceFactory_delegate$lambda$0;
}
});
private final Lazy mediaSourceFactory = LazyKt.lazy(new Function0() {
public final Object invoke() {
DefaultMediaSourceFactory mediaSourceFactory_delegate$lambda$3;
mediaSourceFactory_delegate$lambda$3 = BarstoolVideoService.mediaSourceFactory_delegate$lambda$3(BarstoolVideoService.this);
return mediaSourceFactory_delegate$lambda$3;
}
});
private final MediaPauseReceiver pauseReceiver = new MediaPauseReceiver(1, new Function0() {
public final Object invoke() {
Unit pauseReceiver$lambda$4;
pauseReceiver$lambda$4 = BarstoolVideoService.pauseReceiver$lambda$4(BarstoolVideoService.this);
return pauseReceiver$lambda$4;
}
});
public final ExoPlayer getExoPlayer() {
ExoPlayer exoPlayer = this.exoPlayer;
if (exoPlayer != null) {
return exoPlayer;
}
Intrinsics.throwUninitializedPropertyAccessException("exoPlayer");
return null;
}
public final void setExoPlayer(ExoPlayer exoPlayer) {
Intrinsics.checkNotNullParameter(exoPlayer, "<set-?>");
this.exoPlayer = exoPlayer;
}
public final ImaAdsLoader getAdsLoader() {
return this.adsLoader;
}
public final void setAdsLoader(ImaAdsLoader imaAdsLoader) {
this.adsLoader = imaAdsLoader;
}
public final AdEventSink getAdEventSink() {
return this.adEventSink;
}
public final void setAdEventSink(AdEventSink adEventSink) {
this.adEventSink = adEventSink;
}
private final DataSource.Factory getDataSourceFactory() {
return (DataSource.Factory) this.dataSourceFactory.getValue();
}
public static final DefaultDataSourceFactory dataSourceFactory_delegate$lambda$0(BarstoolVideoService barstoolVideoService) {
BarstoolVideoService barstoolVideoService2 = barstoolVideoService;
return new DefaultDataSourceFactory(barstoolVideoService2, Util.getUserAgent(barstoolVideoService2, barstoolVideoService.getString(R.string.app_name)));
}
private final MediaSource.Factory getMediaSourceFactory() {
Object value = this.mediaSourceFactory.getValue();
Intrinsics.checkNotNullExpressionValue(value, "getValue(...)");
return (MediaSource.Factory) value;
}
public static final DefaultMediaSourceFactory mediaSourceFactory_delegate$lambda$3(final BarstoolVideoService barstoolVideoService) {
return new DefaultMediaSourceFactory(barstoolVideoService.getDataSourceFactory()).setLocalAdInsertionComponents(new AdsLoader.Provider() {
public final AdsLoader getAdsLoader(MediaItem.AdsConfiguration adsConfiguration) {
AdsLoader mediaSourceFactory_delegate$lambda$3$lambda$1;
mediaSourceFactory_delegate$lambda$3$lambda$1 = BarstoolVideoService.mediaSourceFactory_delegate$lambda$3$lambda$1(BarstoolVideoService.this, adsConfiguration);
return mediaSourceFactory_delegate$lambda$3$lambda$1;
}
}, new AdViewProvider() {
public final ViewGroup getAdViewGroup() {
ViewGroup mediaSourceFactory_delegate$lambda$3$lambda$2;
mediaSourceFactory_delegate$lambda$3$lambda$2 = BarstoolVideoService.mediaSourceFactory_delegate$lambda$3$lambda$2(BarstoolVideoService.this);
return mediaSourceFactory_delegate$lambda$3$lambda$2;
}
});
}
public static final AdsLoader mediaSourceFactory_delegate$lambda$3$lambda$1(BarstoolVideoService barstoolVideoService, MediaItem.AdsConfiguration adsConfiguration) {
Intrinsics.checkNotNullParameter(adsConfiguration, "it");
return barstoolVideoService.adsLoader;
}
public static final ViewGroup mediaSourceFactory_delegate$lambda$3$lambda$2(BarstoolVideoService barstoolVideoService) {
return barstoolVideoService.player;
}
public final MediaPauseReceiver getPauseReceiver() {
return this.pauseReceiver;
}
public static final Unit pauseReceiver$lambda$4(BarstoolVideoService barstoolVideoService) {
barstoolVideoService.getExoPlayer().setPlayWhenReady(false);
return Unit.INSTANCE;
}
@Override
public void onCreate() {
super.onCreate();
BarstoolVideoService barstoolVideoService = this;
setExoPlayer(new ExoPlayer.Builder(barstoolVideoService).setMediaSourceFactory(getMediaSourceFactory()).build());
getExoPlayer().addListener(new Player.Listener() {
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
if (playWhenReady) {
BarstoolVideoService barstoolVideoService2 = BarstoolVideoService.this;
Intent intent = new Intent(MediaPauseReceiverKt.ACTION_REQUEST_MEDIA_PRIORITY);
intent.setPackage(BarstoolVideoService.this.getPackageName());
intent.putExtra(MediaPauseReceiverKt.EXTRA_REQUESTER_ORDINAL, 1);
Log.d("BarstoolMedia", "Sending intent to pause podcast");
barstoolVideoService2.sendBroadcast(intent);
}
}
});
ContextCompat.registerReceiver(barstoolVideoService, this.pauseReceiver, new IntentFilter(MediaPauseReceiverKt.ACTION_REQUEST_MEDIA_PRIORITY), 4);
this.mediaSession = new MediaSession.Builder(barstoolVideoService, getExoPlayer()).build();
}
@Override
public IBinder onBind(Intent intent) {
return this.binder;
}
@Override
public boolean onUnbind(Intent intent) {
getExoPlayer().setPlayWhenReady(false);
unregisterReceiver(this.pauseReceiver);
return super.onUnbind(intent);
}
@Override
public void onDestroy() {
super.onDestroy();
MediaSession mediaSession = this.mediaSession;
if (mediaSession != null) {
mediaSession.release();
}
this.mediaSession = null;
}
public static void prepare$default(BarstoolVideoService barstoolVideoService, String str, String str2, String str3, long j, PlayerView playerView, int i, Object obj) {
if ((i & 4) != 0) {
str3 = null;
}
String str4 = str3;
if ((i & 8) != 0) {
j = -1;
}
barstoolVideoService.prepare(str, str2, str4, j, playerView);
}
public final void prepare(final String id, String uri, String adTag, long startPos, PlayerView playerView) {
MediaItem fromUri;
Intrinsics.checkNotNullParameter(id, FacebookMediationAdapter.KEY_ID);
Intrinsics.checkNotNullParameter(uri, "uri");
this.player = playerView;
if (Intrinsics.areEqual(this.latestUri, uri)) {
return;
}
this.latestUri = uri;
if (adTag != null && !AdWatchedCache.INSTANCE.get(id)) {
ImaAdsLoader imaAdsLoader = this.adsLoader;
if (imaAdsLoader != null) {
imaAdsLoader.release();
}
ImaAdsLoader imaAdsLoader2 = this.adsLoader;
if (imaAdsLoader2 != null) {
imaAdsLoader2.setPlayer((Player) null);
}
this.adsLoader = null;
this.adsLoader = new ImaAdsLoader.Builder(this).setAdEventListener(new AdEvent.AdEventListener() {
@Override
public final void onAdEvent(AdEvent adEvent) {
BarstoolVideoService.prepare$lambda$6(BarstoolVideoService.this, id, adEvent);
}
}).setAdErrorListener(new AdErrorEvent.AdErrorListener() {
@Override
public final void onAdError(AdErrorEvent adErrorEvent) {
BarstoolVideoService.prepare$lambda$7(BarstoolVideoService.this, adErrorEvent);
}
}).build();
fromUri = new MediaItem.Builder().setUri(uri).setAdTagUri(Uri.parse(adTag), adTag).build();
} else {
fromUri = MediaItem.fromUri(Uri.parse(uri));
}
ImaAdsLoader imaAdsLoader3 = this.adsLoader;
if (imaAdsLoader3 != null) {
imaAdsLoader3.setPlayer(getExoPlayer());
}
getExoPlayer().addMediaItem(fromUri);
getExoPlayer().prepare();
getExoPlayer().seekTo(startPos);
}
public static final void prepare$lambda$6(BarstoolVideoService barstoolVideoService, String str, AdEvent adEvent) {
Intrinsics.checkNotNullParameter(adEvent, "it");
AdEventSink adEventSink = barstoolVideoService.adEventSink;
if (adEventSink != null) {
adEventSink.onAdEvent(adEvent);
}
AdWatchedCache.INSTANCE.set(str, AdWatchedCache.INSTANCE.get(str) || !barstoolVideoService.getExoPlayer().isPlayingAd() || adEvent.getType() == AdEvent.AdEventType.CONTENT_RESUME_REQUESTED);
}
public static final void prepare$lambda$7(BarstoolVideoService barstoolVideoService, AdErrorEvent adErrorEvent) {
Intrinsics.checkNotNullParameter(adErrorEvent, "it");
AdEventSink adEventSink = barstoolVideoService.adEventSink;
if (adEventSink != null) {
adEventSink.onAdErrorEvent(adErrorEvent);
}
}
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\b\u0086\u0004\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u0006\u0010\u0004\u001a\u00020\u0005¨\u0006\u0006"}, d2 = {"Lcom/barstoolsports/videoservice/BarstoolVideoService$VideoServiceBinder;", "Landroid/os/Binder;", "<init>", "(Lcom/barstoolsports/videoservice/BarstoolVideoService;)V", "getService", "Lcom/barstoolsports/videoservice/BarstoolVideoService;", "videoservice_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public final class VideoServiceBinder extends Binder {
public VideoServiceBinder() {
}
public final BarstoolVideoService getThis$0() {
return BarstoolVideoService.this;
}
}
@Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u0012\u0010\u0004\u001a\u00020\u0005*\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bJ(\u0010\t\u001a\u00020\b2\u0012\u0010\n\u001a\u000e\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\u00050\u000b2\f\u0010\r\u001a\b\u0012\u0004\u0012\u00020\u00050\u000e¨\u0006\u000f"}, d2 = {"Lcom/barstoolsports/videoservice/BarstoolVideoService$Companion;", "", "<init>", "()V", "bindVideoService", "", "Landroidx/fragment/app/Fragment;", "connection", "Landroid/content/ServiceConnection;", "createServiceConnection", "onConnected", "Lkotlin/Function1;", "Lcom/barstoolsports/videoservice/BarstoolVideoService;", "onDisconnect", "Lkotlin/Function0;", "videoservice_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final void bindVideoService(Fragment fragment, ServiceConnection serviceConnection) {
Intrinsics.checkNotNullParameter(fragment, "<this>");
Intrinsics.checkNotNullParameter(serviceConnection, "connection");
Intent intent = new Intent(fragment.requireContext(), (Class<?>) BarstoolVideoService.class);
FragmentActivity activity = fragment.getActivity();
if (activity != null) {
activity.bindService(intent, serviceConnection, 1);
}
}
public final ServiceConnection createServiceConnection(final Function1<? super BarstoolVideoService, Unit> onConnected, final Function0<Unit> onDisconnect) {
Intrinsics.checkNotNullParameter(onConnected, "onConnected");
Intrinsics.checkNotNullParameter(onDisconnect, "onDisconnect");
return new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Function1<BarstoolVideoService, Unit> function1 = onConnected;
Intrinsics.checkNotNull(service, "null cannot be cast to non-null type com.barstoolsports.videoservice.BarstoolVideoService.VideoServiceBinder");
function1.invoke(((BarstoolVideoService.VideoServiceBinder) service).getThis$0());
}
@Override
public void onServiceDisconnected(ComponentName name) {
onDisconnect.invoke();
}
};
}
}
}