pull/589/head
FongMi 1 year ago
parent ecb6630195
commit 559fea9009
  1. 9
      app/build.gradle
  2. 12
      app/src/main/java/com/fongmi/android/tv/player/Players.java
  3. 6
      app/src/main/java/com/fongmi/android/tv/player/exo/ExoUtil.java
  4. 8
      app/src/main/java/com/fongmi/android/tv/player/exo/MediaSourceFactory.java

@ -63,6 +63,12 @@ android {
exclude 'META-INF/beans.xml'
exclude 'META-INF/versions/9/OSGI-INF/MANIFEST.MF'
}
pickFirsts.addAll([
"lib/x86/libc++_shared.so",
"lib/x86_64/libc++_shared.so",
"lib/arm64-v8a/libc++_shared.so",
"lib/armeabi-v7a/libc++_shared.so"
])
}
android.applicationVariants.configureEach { variant ->
@ -109,6 +115,9 @@ dependencies {
implementation 'com.guolindev.permissionx:permissionx:1.8.0'
implementation 'com.hierynomus:smbj:0.14.0'
implementation 'io.antmedia:rtmp-client:3.2.0'
implementation 'io.github.peerless2012:ass:0.2.0'
implementation 'io.github.peerless2012:ass-kt:0.2.0'
implementation('io.github.peerless2012:ass-media:0.2.0') { exclude group: 'androidx.media3' }
implementation 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'org.eclipse.jetty:jetty-client:8.1.21.v20160908'
implementation('org.eclipse.jetty:jetty-server:8.1.21.v20160908') { exclude group: 'org.eclipse.jetty.orbit', module: 'javax.servlet' }

@ -66,6 +66,9 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import io.github.peerless2012.ass.media.AssHandler;
import io.github.peerless2012.ass.media.parser.AssSubtitleParserFactory;
import io.github.peerless2012.ass.media.type.AssRenderType;
import master.flame.danmaku.controller.DrawHandler;
import master.flame.danmaku.danmaku.model.BaseDanmaku;
import master.flame.danmaku.danmaku.model.DanmakuTimer;
@ -131,13 +134,16 @@ public class Players implements Player.Listener, ParseCallback, DrawHandler.Call
}
private void setPlayer(PlayerView view) {
exoPlayer = new ExoPlayer.Builder(App.get()).setLoadControl(ExoUtil.buildLoadControl()).setTrackSelector(ExoUtil.buildTrackSelector()).setRenderersFactory(ExoUtil.buildRenderersFactory(isHard() ? EXTENSION_RENDERER_MODE_ON : EXTENSION_RENDERER_MODE_PREFER)).setMediaSourceFactory(ExoUtil.buildMediaSourceFactory()).build();
AssHandler assHandler = new AssHandler(AssRenderType.OPEN_GL);
AssSubtitleParserFactory subtitleParserFactory = new AssSubtitleParserFactory(assHandler);
exoPlayer = new ExoPlayer.Builder(App.get()).setLoadControl(ExoUtil.buildLoadControl()).setTrackSelector(ExoUtil.buildTrackSelector()).setRenderersFactory(ExoUtil.buildRenderersFactory(isHard() ? EXTENSION_RENDERER_MODE_ON : EXTENSION_RENDERER_MODE_PREFER)).setMediaSourceFactory(ExoUtil.buildMediaSourceFactory(assHandler, subtitleParserFactory)).build();
exoPlayer.setAudioAttributes(AudioAttributes.DEFAULT, true);
exoPlayer.addAnalyticsListener(new EventLogger());
exoPlayer.setHandleAudioBecomingNoisy(true);
view.setRender(Setting.getRender());
exoPlayer.setPlayWhenReady(true);
exoPlayer.addListener(this);
assHandler.init(exoPlayer);
view.setPlayer(exoPlayer);
this.view = view;
}
@ -270,10 +276,6 @@ public class Players implements Player.Listener, ParseCallback, DrawHandler.Call
return decode == HARD;
}
public boolean isSoft() {
return decode == SOFT;
}
public boolean isPortrait() {
return getVideoHeight() > getVideoWidth();
}

@ -36,6 +36,8 @@ import java.util.Locale;
import java.util.Map;
import io.github.anilbeesetti.nextlib.media3ext.ffdecoder.NextRenderersFactory;
import io.github.peerless2012.ass.media.AssHandler;
import io.github.peerless2012.ass.media.parser.AssSubtitleParserFactory;
public class ExoUtil {
@ -57,8 +59,8 @@ public class ExoUtil {
return new NextRenderersFactory(App.get()).setAudioPrefer(Setting.isAudioPrefer()).setEnableDecoderFallback(true).setExtensionRendererMode(renderMode);
}
public static MediaSource.Factory buildMediaSourceFactory() {
return new MediaSourceFactory();
public static MediaSource.Factory buildMediaSourceFactory(AssHandler assHandler, AssSubtitleParserFactory subtitleParserFactory) {
return new MediaSourceFactory(assHandler, subtitleParserFactory);
}
public static CaptionStyleCompat getCaptionStyle() {

@ -27,6 +27,10 @@ import com.github.catvod.net.OkHttp;
import java.util.HashMap;
import java.util.Map;
import io.github.peerless2012.ass.media.AssHandler;
import io.github.peerless2012.ass.media.kt.AssPlayerKt;
import io.github.peerless2012.ass.media.parser.AssSubtitleParserFactory;
public class MediaSourceFactory implements MediaSource.Factory {
private final DefaultMediaSourceFactory defaultMediaSourceFactory;
@ -34,8 +38,8 @@ public class MediaSourceFactory implements MediaSource.Factory {
private DataSource.Factory dataSourceFactory;
private ExtractorsFactory extractorsFactory;
public MediaSourceFactory() {
defaultMediaSourceFactory = new DefaultMediaSourceFactory(getDataSourceFactory(), getExtractorsFactory());
public MediaSourceFactory(AssHandler assHandler, AssSubtitleParserFactory subtitleParserFactory) {
defaultMediaSourceFactory = new DefaultMediaSourceFactory(getDataSourceFactory(), AssPlayerKt.withAssMkvSupport(getExtractorsFactory(), subtitleParserFactory, assHandler));
}
@NonNull

Loading…
Cancel
Save