Support next render

pull/485/head
okjack 2 years ago
parent 1991531b20
commit f078f722ed
  1. 1
      app/build.gradle
  2. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/CastActivity.java
  3. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  4. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  5. 13
      app/src/leanback/res/layout/activity_cast.xml
  6. 13
      app/src/leanback/res/layout/activity_live.xml
  7. 13
      app/src/leanback/res/layout/activity_video.xml
  8. 3
      app/src/main/java/com/fongmi/android/tv/player/ExoUtil.java
  9. 1
      app/src/main/java/com/fongmi/android/tv/player/Players.java
  10. 56
      app/src/main/java/com/fongmi/android/tv/player/custom/NextRenderersFactory.java
  11. 2
      app/src/main/java/com/fongmi/android/tv/player/custom/TrackNameProvider.java
  12. 2
      app/src/main/java/com/fongmi/android/tv/ui/dialog/TrackDialog.java
  13. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  14. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  15. 13
      app/src/mobile/res/layout-sw600dp/activity_video.xml
  16. 13
      app/src/mobile/res/layout/activity_live.xml
  17. 13
      app/src/mobile/res/layout/activity_video.xml

@ -121,6 +121,7 @@ dependencies {
implementation 'androidx.biometric:biometric:1.1.0'
implementation 'androidx.room:room-runtime:2.6.1'
implementation 'androidx.media:media:1.7.0'
implementation ('com.github.anilbeesetti.nextlib:nextlib-media3ext:0.7.1') { exclude group: 'androidx.media3', module: 'media3-exoplayer' }
implementation 'cat.ereza:customactivityoncrash:2.4.0'
implementation 'com.github.bassaer:materialdesigncolors:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.16.0'

@ -69,7 +69,7 @@ public class CastActivity extends BaseActivity implements CustomKeyDownCast.List
private int scale;
private PlayerView getExo() {
return Setting.getRender() == 0 ? mBinding.surface : mBinding.texture;
return mBinding.exo;
}
private IjkVideoView getIjk() {

@ -105,7 +105,7 @@ public class LiveActivity extends BaseActivity implements Clock.Callback, GroupP
}
private PlayerView getExo() {
return Setting.getRender() == 0 ? mBinding.surface : mBinding.texture;
return mBinding.exo;
}
private IjkVideoView getIjk() {

@ -280,7 +280,7 @@ public class VideoActivity extends BaseActivity implements CustomKeyDownVod.List
}
private PlayerView getExo() {
return Setting.getRender() == 0 ? mBinding.surface : mBinding.texture;
return mBinding.exo;
}
private IjkVideoView getIjk() {

@ -8,20 +8,11 @@
android:keepScreenOn="true">
<androidx.media3.ui.PlayerView
android:id="@+id/surface"
android:id="@+id/exo"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="surface_view" />
<androidx.media3.ui.PlayerView
android:id="@+id/texture"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="texture_view" />
app:surface_type="none" />
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"

@ -15,20 +15,11 @@
android:focusable="true">
<androidx.media3.ui.PlayerView
android:id="@+id/surface"
android:id="@+id/exo"
style="@style/Player.Live"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="surface_view" />
<androidx.media3.ui.PlayerView
android:id="@+id/texture"
style="@style/Player.Live"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="texture_view" />
app:surface_type="none" />
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"

@ -24,20 +24,11 @@
android:nextFocusDown="@id/flag">
<androidx.media3.ui.PlayerView
android:id="@+id/surface"
android:id="@+id/exo"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="surface_view" />
<androidx.media3.ui.PlayerView
android:id="@+id/texture"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="texture_view" />
app:surface_type="none" />
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"

@ -44,6 +44,7 @@ import com.fongmi.android.tv.bean.Channel;
import com.fongmi.android.tv.bean.Drm;
import com.fongmi.android.tv.bean.Result;
import com.fongmi.android.tv.bean.Sub;
import com.fongmi.android.tv.player.custom.NextRenderersFactory;
import com.fongmi.android.tv.utils.UrlUtil;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Path;
@ -77,7 +78,7 @@ public class ExoUtil {
}
public static RenderersFactory buildRenderersFactory() {
return new DefaultRenderersFactory(App.get()).setEnableDecoderFallback(true).setExtensionRendererMode(Players.isSoft(Players.EXO) ? DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER : DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
return new NextRenderersFactory(App.get()).setEnableDecoderFallback(true).setExtensionRendererMode(Players.isSoft(Players.EXO) ? DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER : DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
}
public static CaptionStyleCompat getCaptionStyle() {

@ -136,6 +136,7 @@ public class Players implements Player.Listener, IMediaPlayer.Listener, Analytic
exoPlayer.setAudioAttributes(AudioAttributes.DEFAULT, true);
exoPlayer.addAnalyticsListener(new EventLogger());
exoPlayer.setHandleAudioBecomingNoisy(true);
view.setRender(Setting.getRender());
exoPlayer.addAnalyticsListener(this);
exoPlayer.setPlayWhenReady(true);
exoPlayer.addListener(this);

@ -0,0 +1,56 @@
package com.fongmi.android.tv.player.custom;
import android.content.Context;
import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.media3.common.util.Log;
import androidx.media3.exoplayer.DefaultRenderersFactory;
import androidx.media3.exoplayer.Renderer;
import androidx.media3.exoplayer.audio.AudioRendererEventListener;
import androidx.media3.exoplayer.audio.AudioSink;
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector;
import androidx.media3.exoplayer.video.VideoRendererEventListener;
import java.util.ArrayList;
import io.github.anilbeesetti.nextlib.media3ext.ffdecoder.FfmpegAudioRenderer;
import io.github.anilbeesetti.nextlib.media3ext.ffdecoder.FfmpegVideoRenderer;
public class NextRenderersFactory extends DefaultRenderersFactory {
private static final String TAG = NextRenderersFactory.class.getSimpleName();
public NextRenderersFactory(@NonNull Context context) {
super(context);
}
@Override
protected void buildAudioRenderers(@NonNull Context context, int extensionRendererMode, @NonNull MediaCodecSelector mediaCodecSelector, boolean enableDecoderFallback, @NonNull AudioSink audioSink, @NonNull Handler eventHandler, @NonNull AudioRendererEventListener eventListener, @NonNull ArrayList<Renderer> out) {
super.buildAudioRenderers(context, extensionRendererMode, mediaCodecSelector, enableDecoderFallback, audioSink, eventHandler, eventListener, out);
int extensionRendererIndex = out.size();
if (extensionRendererMode == EXTENSION_RENDERER_MODE_PREFER) {
extensionRendererIndex--;
}
try {
Renderer renderer = new FfmpegAudioRenderer(eventHandler, eventListener, audioSink);
out.add(extensionRendererIndex++, renderer);
Log.i(TAG, "Loaded FfmpegAudioRenderer.");
} catch (Exception e) {
throw new RuntimeException("Error instantiating Ffmpeg extension", e);
}
}
@Override
protected void buildVideoRenderers(@NonNull Context context, int extensionRendererMode, @NonNull MediaCodecSelector mediaCodecSelector, boolean enableDecoderFallback, @NonNull Handler eventHandler, @NonNull VideoRendererEventListener eventListener, long allowedVideoJoiningTimeMs, @NonNull ArrayList<Renderer> out) {
super.buildVideoRenderers(context, extensionRendererMode, mediaCodecSelector, enableDecoderFallback, eventHandler, eventListener, allowedVideoJoiningTimeMs, out);
int extensionRendererIndex = out.size();
try {
Renderer renderer = new FfmpegVideoRenderer(allowedVideoJoiningTimeMs, eventHandler, eventListener, MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY);
out.add(extensionRendererIndex++, renderer);
Log.i(TAG, "Loaded FfmpegVideoRenderer.");
} catch (Exception e) {
throw new RuntimeException("Error instantiating Ffmpeg extension", e);
}
}
}

@ -1,4 +1,4 @@
package com.fongmi.android.tv.player;
package com.fongmi.android.tv.player.custom;
import android.content.res.Resources;
import android.text.TextUtils;

@ -20,7 +20,7 @@ import com.fongmi.android.tv.bean.Sub;
import com.fongmi.android.tv.bean.Track;
import com.fongmi.android.tv.databinding.DialogTrackBinding;
import com.fongmi.android.tv.player.Players;
import com.fongmi.android.tv.player.TrackNameProvider;
import com.fongmi.android.tv.player.custom.TrackNameProvider;
import com.fongmi.android.tv.ui.adapter.TrackAdapter;
import com.fongmi.android.tv.ui.custom.SpaceItemDecoration;
import com.fongmi.android.tv.utils.FileChooser;

@ -117,7 +117,7 @@ public class LiveActivity extends BaseActivity implements Clock.Callback, Custom
}
private PlayerView getExo() {
return Setting.getRender() == 0 ? mBinding.surface : mBinding.texture;
return mBinding.exo;
}
private IjkVideoView getIjk() {

@ -249,7 +249,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
}
private PlayerView getExo() {
return Setting.getRender() == 0 ? mBinding.surface : mBinding.texture;
return mBinding.exo;
}
private IjkVideoView getIjk() {

@ -22,20 +22,11 @@
android:focusable="true">
<androidx.media3.ui.PlayerView
android:id="@+id/surface"
android:id="@+id/exo"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="surface_view" />
<androidx.media3.ui.PlayerView
android:id="@+id/texture"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="texture_view" />
app:surface_type="none" />
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"

@ -15,20 +15,11 @@
android:focusable="true">
<androidx.media3.ui.PlayerView
android:id="@+id/surface"
android:id="@+id/exo"
style="@style/Player.Live"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="surface_view" />
<androidx.media3.ui.PlayerView
android:id="@+id/texture"
style="@style/Player.Live"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="texture_view" />
app:surface_type="none" />
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"

@ -15,20 +15,11 @@
android:focusable="true">
<androidx.media3.ui.PlayerView
android:id="@+id/surface"
android:id="@+id/exo"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="surface_view" />
<androidx.media3.ui.PlayerView
android:id="@+id/texture"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:surface_type="texture_view" />
app:surface_type="none" />
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"

Loading…
Cancel
Save