1、启动页注释视频播放(腾讯)
This commit is contained in:
parent
b300541ce9
commit
9b4a2bd5e5
@ -33,6 +33,14 @@ import androidx.core.app.NotificationManagerCompat;
|
|||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
|
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.ui.AspectRatioFrameLayout;
|
||||||
|
import com.google.android.exoplayer2.ui.StyledPlayerView;
|
||||||
|
import com.google.android.exoplayer2.video.VideoSize;
|
||||||
import com.shayu.phonelive.AppContext;
|
import com.shayu.phonelive.AppContext;
|
||||||
import com.tencent.rtmp.ITXLivePlayListener;
|
import com.tencent.rtmp.ITXLivePlayListener;
|
||||||
import com.tencent.rtmp.TXLiveBase;
|
import com.tencent.rtmp.TXLiveBase;
|
||||||
@ -106,12 +114,13 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
private int mInterval = 2000;
|
private int mInterval = 2000;
|
||||||
private View mBtnSkipImage;
|
private View mBtnSkipImage;
|
||||||
private View mBtnSkipVideo;
|
private View mBtnSkipVideo;
|
||||||
private TXCloudVideoView mTXCloudVideoView;
|
|
||||||
private TXLivePlayer mPlayer;
|
|
||||||
private LauncherAdViewHolder mLauncherAdViewHolder;
|
private LauncherAdViewHolder mLauncherAdViewHolder;
|
||||||
private boolean mPaused;
|
private boolean mPaused;
|
||||||
private int mVideoLastProgress;
|
private int mVideoLastProgress;
|
||||||
private boolean mForward;
|
private boolean mForward;
|
||||||
|
private StyledPlayerView mPlayerView;
|
||||||
|
private ExoPlayer mPlayerForExo;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resources getResources() {
|
public Resources getResources() {
|
||||||
@ -183,6 +192,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
//解压后的文件数量必须要有2个
|
//解压后的文件数量必须要有2个
|
||||||
//如果文件存在,解压后 文件数量一致,直接进入下一步
|
//如果文件存在,解压后 文件数量一致,直接进入下一步
|
||||||
if (fileSo.exists() && getFileCount(fileSoList.getAbsolutePath()) == 2){
|
if (fileSo.exists() && getFileCount(fileSoList.getAbsolutePath()) == 2){
|
||||||
|
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// https://downs.yaoulive.com/androidLibs/t3/faceunity2-so-arm64-v8a.zip
|
// https://downs.yaoulive.com/androidLibs/t3/faceunity2-so-arm64-v8a.zip
|
||||||
@ -523,6 +533,9 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
|
if (mPlayerForExo != null) {
|
||||||
|
mPlayerForExo.release();
|
||||||
|
}
|
||||||
EventBus.getDefault().unregister(this);
|
EventBus.getDefault().unregister(this);
|
||||||
if (mHandler != null) {
|
if (mHandler != null) {
|
||||||
mHandler.removeCallbacksAndMessages(null);
|
mHandler.removeCallbacksAndMessages(null);
|
||||||
@ -602,11 +615,6 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void releaseVideo() {
|
private void releaseVideo() {
|
||||||
if (mPlayer != null) {
|
|
||||||
mPlayer.stopPlay(false);
|
|
||||||
mPlayer.setPlayListener(null);
|
|
||||||
}
|
|
||||||
mPlayer = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -685,20 +693,16 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
mPaused = true;
|
mPaused = true;
|
||||||
if (mPlayer != null && mPlayer.isPlaying()) {
|
if (mPlayerForExo != null) {
|
||||||
mPlayer.setMute(true);
|
mPlayerForExo.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (mPaused) {
|
|
||||||
if (mPlayer != null && mPlayer.isPlaying()) {
|
|
||||||
mPlayer.setMute(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,7 +737,9 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
if (mBtnSkipVideo != null && mBtnSkipVideo.getVisibility() != View.VISIBLE) {
|
if (mBtnSkipVideo != null && mBtnSkipVideo.getVisibility() != View.VISIBLE) {
|
||||||
mBtnSkipVideo.setVisibility(View.VISIBLE);
|
mBtnSkipVideo.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
mTXCloudVideoView = new TXCloudVideoView(mContext);
|
checkUidAndToken();
|
||||||
|
|
||||||
|
/* mTXCloudVideoView = new TXCloudVideoView(mContext);
|
||||||
mTXCloudVideoView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
mTXCloudVideoView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
mTXCloudVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
|
mTXCloudVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
|
||||||
mContainer.addView(mTXCloudVideoView);
|
mContainer.addView(mTXCloudVideoView);
|
||||||
@ -789,6 +795,58 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
|
|
||||||
});
|
});
|
||||||
mPlayer.startPlay(videoFile.getAbsolutePath(), TXLivePlayer.PLAY_TYPE_LOCAL_VIDEO);
|
mPlayer.startPlay(videoFile.getAbsolutePath(), TXLivePlayer.PLAY_TYPE_LOCAL_VIDEO);
|
||||||
|
*/
|
||||||
|
/* mPlayerForExo.addListener(new Player.Listener() {
|
||||||
|
@Override
|
||||||
|
public void onIsPlayingChanged(boolean isPlaying) {
|
||||||
|
Player.Listener.super.onIsPlayingChanged(isPlaying);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onPlaybackStateChanged(int playbackState) {
|
||||||
|
Player.Listener.super.onPlaybackStateChanged(playbackState);
|
||||||
|
if (playbackState == Player.STATE_ENDED) {
|
||||||
|
// 播放完成的处理逻辑
|
||||||
|
checkUidAndToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoSizeChanged(VideoSize videoSize) {
|
||||||
|
Player.Listener.super.onVideoSizeChanged(videoSize);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt("EVT_PARAM1", videoSize.width);
|
||||||
|
bundle.putInt("EVT_PARAM2", videoSize.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRenderedFirstFrame() {
|
||||||
|
Player.Listener.super.onRenderedFirstFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerError(PlaybackException error) {
|
||||||
|
Player.Listener.super.onPlayerError(error);
|
||||||
|
LogUtils.e(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerErrorChanged(@Nullable PlaybackException error) {
|
||||||
|
Player.Listener.super.onPlayerErrorChanged(error);
|
||||||
|
LogUtils.e(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mPlayerView.setPlayer(mPlayerForExo);*/
|
||||||
|
|
||||||
|
|
||||||
|
/* mPlayerView = new StyledPlayerView(mContext);
|
||||||
|
mPlayerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
mContainer.addView(mPlayerView);
|
||||||
|
// 准备媒体项并开始播放
|
||||||
|
MediaItem mediaItem = MediaItem.fromUri(videoFile.getAbsolutePath());
|
||||||
|
mPlayerForExo.setMediaItem(mediaItem);
|
||||||
|
mPlayerForExo.prepare();
|
||||||
|
mPlayerForExo.play();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
@ -803,4 +861,5 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user