Merge pull request #485 from okcaptain/dev

Dev
pull/486/head^2
okcaptain 2 years ago committed by GitHub
commit 3eb16bdd70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      app/build.gradle
  2. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/CastActivity.java
  3. 8
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  4. 9
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/SettingPlayerActivity.java
  5. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  6. 13
      app/src/leanback/res/layout/activity_cast.xml
  7. 13
      app/src/leanback/res/layout/activity_live.xml
  8. 29
      app/src/leanback/res/layout/activity_setting_player.xml
  9. 13
      app/src/leanback/res/layout/activity_video.xml
  10. 8
      app/src/main/java/com/fongmi/android/tv/Setting.java
  11. 4
      app/src/main/java/com/fongmi/android/tv/player/ExoUtil.java
  12. 11
      app/src/main/java/com/fongmi/android/tv/player/Players.java
  13. 56
      app/src/main/java/com/fongmi/android/tv/player/custom/NextRenderersFactory.java
  14. 2
      app/src/main/java/com/fongmi/android/tv/player/custom/TrackNameProvider.java
  15. 2
      app/src/main/java/com/fongmi/android/tv/ui/dialog/TrackDialog.java
  16. 8
      app/src/main/res/values-zh-rCN/strings.xml
  17. 8
      app/src/main/res/values-zh-rTW/strings.xml
  18. 8
      app/src/main/res/values/strings.xml
  19. 10
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  20. 4
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  21. 9
      app/src/mobile/java/com/fongmi/android/tv/ui/fragment/SettingPlayerFragment.java
  22. 17
      app/src/mobile/java/com/fongmi/android/tv/utils/PiP.java
  23. 13
      app/src/mobile/res/layout-sw600dp/activity_video.xml
  24. 13
      app/src/mobile/res/layout/activity_live.xml
  25. 13
      app/src/mobile/res/layout/activity_video.xml
  26. 27
      app/src/mobile/res/layout/fragment_setting_player.xml

@ -14,7 +14,7 @@ android {
//noinspection ExpiredTargetSdkVersion
targetSdk 28
versionCode 237
versionName "0604"
versionName "0607"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
@ -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() {
@ -756,7 +756,6 @@ public class LiveActivity extends BaseActivity implements Clock.Callback, GroupP
setMetadata();
hideProgress();
mPlayers.reset();
setSpeedVisible();
setTrackVisible(true);
mBinding.widget.size.setText(mPlayers.getSizeText());
break;
@ -766,12 +765,9 @@ public class LiveActivity extends BaseActivity implements Clock.Callback, GroupP
}
}
private void setSpeedVisible() {
mBinding.control.speed.setVisibility(mPlayers.isVod() ? View.VISIBLE : View.GONE);
}
private void setTrackVisible(boolean visible) {
mBinding.control.text.setVisibility(visible && mPlayers.haveTrack(C.TRACK_TYPE_TEXT) ? View.VISIBLE : View.GONE);
mBinding.control.speed.setVisibility(visible && mPlayers.isVod() ? View.VISIBLE : View.GONE);
mBinding.control.audio.setVisibility(visible && mPlayers.haveTrack(C.TRACK_TYPE_AUDIO) ? View.VISIBLE : View.GONE);
mBinding.control.video.setVisibility(visible && mPlayers.haveTrack(C.TRACK_TYPE_VIDEO) ? View.VISIBLE : View.GONE);
}

@ -31,6 +31,7 @@ public class SettingPlayerActivity extends BaseActivity implements UaCallback, B
private String[] scale;
private String[] http;
private String[] flag;
private String[] rtsp;
public static void start(Activity activity) {
activity.startActivity(new Intent(activity, SettingPlayerActivity.class));
@ -53,6 +54,7 @@ public class SettingPlayerActivity extends BaseActivity implements UaCallback, B
mBinding.tunnelText.setText(getSwitch(Setting.isTunnel()));
mBinding.bufferText.setText(String.valueOf(Setting.getBuffer()));
mBinding.subtitleText.setText(String.valueOf(Setting.getSubtitle()));
mBinding.rtspText.setText((rtsp = ResUtil.getStringArray(R.array.select_rtsp))[Setting.getRtsp()]);
mBinding.flagText.setText((flag = ResUtil.getStringArray(R.array.select_flag))[Setting.getFlag()]);
mBinding.httpText.setText((http = ResUtil.getStringArray(R.array.select_exo_http))[Setting.getHttp()]);
mBinding.scaleText.setText((scale = ResUtil.getStringArray(R.array.select_scale))[Setting.getScale()]);
@ -65,6 +67,7 @@ public class SettingPlayerActivity extends BaseActivity implements UaCallback, B
@Override
protected void initEvent() {
mBinding.ua.setOnClickListener(this::onUa);
mBinding.rtsp.setOnClickListener(this::setRtsp);
mBinding.http.setOnClickListener(this::setHttp);
mBinding.flag.setOnClickListener(this::setFlag);
mBinding.scale.setOnClickListener(this::setScale);
@ -95,6 +98,12 @@ public class SettingPlayerActivity extends BaseActivity implements UaCallback, B
Setting.putUa(ua);
}
private void setRtsp(View view) {
int index = Setting.getRtsp();
Setting.putRtsp(index = index == rtsp.length - 1 ? 0 : ++index);
mBinding.rtspText.setText(rtsp[index]);
}
private void setHttp(View view) {
int index = Setting.getHttp();
Setting.putHttp(index = index == http.length - 1 ? 0 : ++index);

@ -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"

@ -311,6 +311,35 @@
</LinearLayout>
<LinearLayout
android:id="@+id/rtsp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/selector_item"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/player_rtsp"
android:textColor="@color/white"
android:textSize="18sp" />
<TextView
android:id="@+id/rtspText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/white"
android:textSize="18sp"
tools:text="UDP" />
</LinearLayout>
<LinearLayout
android:id="@+id/ua"
android:layout_width="match_parent"

@ -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"

@ -194,6 +194,14 @@ public class Setting {
Prefers.put("background", background);
}
public static int getRtsp() {
return Prefers.getInt("rtsp");
}
public static void putRtsp(int rtsp) {
Prefers.put("rtsp", rtsp);
}
public static int getSiteMode() {
return Prefers.getInt("site_mode", 1);
}

@ -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() {
@ -159,6 +160,7 @@ public class ExoUtil {
if (drm != null) builder.setDrmConfiguration(drm.get());
builder.setAllowChunklessPreparation(Players.isHard(Players.EXO));
if (mimeType != null) builder.setMimeType(mimeType);
builder.setForceUseRtpTcp(Setting.getRtsp() == 1);
return builder.build();
}

@ -15,6 +15,7 @@ import androidx.annotation.NonNull;
import androidx.media3.common.AudioAttributes;
import androidx.media3.common.PlaybackException;
import androidx.media3.common.Player;
import androidx.media3.common.VideoSize;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.analytics.AnalyticsListener;
import androidx.media3.exoplayer.util.EventLogger;
@ -135,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);
@ -166,6 +168,11 @@ public class Players implements Player.Listener, IMediaPlayer.Listener, Analytic
return ijkPlayer;
}
public VideoSize getVideoSize() {
if (isExo()) return exo().getVideoSize();
return new VideoSize(ijk().getVideoWidth(), ijk().getVideoHeight());
}
public Map<String, String> getHeaders() {
return headers == null ? new HashMap<>() : checkUa(headers);
}
@ -280,6 +287,10 @@ public class Players implements Player.Listener, IMediaPlayer.Listener, Analytic
return TextUtils.isEmpty(getUrl());
}
public boolean isLive() {
return getDuration() < 5 * 60 * 1000;
}
public boolean isVod() {
return getDuration() > 5 * 60 * 1000;
}

@ -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;

@ -1,7 +1,7 @@
<resources xmlns:xliff="http://schemas.android.com/apk/res-auto">
<!-- App -->
<string name="app_name">影视</string>
<string name="app_name">OK影视</string>
<string name="app_exit">再按一次返回键退出</string>
<!-- Vod -->
@ -122,6 +122,7 @@
<string name="player_exo_tunnel">隧道模式</string>
<string name="player_exo_http">连线方式</string>
<string name="player_exo_buffer">缓冲时间</string>
<string name="player_rtsp">RTSP 通道</string>
<string name="player_ua">User-Agent</string>
<!-- Search -->
@ -309,4 +310,9 @@
<item>选择字幕</item>
</string-array>
<string-array name="select_rtsp">
<item>UDP</item>
<item>TCP</item>
</string-array>
</resources>

@ -1,7 +1,7 @@
<resources xmlns:xliff="http://schemas.android.com/apk/res-auto">
<!-- App -->
<string name="app_name">影視</string>
<string name="app_name">OK影視</string>
<string name="app_exit">再按一次返回鍵退出</string>
<!-- Vod -->
@ -122,6 +122,7 @@
<string name="player_exo_tunnel">隧道模式</string>
<string name="player_exo_http">連線方式</string>
<string name="player_exo_buffer">緩衝時間</string>
<string name="player_rtsp">RTSP 通道</string>
<string name="player_ua">User-Agent</string>
<!-- Search -->
@ -310,4 +311,9 @@
<item>選擇字幕</item>
</string-array>
<string-array name="select_rtsp">
<item>UDP</item>
<item>TCP</item>
</string-array>
</resources>

@ -1,7 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:xliff="http://schemas.android.com/apk/res-auto" tools:ignore="MissingTranslation">
<!-- App -->
<string name="app_name">TV</string>
<string name="app_name">OKTV</string>
<string name="app_exit">Press back again to exit</string>
<!-- Vod -->
@ -122,6 +122,7 @@
<string name="player_exo_tunnel">Tunnel mode</string>
<string name="player_exo_http">HTTP method</string>
<string name="player_exo_buffer">Buffer time</string>
<string name="player_rtsp">RTSP channel</string>
<string name="player_ua">User-Agent</string>
<!-- Search -->
@ -314,4 +315,9 @@
<item>Select subtitle track</item>
</string-array>
<string-array name="select_rtsp">
<item>UDP</item>
<item>TCP</item>
</string-array>
</resources>

@ -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() {
@ -819,7 +819,6 @@ public class LiveActivity extends BaseActivity implements Clock.Callback, Custom
resetToggle();
hideProgress();
mPlayers.reset();
setSpeedVisible();
setTrackVisible(true);
checkPlayImg(mPlayers.isPlaying());
mBinding.control.size.setText(mPlayers.getSizeText());
@ -831,12 +830,9 @@ public class LiveActivity extends BaseActivity implements Clock.Callback, Custom
}
}
private void setSpeedVisible() {
mBinding.control.action.speed.setVisibility(mPlayers.isVod() ? View.VISIBLE : View.GONE);
}
private void setTrackVisible(boolean visible) {
mBinding.control.action.text.setVisibility(visible && mPlayers.haveTrack(C.TRACK_TYPE_TEXT) ? View.VISIBLE : View.GONE);
mBinding.control.action.speed.setVisibility(visible && mPlayers.isVod() ? View.VISIBLE : View.GONE);
mBinding.control.action.audio.setVisibility(visible && mPlayers.haveTrack(C.TRACK_TYPE_AUDIO) ? View.VISIBLE : View.GONE);
mBinding.control.action.video.setVisibility(visible && mPlayers.haveTrack(C.TRACK_TYPE_VIDEO) ? View.VISIBLE : View.GONE);
}
@ -1143,7 +1139,7 @@ public class LiveActivity extends BaseActivity implements Clock.Callback, Custom
super.onUserLeaveHint();
if (isRedirect()) return;
if (isLock()) App.post(this::onLock, 500);
if (mPlayers.haveTrack(C.TRACK_TYPE_VIDEO)) mPiP.enter(this, Setting.getLiveScale() == 2);
if (mPlayers.haveTrack(C.TRACK_TYPE_VIDEO)) mPiP.enter(this, mPlayers.getVideoSize(), Setting.getLiveScale());
}
@Override

@ -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() {
@ -1700,7 +1700,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
super.onUserLeaveHint();
if (isRedirect()) return;
if (isLock()) App.post(this::onLock, 500);
if (mPlayers.haveTrack(C.TRACK_TYPE_VIDEO)) mPiP.enter(this, getScale() == 2);
if (mPlayers.haveTrack(C.TRACK_TYPE_VIDEO)) mPiP.enter(this, mPlayers.getVideoSize(), getScale());
}
@Override

@ -36,6 +36,7 @@ public class SettingPlayerFragment extends BaseFragment implements UaCallback, B
private String[] scale;
private String[] http;
private String[] flag;
private String[] rtsp;
public static SettingPlayerFragment newInstance() {
return new SettingPlayerFragment();
@ -59,6 +60,7 @@ public class SettingPlayerFragment extends BaseFragment implements UaCallback, B
mBinding.bufferText.setText(String.valueOf(Setting.getBuffer()));
mBinding.subtitleText.setText(String.valueOf(Setting.getSubtitle()));
mBinding.danmuLoadText.setText(getSwitch(Setting.isDanmuLoad()));
mBinding.rtspText.setText((rtsp = ResUtil.getStringArray(R.array.select_rtsp))[Setting.getRtsp()]);
mBinding.flagText.setText((flag = ResUtil.getStringArray(R.array.select_flag))[Setting.getFlag()]);
mBinding.httpText.setText((http = ResUtil.getStringArray(R.array.select_exo_http))[Setting.getHttp()]);
mBinding.scaleText.setText((scale = ResUtil.getStringArray(R.array.select_scale))[Setting.getScale()]);
@ -72,6 +74,7 @@ public class SettingPlayerFragment extends BaseFragment implements UaCallback, B
@Override
protected void initEvent() {
mBinding.ua.setOnClickListener(this::onUa);
mBinding.rtsp.setOnClickListener(this::setRtsp);
mBinding.http.setOnClickListener(this::setHttp);
mBinding.flag.setOnClickListener(this::setFlag);
mBinding.scale.setOnClickListener(this::onScale);
@ -104,6 +107,12 @@ public class SettingPlayerFragment extends BaseFragment implements UaCallback, B
Setting.putUa(ua);
}
private void setRtsp(View view) {
int index = Setting.getRtsp();
Setting.putRtsp(index = index == rtsp.length - 1 ? 0 : ++index);
mBinding.rtspText.setText(rtsp[index]);
}
private void setHttp(View view) {
int index = Setting.getHttp();
Setting.putHttp(index = index == http.length - 1 ? 0 : ++index);

@ -13,6 +13,7 @@ import android.view.View;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.media3.common.VideoSize;
import androidx.media3.ui.R;
import com.fongmi.android.tv.App;
@ -71,15 +72,27 @@ public class PiP {
}
}
public void enter(Activity activity, boolean four) {
public void enter(Activity activity, VideoSize size, int scale) {
try {
if (noPiP() || activity.isInPictureInPictureMode() || !Setting.isBackgroundPiP()) return;
builder.setAspectRatio(new Rational(four ? 4 : 16, four ? 3 : 9));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) builder.setAutoEnterEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) builder.setSeamlessResizeEnabled(true);
if (scale == 1) builder.setAspectRatio(new Rational(16, 9));
else if (scale == 2) builder.setAspectRatio(new Rational(4, 3));
else builder.setAspectRatio(getRational(size));
activity.enterPictureInPictureMode(builder.build());
} catch (Exception e) {
e.printStackTrace();
}
}
private Rational getRational(VideoSize size) {
Rational limitWide = new Rational(239, 100);
Rational limitTall = new Rational(100, 239);
Rational rational = new Rational(size.width, size.height);
if (rational.isInfinite()) return new Rational(16, 9);
if (rational.floatValue() > limitWide.floatValue()) return limitWide;
if (rational.floatValue() < limitTall.floatValue()) return limitTall;
return rational;
}
}

@ -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"

@ -266,6 +266,33 @@
</LinearLayout>
<LinearLayout
android:id="@+id/rtsp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_item"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/player_rtsp"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/rtspText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="UDP" />
</LinearLayout>
<LinearLayout
android:id="@+id/flag"
android:layout_width="match_parent"

Loading…
Cancel
Save