提交 d84aee2d authored 作者: kongdywang's avatar kongdywang

1. fix playback failed when in pip after recover from lock screen

2. superPlayer Widget fix replay failed after play error 3. superPlayer Widget now will throw playback error msg (cherry picked from commit 8ac09f2e)
上级 2ea7d7a0
...@@ -13,7 +13,7 @@ import android.content.IntentFilter; ...@@ -13,7 +13,7 @@ import android.content.IntentFilter;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PixelFormat; import android.graphics.SurfaceTexture;
import android.os.Build; import android.os.Build;
import android.os.Build.VERSION; import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES; import android.os.Build.VERSION_CODES;
...@@ -22,11 +22,10 @@ import android.os.Handler; ...@@ -22,11 +22,10 @@ import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Surface; import android.view.Surface;
import android.view.SurfaceHolder; import android.view.TextureView;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
...@@ -36,7 +35,6 @@ import com.tencent.rtmp.ITXLivePlayListener; ...@@ -36,7 +35,6 @@ import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.ITXVodPlayListener; import com.tencent.rtmp.ITXVodPlayListener;
import com.tencent.rtmp.TXLiveConstants; import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePlayer; import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.TXVodConstants;
import com.tencent.rtmp.TXVodPlayer; import com.tencent.rtmp.TXVodPlayer;
import com.tencent.vod.flutter.FTXEvent; import com.tencent.vod.flutter.FTXEvent;
import com.tencent.vod.flutter.FTXPIPManager.PipParams; import com.tencent.vod.flutter.FTXPIPManager.PipParams;
...@@ -47,7 +45,7 @@ import com.tencent.vod.flutter.tools.TXFlutterEngineHolder; ...@@ -47,7 +45,7 @@ import com.tencent.vod.flutter.tools.TXFlutterEngineHolder;
import com.tencent.vod.flutter.tools.TXSimpleEventBus; import com.tencent.vod.flutter.tools.TXSimpleEventBus;
public class FlutterPipImplActivity extends Activity implements Callback, ITXVodPlayListener, public class FlutterPipImplActivity extends Activity implements TextureView.SurfaceTextureListener, ITXVodPlayListener,
ITXLivePlayListener, ServiceConnection { ITXLivePlayListener, ServiceConnection {
private static final String TAG = "FlutterPipImplActivity"; private static final String TAG = "FlutterPipImplActivity";
...@@ -69,8 +67,9 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod ...@@ -69,8 +67,9 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
private int configWidth = 0; private int configWidth = 0;
private int configHeight = 0; private int configHeight = 0;
private SurfaceView mVideoSurface; private TextureView mVideoSurface;
private ProgressBar mVideoProgress; private ProgressBar mVideoProgress;
private RelativeLayout mPipContainer;
private boolean mIsSurfaceCreated = false; private boolean mIsSurfaceCreated = false;
// In picture-in-picture mode, clicking the X in the upper right corner will trigger `onStop` first. // In picture-in-picture mode, clicking the X in the upper right corner will trigger `onStop` first.
...@@ -141,9 +140,10 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod ...@@ -141,9 +140,10 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
bindAndroid12BugServiceIfNeed(); bindAndroid12BugServiceIfNeed();
registerPipBroadcast(); registerPipBroadcast();
setContentView(R.layout.activity_flutter_pip_impl); setContentView(R.layout.activity_flutter_pip_impl);
mVideoSurface = findViewById(R.id.sv_video_container); mVideoSurface = findViewById(R.id.tv_video_container);
mVideoProgress = findViewById(R.id.pb_video_progress); mVideoProgress = findViewById(R.id.pb_video_progress);
mVideoSurface.getHolder().addCallback(this); mPipContainer = findViewById(R.id.rl_pip_container);
mVideoSurface.setSurfaceTextureListener(this);
if (null == pipPlayerHolder) { if (null == pipPlayerHolder) {
LiteavLog.e(TAG, "lack pipPlayerHolder, please check the pip argument"); LiteavLog.e(TAG, "lack pipPlayerHolder, please check the pip argument");
finish(); finish();
...@@ -401,7 +401,7 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod ...@@ -401,7 +401,7 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
private void startPipVideo() { private void startPipVideo() {
if (mIsSurfaceCreated) { if (mIsSurfaceCreated) {
attachSurface(mVideoSurface.getHolder().getSurface()); attachSurface(new Surface(mVideoSurface.getSurfaceTexture()));
startPlay(); startPlay();
} }
} }
...@@ -418,20 +418,26 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod ...@@ -418,20 +418,26 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
} }
@Override @Override
public void surfaceCreated(SurfaceHolder holder) { public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surface, int width, int height) {
mIsSurfaceCreated = true; mIsSurfaceCreated = true;
holder.setFormat(PixelFormat.TRANSLUCENT); attachSurface(new Surface(surface));
attachSurface(holder.getSurface());
startPlay(); startPlay();
} }
@Override @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surface, int width, int height) {
} }
@Override @Override
public void surfaceDestroyed(SurfaceHolder holder) { public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surface) {
mIsSurfaceCreated = false; mIsSurfaceCreated = false;
return false;
}
@Override
public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {
} }
@Override @Override
...@@ -552,7 +558,7 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod ...@@ -552,7 +558,7 @@ public class FlutterPipImplActivity extends Activity implements Callback, ITXVod
private void showComponent() { private void showComponent() {
mVideoSurface.setVisibility(View.VISIBLE); mVideoSurface.setVisibility(View.VISIBLE);
mVideoProgress.setVisibility(View.VISIBLE); mVideoProgress.setVisibility(View.VISIBLE);
mVideoSurface.setBackgroundColor(Color.parseColor("#33000000")); mPipContainer.setBackgroundColor(Color.parseColor("#33000000"));
} }
private void controlPipPlayStatus(boolean isPlaying) { private void controlPipPlayStatus(boolean isPlaying) {
......
...@@ -3,16 +3,17 @@ ...@@ -3,16 +3,17 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rl_pip_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/transparent" android:background="@android:color/transparent"
tools:context="com.tencent.vod.flutter.ui.FlutterPipImplActivity"> tools:context="com.tencent.vod.flutter.ui.FlutterPipImplActivity">
<SurfaceView <TextureView
android:id="@+id/sv_video_container" android:id="@+id/tv_video_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/transparent" android:background="@null"
android:visibility="gone" /> android:visibility="gone" />
<ProgressBar <ProgressBar
......
...@@ -223,6 +223,12 @@ class SuperPlayerController { ...@@ -223,6 +223,12 @@ class SuperPlayerController {
} }
break; break;
} }
// -100 is IOS valid view
if (eventCode < 0 && eventCode != -100) {
_observer?.onError(SuperPlayerCode.VOD_PLAY_FAIL, event.toString());
_addSimpleEvent(SuperPlayerViewEvent.onSuperPlayerError, params: event);
_updatePlayerState(SuperPlayerState.END);
}
}); });
_vodNetEventListener = _vodPlayerController.onPlayerNetStatusBroadcast.listen((event) { _vodNetEventListener = _vodPlayerController.onPlayerNetStatusBroadcast.listen((event) {
_playerNetStatusStreamController.add(event); _playerNetStatusStreamController.add(event);
...@@ -542,7 +548,9 @@ class SuperPlayerController { ...@@ -542,7 +548,9 @@ class SuperPlayerController {
} }
} }
} else { } else {
await _playVodUrl(_currentPlayUrl); if (null != videoModel) {
await _playWithModelInner(videoModel!);
}
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论