This commit is contained in:
zlzw 2022-12-28 17:51:35 +08:00
parent 339d460c0f
commit 137dbc72d8
10 changed files with 194 additions and 55 deletions

View File

@ -10,9 +10,9 @@ ext {
manifestPlaceholders = [ manifestPlaceholders = [
// //
serverHost : "https://napi.yaoulive.com", // serverHost : "https://napi.yaoulive.com",
// //
// serverHost : "https://ceshi.yaoulive.com", serverHost : "https://ceshi.yaoulive.com",
// //
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

View File

@ -1 +1 @@
apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { abiFilters "armeabi-v7a", "arm64-v8a" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path: ':common') api project(path:':FaceUnity')//新娱美颜 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" } apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { abiFilters "armeabi-v7a", "arm64-v8a" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path: ':common') api project(path:':FaceUnity')//新娱美颜 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" //ExoPlayer,腾讯的播放器不支持无缝切换 implementation 'com.google.android.exoplayer:exoplayer:2.18.2' implementation 'com.google.android.exoplayer:exoplayer-core:2.18.2@aar' }

View File

@ -128,7 +128,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
* @param url 流地址 * @param url 流地址
*/ */
@Override @Override
public void play(String url) { public void play(String url,int playModel) {
mPlayer = new V2TXLivePlayerImpl(mContext); mPlayer = new V2TXLivePlayerImpl(mContext);
if (TextUtils.isEmpty(url) || mVideoView == null) { if (TextUtils.isEmpty(url) || mVideoView == null) {

View File

@ -6,15 +6,14 @@ import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL
import android.Manifest; import android.Manifest;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent; import android.view.ViewParent;
@ -23,19 +22,18 @@ import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.alibaba.fastjson.JSON; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Tracks;
import com.google.android.exoplayer2.video.VideoSize;
import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.EasyFloat;
import com.lzy.okserver.OkDownload;
import com.lzy.okserver.download.DownloadTask;
import com.tencent.live2.V2TXLiveDef;
import com.tencent.live2.V2TXLivePlayer;
import com.tencent.live2.V2TXLivePlayerObserver;
import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.bean.CrashSaveBean;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
@ -56,7 +54,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCRemoteUser; import cn.rongcloud.rtc.api.RCRTCRemoteUser;
@ -89,7 +86,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private ViewGroup mLeftContainer; private ViewGroup mLeftContainer;
private ViewGroup mRightContainer; private ViewGroup mRightContainer;
private RelativeLayout mPkContainer; private RelativeLayout mPkContainer;
public static TXCloudVideoView mVideoView; public static SurfaceView mVideoView;
private View mLoading, mLoading2; private View mLoading, mLoading2;
private ImageView mCover; private ImageView mCover;
@ -101,15 +98,16 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private boolean mPausedPlay;//是否被动暂停了播放 private boolean mPausedPlay;//是否被动暂停了播放
public int landscape; //1h 2s public int landscape; //1h 2s
public static Context contexts; public static Context contexts;
public V2TXLivePlayer mPlayer;
public static FrameLayout ry_view; public static FrameLayout ry_view;
private static final int VIDEO_VERTICAL = 1; private static final int VIDEO_VERTICAL = 1;
private static final int VIDEO_HORIZONTAL = 2; private static final int VIDEO_HORIZONTAL = 2;
int videoLandscape; // 视频方向1=竖屏2=横屏 int videoLandscape = -1; // 视频方向1=竖屏2=横屏
static int vHeight;//视频高 static int vHeight;//视频高
private TextView debugView; private TextView debugView;
private ExoPlayer mPlayer, mPlayer2;
private boolean isPlayer = true;
//0未申请1申请中2连麦中 //0未申请1申请中2连麦中
@ -141,7 +139,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mLeftContainer = (ViewGroup) findViewById(R.id.left_container); mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
mRightContainer = (ViewGroup) findViewById(R.id.right_container); mRightContainer = (ViewGroup) findViewById(R.id.right_container);
mPkContainer = (RelativeLayout) findViewById(R.id.pk_container); mPkContainer = (RelativeLayout) findViewById(R.id.pk_container);
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view); mVideoView = (SurfaceView) findViewById(R.id.video_view);
ry_view = (FrameLayout) findViewById(R.id.ry_view); ry_view = (FrameLayout) findViewById(R.id.ry_view);
leave = (ImageView) findViewById(R.id.leave); leave = (ImageView) findViewById(R.id.leave);
mLoading = findViewById(R.id.loading); mLoading = findViewById(R.id.loading);
@ -154,9 +152,14 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams();
params.height = vHeight; params.height = vHeight;
mPkContainer.requestLayout(); mPkContainer.requestLayout();
mPlayer = new V2TXLivePlayerImpl(mContext);
mPlayer.setRenderView(mVideoView);
mPlayer = new ExoPlayer.Builder(mContext)
.build();
mPlayer2 = new ExoPlayer.Builder(mContext).build();
mPlayer.setVideoSurfaceView(mVideoView);
mPlayer2.setVideoSurfaceView(mVideoView);
mPlayer.addListener(new ExoPlayerListener(true));
mPlayer2.addListener(new ExoPlayerListener(false));
debugView = new TextView(mContext); debugView = new TextView(mContext);
debugView.setBackgroundColor(Color.WHITE); debugView.setBackgroundColor(Color.WHITE);
@ -247,13 +250,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
*/ */
@Override @Override
public void resumePlay() { public void resumePlay() {
if (mPlayer.isPlaying() != 1) { if (!mPlayer.isPlaying()) {
new Handler(Looper.getMainLooper()) new Handler(Looper.getMainLooper())
.postDelayed(() -> { .postDelayed(() -> {
mPlayer.stopPlay(); mPlayer.stop();
int val = mPlayer.startPlay(purl); mPlayer.play();
// ToastUtil.show("强制播放" + val); // ToastUtil.show("强制播放" + val);
Log.i(TAG, "强制播放: " + val);
}, 100); }, 100);
} }
} }
@ -264,7 +266,14 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
* @param url 流地址 * @param url 流地址
*/ */
@Override @Override
public void play(String url) { public void play(String url, int playModel) {
if (playModel != PLAY_MODEL_DEF) {
if (videoLandscape == VIDEO_VERTICAL) {
url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
} else if (videoLandscape == VIDEO_HORIZONTAL) {
url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
}
}
Log.e("purl121", url); Log.e("purl121", url);
if (TextUtils.isEmpty(url) || mVideoView == null) { if (TextUtils.isEmpty(url) || mVideoView == null) {
@ -275,16 +284,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (TextUtils.isEmpty(url) || mVideoView == null) { if (TextUtils.isEmpty(url) || mVideoView == null) {
return; return;
} }
mVideoView.clearLastFrame(true);
mPlayer.setObserver(new V2TXLivePlayerObserver() {
String TAG = "播放流";
@Override /*mPlayer.setObserver(new V2TXLivePlayerObserver() {
public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
super.onError(player, code, msg, extraInfo);
Log.i(TAG, "onError: player = " + player + ", code = " + code + ", msg = " + msg + ", extraInfo = " + extraInfo);
debugView.setText("播放出错code=" + code + " msg=" + msg);
}
@Override @Override
public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) {
@ -388,21 +391,55 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data) { public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data) {
super.onReceiveSeiMessage(player, payloadType, data); super.onReceiveSeiMessage(player, payloadType, data);
} }
}); });*/
MediaItem item = createMediaItem(url);
if (mPlayer.isPlaying()) {
ToastUtil.show("set 2");
mPlayer2.setMediaItem(item);
mPlayer2.setVideoSurfaceView(mVideoView);
mPlayer2.prepare();
mPlayer2.play();
} else {
ToastUtil.show("set 1");
mPlayer.setMediaItem(item);
mPlayer.setVideoSurfaceView(mVideoView);
mPlayer.prepare();
mPlayer.play();
}
/* if (mPlayer.isPlaying()) {
MediaSource nextSource = new ProgressiveMediaSource.Factory(new DefaultHttpDataSource.Factory())
.createMediaSource(createMediaItem(url));
MediaSource oldSource = new ProgressiveMediaSource.Factory(new DefaultHttpDataSource.Factory())
.createMediaSource(mPlayer.getCurrentMediaItem());
ClippingMediaSource clippingMediaSource = new ClippingMediaSource(oldSource, 0, 3000, false, true, true);
ConcatenatingMediaSource source = new ConcatenatingMediaSource(clippingMediaSource, nextSource);
mPlayer.addMediaSource(source);
mPlayer.prepare();
mPlayer.setPlayWhenReady(true);
} else {
MediaItem item = createMediaItem(url);
mPlayer.setMediaItem(item);
mPlayer.prepare();
mPlayer.play();
}*/
purl = url; purl = url;
int V2TXLiveCode = mPlayer.startPlay(url);
onPrepared(); onPrepared();
} }
private MediaItem createMediaItem(String url) {
MediaItem mediaItem = MediaItem.fromUri(url);
return mediaItem;
}
@Override @Override
public void release() { public void release() {
mEnd = true; mEnd = true;
mStarted = false; mStarted = false;
if (mPlayer != null) { if (mPlayer != null) {
mPlayer.stopPlay(); mPlayer.stop();
mPlayer.release();
} }
L.e(TAG, "release------->"); L.e(TAG, "release------->");
} }
@ -416,7 +453,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} }
} }
if (mPlayer != null) { if (mPlayer != null) {
mPlayer.stopPlay(); mPlayer.stop();
} }
stopPlay2(); stopPlay2();
} }
@ -629,7 +666,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0; params.topMargin = 0;
params.addRule(RelativeLayout.ALIGN_TOP); params.addRule(RelativeLayout.ALIGN_TOP);
mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270); // mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270);
mVideoView.requestLayout(); mVideoView.requestLayout();
} }
@ -639,7 +676,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight; params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0); // mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
params.addRule(RelativeLayout.ALIGN_TOP); params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout(); mVideoView.requestLayout();
} }
@ -703,10 +740,13 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Log.e("ry", "退出多人房间成功"); Log.e("ry", "退出多人房间成功");
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() { public void run() {
mPlayer.startPlay(purl); mPlayer.play();
Log.e("ry", mPlayer.isPlaying() + "purl" + purl); Log.e("ry", mPlayer.isPlaying() + "purl" + purl);
if (mPlayer.isPlaying() != 1) { if (!mPlayer.isPlaying()) {
mPlayer.startPlay(purl); MediaItem item = createMediaItem(purl);
mPlayer.setMediaItem(item);
mPlayer.prepare();
mPlayer.play();
} }
ry_view.removeAllViews(); ry_view.removeAllViews();
ry_view.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; ry_view.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
@ -783,7 +823,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
for (RCRTCInputStream stream : data.getLiveStreams()) { for (RCRTCInputStream stream : data.getLiveStreams()) {
if (stream.getMediaType() == RCRTCMediaType.VIDEO) { if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
//暂停播放 //暂停播放
mPlayer.stopPlay(); mPlayer.stop();
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
//如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示 //如果远端用户发布的是视频流创建显示视图RCRTCVideoView并添加到布局中显示
@ -1020,4 +1060,86 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} }
}); });
} }
protected void startPlay() {
if (mPlayer.isPlaying()) {
mPlayer.stop();
mPlayer2.play();
} else {
mPlayer2.stop();
mPlayer.play();
}
}
private class ExoPlayerListener implements Player.Listener {
String TAG = "播放流";
boolean isPlayer1;
public ExoPlayerListener(boolean isPlayer1) {
this.isPlayer1 = isPlayer1;
}
@Override
public void onPlaybackStateChanged(int playbackState) {
Player.Listener.super.onPlaybackStateChanged(playbackState);
if (playbackState == Player.STATE_READY) {
if (isPlayer1) {
mPlayer2.stop();
Log.i(TAG, "onPlaybackStateChanged1: " + mPlayer.getCurrentMediaItem().localConfiguration.uri);
mPlayer.setVideoSurfaceView(mVideoView);
mPlayer.play();
} else {
mPlayer.stop();
Log.i(TAG, "onPlaybackStateChanged2: " + mPlayer2.getCurrentMediaItem().localConfiguration.uri);
mPlayer2.setVideoSurfaceView(mVideoView);
mPlayer2.play();
}
}else if (playbackState==Player.STATE_IDLE){
if(!isPlayer1){
mPlayer.stop();
mPlayer2.prepare();
}else{
/* mPlayer2.stop();
mPlayer.prepare();*/
}
}
Log.i(TAG, "onPlaybackStateChanged: " + playbackState + " play = " + isPlayer1 + " p1 = " + mPlayer.isPlaying() + " p2 = " + mPlayer2.isPlaying());
isPlayer = !isPlayer;
}
@Override
public void onMediaItemTransition(@Nullable MediaItem mediaItem, int reason) {
Player.Listener.super.onMediaItemTransition(mediaItem, reason);
Log.i(TAG, "onMediaItemTransition: " + reason);
}
@Override
public void onPlayerError(PlaybackException error) {
Player.Listener.super.onPlayerError(error);
debugView.setText("播放出错code=" + error.errorCode + " msg=" + error.getErrorCodeName());
}
@Override
public void onVideoSizeChanged(VideoSize videoSize) {
Player.Listener.super.onVideoSizeChanged(videoSize);
if (videoSize.height > videoSize.width) {
videoLandscape = VIDEO_VERTICAL;
} else {
videoLandscape = VIDEO_HORIZONTAL;
}
}
@Override
public void onTimelineChanged(Timeline timeline, int reason) {
Player.Listener.super.onTimelineChanged(timeline, reason);
Log.i(TAG, "onTimelineChanged: " + reason);
}
@Override
public void onTracksChanged(Tracks tracks) {
Player.Listener.super.onTracksChanged(tracks);
Log.i(TAG, "onTracksChanged: " + tracks.getGroups().size());
}
}
} }

View File

@ -257,7 +257,7 @@ public class LivePlayTxViewHolder extends LiveRoomPlayViewHolder implements ITXL
* @param url 流地址 * @param url 流地址
*/ */
@Override @Override
public void play(String url) { public void play(String url,int playModel) {
url = "webrtc://5664.liveplay.myqcloud.com/live/5664_harchar1"; url = "webrtc://5664.liveplay.myqcloud.com/live/5664_harchar1";
mPlayer = new V2TXLivePlayerImpl(mContext); mPlayer = new V2TXLivePlayerImpl(mContext);

View File

@ -251,7 +251,7 @@ public class LivePlayTxViewHolder_backup extends LiveRoomPlayViewHolder implemen
* @param url 流地址 * @param url 流地址
*/ */
@Override @Override
public void play(String url) { public void play(String url,int playModel) {
if (TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
return; return;
} }

View File

@ -13,14 +13,21 @@ import com.yunbao.live.interfaces.ILiveLinkMicViewHolder;
public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements ILiveLinkMicViewHolder { public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements ILiveLinkMicViewHolder {
protected LiveBean mLiveBean; protected LiveBean mLiveBean;
public static final int PLAY_MODEL_DEF=-1;
public static final int PLAY_MODEL_480=0;
public static final int PLAY_MODEL_720=1;
public static final int PLAY_MODEL_1080=2;
public static final String[] videoRatioHorizontal = new String[]{"_640_480", "_960_720", "_1920_1080","_180_180"};
public static final String[] videoRatioVertical = new String[]{"_480_640", "_720_960", "_1080_1920","_180_180"};
public static final String[] videoFps = new String[]{"_24", "_30"};
OnMicCallback onMicCallback;//连麦回调 OnMicCallback onMicCallback;//连麦回调
public LiveRoomPlayViewHolder(Context context, ViewGroup parentView) { public LiveRoomPlayViewHolder(Context context, ViewGroup parentView) {
super(context, parentView); super(context, parentView);
} }
public abstract void play(String url); public abstract void play(String url,int playModel);
public abstract void stopPlay(); public abstract void stopPlay();

View File

@ -837,8 +837,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mLiveUserAdapter.setOnItemClickListener(new OnItemClickListener<UserBean>() { mLiveUserAdapter.setOnItemClickListener(new OnItemClickListener<UserBean>() {
@Override @Override
public void onItemClick(UserBean bean, int position) { public void onItemClick(UserBean bean, int position) {
if (position < 4) {
ToastUtil.show("切换:" + LiveRoomPlayViewHolder.videoRatioVertical[position]);
PortraitLiveManager.portraitLiveManager.test(position);
} else {
showUserDialog(bean.getId()); showUserDialog(bean.getId());
} }
}
}); });
mUserRecyclerView.setAdapter(mLiveUserAdapter); mUserRecyclerView.setAdapter(mLiveUserAdapter);
//聊天栏 //聊天栏

View File

@ -186,6 +186,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
private int landscape; private int landscape;
private String leaveStream = "", leaveGroupId = ""; private String leaveStream = "", leaveGroupId = "";
public static PortraitLiveManager portraitLiveManager;
public PortraitLiveManager setQuitF(boolean quitF) { public PortraitLiveManager setQuitF(boolean quitF) {
isQuitF = quitF; isQuitF = quitF;
@ -196,6 +198,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
this.mContext = context; this.mContext = context;
this.mIntent = intent; this.mIntent = intent;
liveImDeletUtil = new LiveImDeletUtil(); liveImDeletUtil = new LiveImDeletUtil();
portraitLiveManager=this;
ininView(); ininView();
} }
@ -296,7 +299,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mask.setVisibility(View.VISIBLE); mask.setVisibility(View.VISIBLE);
mLivePlayViewHolder.setLiveBean(mLiveBean); mLivePlayViewHolder.setLiveBean(mLiveBean);
mLivePlayViewHolder.setCover(mLiveBean.getAvatar()); mLivePlayViewHolder.setCover(mLiveBean.getAvatar());
mLivePlayViewHolder.play(mLiveBean.getPull()); mLivePlayViewHolder.play(mLiveBean.getPull(), LiveRoomPlayViewHolder.PLAY_MODEL_DEF);
mLivePlayViewHolder.setOnMicCallback(new LiveRoomPlayViewHolder.OnMicCallback() { mLivePlayViewHolder.setOnMicCallback(new LiveRoomPlayViewHolder.OnMicCallback() {
@Override @Override
public void onMikUpdate() { public void onMikUpdate() {
@ -326,7 +329,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}); });
} }
public void test(int model) {
mLivePlayViewHolder.play(mLiveBean.getPull(), model);
}
private Runnable sendFIm = new Runnable() { private Runnable sendFIm = new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -7,7 +7,7 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.tencent.rtmp.ui.TXCloudVideoView <SurfaceView
android:id="@+id/video_view" android:id="@+id/video_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />