Skip to content

Commit

Permalink
feat:update AliVCSDK to version v6.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
善师 committed Nov 3, 2023
1 parent 64ac9fb commit 1de7f02
Show file tree
Hide file tree
Showing 23 changed files with 167 additions and 175 deletions.
1 change: 0 additions & 1 deletion AliLivePushDemo/AUIFoundation

This file was deleted.

1 change: 0 additions & 1 deletion AliLivePushDemo/AndroidThirdParty

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import com.aliyun.aio.avbaseui.widget.AVCircleProgressView;
import com.aliyun.aio.avbaseui.widget.AVToast;
import com.aliyun.common.global.Version;
import com.aliyun.svideosdk.common.struct.common.MediaType;
import com.aliyun.svideosdk.common.struct.encoder.VideoCodecs;
import com.aliyun.ugsv.common.utils.FileUtils;
import com.aliyun.ugsv.common.utils.ToastUtil;
import com.aliyun.svideo.base.Constants;
Expand Down Expand Up @@ -656,41 +654,25 @@ private void startCrop() {
//TODO
}

// CropParam cropParam = new CropParam();
// cropParam.setOutputPath(mOutputPath);
// cropParam.setInputPath(mInputVideoPath);
// cropParam.setOutputWidth(outputWidth);
// cropParam.setOutputHeight(outputHeight);
// Rect cropRect = new Rect(posX, posY, posX + cropWidth, posY + cropHeight);
// cropParam.setCropRect(cropRect);
// cropParam.setStartTime(mCropStartTime, TimeUnit.MILLISECONDS);
// cropParam.setEndTime(mCropEndTime, TimeUnit.MILLISECONDS);
// cropParam.setScaleMode(CropConfig.Companion.getInstance().getVideoDisplayMode());
// cropParam.setFrameRate(CropConfig.Companion.getInstance().getFps());
// cropParam.setGop(CropConfig.Companion.getInstance().getGop());
// cropParam.setQuality(CropConfig.Companion.getInstance().getVideoQuality());
// cropParam.setVideoCodec(CropConfig.Companion.getInstance().getCodec());
// cropParam.setFillColor(Color.BLACK);
// cropParam.setCrf(0);

CropParam cropParam = new CropParam();

//设置裁剪模式,Scale:等比缩放裁剪, Fill:填充模式
cropParam.setScaleMode(VideoDisplayMode.FILL);
//输出文件路径
cropParam.setOutputPath(mOutputPath);
//视频源文件路径
cropParam.setInputPath(mInputVideoPath);
//裁剪媒体类型,包括图片、视频、音频
cropParam.setMediaType(MediaType.ANY_VIDEO_TYPE);
//视频编码方式
cropParam.setVideoCodec(VideoCodecs.H264_HARDWARE);
cropParam.setVideoBitrate(3000);
cropParam.setOutputHeight(720);
cropParam.setOutputWidth(720);
cropParam.setFrameRate(30);
cropParam.setOutputWidth(outputWidth);
cropParam.setOutputHeight(outputHeight);
Rect cropRect = new Rect(posX, posY, posX + cropWidth, posY + cropHeight);
cropParam.setCropRect(cropRect);
cropParam.setStartTime(mCropStartTime, TimeUnit.MILLISECONDS);
cropParam.setEndTime(mCropEndTime, TimeUnit.MILLISECONDS);
cropParam.setScaleMode(CropConfig.Companion.getInstance().getVideoDisplayMode());
cropParam.setFrameRate(CropConfig.Companion.getInstance().getFps());
cropParam.setGop(CropConfig.Companion.getInstance().getGop());
cropParam.setQuality(CropConfig.Companion.getInstance().getVideoQuality());
cropParam.setVideoCodec(CropConfig.Companion.getInstance().getCodec());
cropParam.setFillColor(Color.BLACK);
cropParam.setCrf(0);

mCropProgress.setVisibility(View.VISIBLE);
cropParam.setUseGPU(false);
mCroptor.setCropParam(cropParam);

int ret = mCroptor.startCrop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void startVideoCropForResult(Activity context, List<String> paths,
if(paths.isEmpty() || TextUtils.isEmpty(paths.get(0))){
return;
}
CropConfig.Companion.getInstance().setInputPath("/sdcard/DCIM/45f16b1a-18acc5b36bf.mp4");
CropConfig.Companion.getInstance().setInputPath(paths.get(0));
Intent intent = new Intent(context, AliyunVideoCropActivity.class);
context.startActivityForResult(intent, requestCode);
}
Expand Down
6 changes: 3 additions & 3 deletions AndroidThirdParty/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ ext {
externalARTC = 'com.aliyun.sdk.android:AlivcArtc:6.4.0'
externalAlivcConan = 'com.alivc.conan:AlivcConan:1.0.5'
externalAlivcCore = 'com.aliyun.video.android:core:1.2.2'
externalLivePusherInteractive = "com.alivc.pusher:AlivcLivePusher_Interactive:6.5.0"
externalLivePusher = "com.alivc.pusher:AlivcLivePusher:6.5.0"
externalAllInOne = 'com.aliyun.aio:AliVCSDK_Premium:6.5.0'
externalLivePusherInteractive = "com.alivc.pusher:AlivcLivePusher_Interactive:6.4.0"
externalLivePusher = "com.alivc.pusher:AlivcLivePusher:6.4.0"
externalAllInOne = 'com.aliyun.aio:AliVCSDK_Premium:6.4.0'

//内部调试代码,发布删除 -- 注释勿动
if(debug != null && "true".equalsIgnoreCase(debug)){ //内部调试代码,发布删除 -- 注释勿动
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class AUIVideoEpisodeController {
private final AliListPlayer aliListPlayer;
private int mOldPosition = 0;
private int mCurrentPlayerState;
private int mCurrentPlayerStateCallBack;
private final SparseArray<String> mIndexWithUUID = new SparseArray<>();
private PlayerListener mPlayerListener;
private IPlayer preRenderPlayer;
Expand Down Expand Up @@ -77,8 +76,6 @@ private void initPlayerListeners() {
});

aliListPlayer.setOnStateChangedListener(i -> {
mCurrentPlayerStateCallBack = i;
mPlayerListener.onPlayStateChanged(-1, mCurrentPlayerStateCallBack == IPlayer.paused);
});

aliListPlayer.setOnErrorListener((ErrorInfo errorInfo) -> {
Expand Down Expand Up @@ -116,7 +113,7 @@ public void setPlayerListener(PlayerListener listener) {

//用于剧集的跳转
public void onPageSelected(int position) {
Log.i("CheckFunc", "onPageSelected (int) position " + position);
Log.i("CheckFunc", "onPageSelected (int)" + " position " + position);

aliListPlayer.moveTo(mIndexWithUUID.get(position));
this.mOldPosition = position;
Expand Down Expand Up @@ -150,8 +147,6 @@ public void onPageSelected(int position, Surface surface) {
}
);
preRenderPlayer.setOnStateChangedListener(i -> {
mCurrentPlayerStateCallBack = i;
mPlayerListener.onPlayStateChanged(-1, mCurrentPlayerStateCallBack == IPlayer.paused);
});

preRenderPlayer.setOnPreparedListener(() -> {
Expand Down Expand Up @@ -213,31 +208,20 @@ public void destroy() {
}

public void onPlayStateChange() {
Log.i("CheckFunc", "onPlayStateChange" + " mCurrentPlayerState " + mCurrentPlayerState + " moldPosition " + mOldPosition + " mCurrentPlayerStateCallBack " + mCurrentPlayerStateCallBack);
if (mCurrentPlayerStateCallBack < IPlayer.prepared){
return;
}
Log.i("CheckFunc", "onPlayStateChange" + " mCurrentPlayerState " + mCurrentPlayerState + " moldPosition " + mOldPosition);
if (mCurrentPlayerState == IPlayer.paused) {
aliListPlayer.start();
mCurrentPlayerState = IPlayer.started;
} else {
aliListPlayer.pause();
mCurrentPlayerState = IPlayer.paused;
}

mPlayerListener.onPlayStateChanged(-1, mCurrentPlayerState == IPlayer.paused);
}

public void seek(long seekPosition) {
if(seekPosition >= aliListPlayer.getDuration()){
// 避免直接跳转到视频尾部,与自动跳转到下一集出现逻辑上的冲突,出现黑屏的的情况。
seekPosition -= 10;
}
if(seekPosition < 0 || seekPosition > aliListPlayer.getDuration()){
Log.w("CheckFunc", "seek, seekTo not valid: " + seekPosition);
return;
}
aliListPlayer.seekTo(seekPosition);
Log.i("CheckFunc", "seek, seekTo " + seekPosition);

}

public void pausePlay() {
Expand All @@ -248,10 +232,6 @@ public void resumePlay() {
aliListPlayer.start();
}

public boolean isCurrentPlayerStateCallBackPaused(){
return mCurrentPlayerStateCallBack == IPlayer.paused;
}

//backUp: in case of preRenderPlayer onRenderingStart being called back ,aliListPlayer cannot get onRenderingStart called back.
private void toRenderingStartOnInfo() {
if (aliListPlayer.getDuration() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
public class AUIEpisodePanelAdapter extends RecyclerView.Adapter<AUIEpisodePanelAdapter.PanelViewHolder> {

private List<AUIEpisodeVideoInfo> mEpisodeVideoInfos = null;
private int mSelectedPosition = -1;

private OnPanelEventListener mOnPanelEventListener = null;

Expand All @@ -46,8 +45,6 @@ public void onBindViewHolder(@NonNull PanelViewHolder holder, int position) {
AUIEpisodeVideoInfo episodeVideoInfo = mEpisodeVideoInfos.get(position);
episodeVideoInfo.setPosition(position);
holder.bind(episodeVideoInfo);
//Log.i("CheckFunc", "setSelected: " + position + ", " + mSelectedPosition);
holder.setSelected(position == mSelectedPosition);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -67,9 +64,8 @@ public void initListener(OnPanelEventListener listener) {
mOnPanelEventListener = listener;
}

public void initData(List<AUIEpisodeVideoInfo> episodeVideoInfos, int selectedPosition) {
public void initData(List<AUIEpisodeVideoInfo> episodeVideoInfos) {
mEpisodeVideoInfos = episodeVideoInfos;
mSelectedPosition = selectedPosition;
}

public static class PanelViewHolder extends RecyclerView.ViewHolder {
Expand All @@ -93,11 +89,8 @@ public void bind(@NonNull AUIEpisodeVideoInfo episodeVideoInfo) {
mDescriptionTextView.setText(episodeVideoInfo.getTitle());
mVideoDurationTextView.setText(AUIEpisodeVideoInfo.formatTimeDuration(episodeVideoInfo.videoDuration));
mPlayCountTextView.setText(AUIEpisodeVideoInfo.formatNumber(episodeVideoInfo.videoPlayCount));
}

private void setSelected(boolean selected) {
mSoundImageView.setVisibility(selected ? View.VISIBLE : View.GONE);
mContainerView.setBackgroundColor(itemView.getContext().getResources().getColor(selected ? R.color.fill_medium : R.color.bg_weak));
mSoundImageView.setVisibility(episodeVideoInfo.isSelected ? View.VISIBLE : View.GONE);
mContainerView.setBackgroundColor(itemView.getContext().getResources().getColor(episodeVideoInfo.isSelected ? R.color.fill_medium : R.color.bg_weak));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ public class AUIVideoEpisodeViewHolder extends AUIVideoListViewHolder {

private static final long VIEW_ANIMATION_DURATION_MS = 330L;

private AUIEpisodeVideoInfo mEpisodeVideoInfo;
private int mPosition;

private AUIVideoInteractiveComponent mInteractiveComponent;
private AUIVideoDetailComponent mDetailComponent;

Expand All @@ -106,10 +103,11 @@ public class AUIVideoEpisodeViewHolder extends AUIVideoListViewHolder {
private OnInteractiveEventListener mOnInteractiveEventListener = null;
private OnPanelEventListener mOnPanelEventListener = null;

private AUIVideoEpisodeViewHolder(View itemView) {
public AUIVideoEpisodeViewHolder(View itemView) {
super(itemView);
initViews();
initCallback();
initData();
}

public Surface getSurface() {
Expand Down Expand Up @@ -174,6 +172,11 @@ public void onItemClicked(AUIEpisodeVideoInfo episodeVideoInfo) {
});
}

private void initData() {
mBarComponent.initData(mEpisodeData);
mPanelComponent.initData(mEpisodeData);
}

public void initSurfaceListener(OnSurfaceListener listener) {
mOnSurfaceListener = listener;
}
Expand All @@ -198,13 +201,11 @@ public void bindUrl(String url) {

@Override
public void onBind(VideoInfo videoInfo) {
mPosition = videoInfo.getPosition();
mEpisodeVideoInfo = mEpisodeData.list.get(mPosition);
mBarComponent.initData(mEpisodeData);
mPanelComponent.initData(mEpisodeData, mPosition);
mPanelComponent.updateView(mEpisodeVideoInfo, mPosition);
mDetailComponent.initData(mEpisodeVideoInfo);
mInteractiveComponent.initData(mEpisodeVideoInfo);
int position = videoInfo.getPosition();
AUIEpisodeVideoInfo episodeVideoInfo = mEpisodeData.list.get(position);

mDetailComponent.initData(episodeVideoInfo);
mInteractiveComponent.initData(episodeVideoInfo);
}

@Override
Expand All @@ -225,7 +226,6 @@ public boolean hidePanelIfNeed() {
}

private void showPanel() {
mPanelComponent.updateView(mEpisodeVideoInfo, mPosition);
mBarComponent.setVisibility(View.GONE);
setVisibilityWithAnimation(mPanelComponent, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
import com.alivc.auiplayer.videoepisode.R;
import com.alivc.auiplayer.videoepisode.adapter.AUIEpisodePanelAdapter;
import com.alivc.auiplayer.videoepisode.data.AUIEpisodeData;
import com.alivc.auiplayer.videoepisode.data.AUIEpisodeVideoInfo;
import com.alivc.auiplayer.videoepisode.data.AUIEpisodeDataEvent;
import com.alivc.auiplayer.videoepisode.listener.OnPanelEventListener;
import com.alivc.player.videolist.auivideolistcommon.view.CenterLayoutManager;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
* @author keria
* @date 2023/8/29
Expand Down Expand Up @@ -70,7 +74,6 @@ public void onClick(View v) {
mRecyclerView = view.findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setItemViewCacheSize(0);
mRecyclerView.setDrawingCacheEnabled(false);
mRecyclerView.setAdapter(mAdapter);
mAdapter.initListener(mOnPanelEventListener);
}
Expand All @@ -80,20 +83,37 @@ public void initListener(OnPanelEventListener listener) {
mAdapter.initListener(mOnPanelEventListener);
}

public void initData(AUIEpisodeData episodeData, int index) {
public void initData(AUIEpisodeData episodeData) {
if (episodeData == null || episodeData.list == null || episodeData.list.isEmpty()) {
return;
}
mAdapter.initData(episodeData.list, index);
mAdapter.notifyDataSetChanged();
mAdapter.initData(episodeData.list);
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
EventBus.getDefault().register(this);
}

public void updateView(AUIEpisodeVideoInfo episodeVideoInfo, int index) {
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
EventBus.getDefault().unregister(this);
}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(AUIEpisodeDataEvent event) {
if (event == null) {
return;
}
if (mRecyclerView != null) {
mRecyclerView.scrollToPosition(index);
mRecyclerView.scrollToPosition(event.curIndex);
}
if (mTitleTextView != null) {
mTitleTextView.setText(episodeVideoInfo != null ? episodeVideoInfo.getTitle() : null);
mTitleTextView.setText(event.episodeVideoInfo != null ? event.episodeVideoInfo.getTitle() : null);
}
mAdapter.notifyItemChanged(event.preIndex);
mAdapter.notifyItemChanged(event.curIndex);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.alivc.auiplayer.videoepisode.data;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;

@Keep
public class AUIEpisodeDataEvent {
public int preIndex;
public int curIndex;
public AUIEpisodeVideoInfo episodeVideoInfo;

public AUIEpisodeDataEvent(int preIndex, int curIndex, @NonNull AUIEpisodeVideoInfo episodeVideoInfo) {
this.preIndex = preIndex;
this.curIndex = curIndex;
this.episodeVideoInfo = episodeVideoInfo;
}

@Override
public String toString() {
return "AUIEpisodeDataEvent{" +
"preIndex=" + preIndex +
", curIndex=" + curIndex +
", episodeVideoInfo=" + episodeVideoInfo +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public class AUIEpisodeVideoInfo extends VideoInfo {
*/
public int videoPlayCount;

/**
* 当前是否选中播放
*/
public boolean isSelected;

/// --------视频互动信息--------

/**
Expand Down
Loading

0 comments on commit 1de7f02

Please sign in to comment.