Ijkplayer support keep_content_on_player_reset

pull/123/head
FongMi 3 years ago
parent d0b23137d4
commit a0d0629724
  1. 1
      app/src/leanback/res/layout/activity_detail.xml
  2. 1
      app/src/leanback/res/layout/activity_live.xml
  3. 1
      app/src/mobile/res/layout/activity_detail.xml
  4. 1
      app/src/mobile/res/layout/activity_live.xml
  5. 16
      ijkplayer/src/main/java/tv/danmaku/ijk/media/player/ui/IjkVideoView.java
  6. 10
      ijkplayer/src/main/res/values/attrs.xml

@ -37,6 +37,7 @@
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />

@ -32,6 +32,7 @@
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"
style="@style/Player.Live"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />

@ -32,6 +32,7 @@
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"
style="@style/Player.Vod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />

@ -32,6 +32,7 @@
<tv.danmaku.ijk.media.player.ui.IjkVideoView
android:id="@+id/ijk"
style="@style/Player.Live"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />

@ -1,6 +1,7 @@
package tv.danmaku.ijk.media.player.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
@ -42,7 +43,6 @@ public class IjkVideoView extends FrameLayout implements MediaController.MediaPl
private static final int RENDER_SURFACE_VIEW = 0;
private static final int RENDER_TEXTURE_VIEW = 1;
private int mVideoRotationDegree;
private int mVideoWidth;
private int mVideoHeight;
@ -57,6 +57,8 @@ public class IjkVideoView extends FrameLayout implements MediaController.MediaPl
private long mCurrentBufferPosition;
private float mCurrentSpeed;
private boolean mKeepContentOnPlayerReset;
private IRenderView.ISurfaceHolder mSurfaceHolder;
private IMediaPlayer.Listener mListener;
private IRenderView mRenderView;
@ -78,6 +80,7 @@ public class IjkVideoView extends FrameLayout implements MediaController.MediaPl
super(context, attrs, defStyleAttr);
LayoutInflater.from(context).inflate(R.layout.ijk_player_view, this);
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
if (attrs != null) initAttr(context, attrs, defStyleAttr);
mContentFrame = findViewById(R.id.ijk_content_frame);
mSubtitleView = findViewById(R.id.ijk_subtitle);
mCurrentState = STATE_IDLE;
@ -85,6 +88,15 @@ public class IjkVideoView extends FrameLayout implements MediaController.MediaPl
mCurrentSpeed = 1;
}
private void initAttr(Context context, AttributeSet attrs, int defStyleAttr) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.IjkVideoView, defStyleAttr, 0);
try {
mKeepContentOnPlayerReset = a.getBoolean(R.styleable.IjkVideoView_keep_content_on_player_reset, mKeepContentOnPlayerReset);
} finally {
a.recycle();
}
}
public IjkVideoView decode(int decode) {
mCurrentDecode = decode;
return this;
@ -147,6 +159,7 @@ public class IjkVideoView extends FrameLayout implements MediaController.MediaPl
}
private void setVideoURI(Uri uri, Map<String, String> headers) {
if (!mKeepContentOnPlayerReset) removeRenderView();
openVideo(uri, headers);
requestLayout();
invalidate();
@ -440,7 +453,6 @@ public class IjkVideoView extends FrameLayout implements MediaController.MediaPl
public void onInfo(IMediaPlayer mp, int what, int extra) {
mListener.onInfo(mp, what, extra);
if (what == IMediaPlayer.MEDIA_INFO_VIDEO_ROTATION_CHANGED) {
mVideoRotationDegree = extra;
if (mRenderView != null) mRenderView.setVideoRotation(extra);
}
}

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="keep_content_on_player_reset" format="boolean" />
<declare-styleable name="IjkVideoView">
<attr name="keep_content_on_player_reset" />
</declare-styleable>
</resources>
Loading…
Cancel
Save