视频播放UI

动态页面UI
This commit is contained in:
hch
2024-03-12 18:30:02 +08:00
parent 409e38e304
commit aa1db981e8
44 changed files with 3271 additions and 540 deletions

View File

@@ -70,10 +70,7 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList
mVideoCover = findViewById(R.id.video_cover);
mPlayBtn = findViewById(R.id.btn_play);
//暂停按钮动画
mPlayBtnAnimator = ObjectAnimator.ofPropertyValuesHolder(mPlayBtn,
PropertyValuesHolder.ofFloat("scaleX", 4f, 0.8f, 1f),
PropertyValuesHolder.ofFloat("scaleY", 4f, 0.8f, 1f),
PropertyValuesHolder.ofFloat("alpha", 0f, 1f));
mPlayBtnAnimator = ObjectAnimator.ofPropertyValuesHolder(mPlayBtn, PropertyValuesHolder.ofFloat("scaleX", 4f, 0.8f, 1f), PropertyValuesHolder.ofFloat("scaleY", 4f, 0.8f, 1f), PropertyValuesHolder.ofFloat("alpha", 0f, 1f));
mPlayBtnAnimator.setDuration(150);
mPlayBtnAnimator.setInterpolator(new AccelerateInterpolator());
}
@@ -87,9 +84,8 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList
case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://加载完成,开始播放的回调
mStartPlay = true;
if (mActionListener != null) {
mActionListener.onPlayBegin();
mActionListener.onPlayBegin(txVodPlayer.getDuration());
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_LOADING: //开始加载的回调
if (mActionListener != null) {
@@ -116,6 +112,13 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList
case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取到视频宽高回调
onVideoSizeChanged(bundle.getInt("EVT_PARAM1", 0), bundle.getInt("EVT_PARAM2", 0));
break;
case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS:
if (mActionListener != null) {
int progress = bundle.getInt(TXLiveConstants.EVT_PLAY_PROGRESS_MS);
int duration = bundle.getInt(TXLiveConstants.EVT_PLAY_DURATION_MS);
mActionListener.onProgress(progress, duration);
}
break;
}
}
@@ -289,11 +292,13 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList
public interface ActionListener {
void onPlayBegin();
void onPlayBegin(float duration);
void onPlayLoading();
void onFirstFrame();
void onProgress(int progress, int duration);
}

View File

@@ -4,18 +4,24 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.alibaba.android.arouter.utils.TextUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
@@ -61,7 +67,10 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
private Drawable[] mLikeAnimDrawables;//点赞帧动画
private int mLikeAnimIndex;
private String mTag;
private TextView tv_video_report;
private SeekBar seekbar;
private LinearLayout progressTextLayout;
private TextView progressTextView;
private TextView progressCount;
public VideoPlayWrapViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@@ -75,27 +84,51 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
@Override
public void init() {
mTag = this.toString();
seekbar = (SeekBar) findViewById(R.id.seekbar);
progressTextLayout = (LinearLayout) findViewById(R.id.progressTextLayout);
progressTextView = (TextView) findViewById(R.id.progress);
progressCount = (TextView) findViewById(R.id.progressCount);
mVideoContainer = (ViewGroup) findViewById(R.id.video_container);
mCover = (ImageView) findViewById(R.id.cover);
mAvatar = (ImageView) findViewById(R.id.avatar2);
mAvatar = (ImageView) findViewById(R.id.avatar);
mName = (TextView) findViewById(R.id.name);
mTitle = (TextView) findViewById(R.id.title);
mBtnLike = (ImageView) findViewById(R.id.btn_like);
mLikeNum = (TextView) findViewById(R.id.like_num);
mCommentNum = (TextView) findViewById(R.id.comment_num);
mShareNum = (TextView) findViewById(R.id.share_num);
mBtnFollow = (ImageView) findViewById(R.id.btn_follow2);
mBtnFollow = (ImageView) findViewById(R.id.btn_follow);
tv_video_report = (TextView) findViewById(R.id.tv_video_report);
// mFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_video_follow_1);
mFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_video_follow_1);
mUnFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_video_follow_0);
mAvatar.setOnClickListener(this);
mBtnFollow.setOnClickListener(this);
mBtnLike.setOnClickListener(this);
findViewById(R.id.btn_comment).setOnClickListener(this);
findViewById(R.id.btn_share).setOnClickListener(this);
findViewById(R.id.tv_video_report).setOnClickListener(this);
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
progressTextLayout.setVisibility(View.VISIBLE);
} else {
progressTextLayout.setVisibility(View.GONE);
}
progressTextView.setText(String.valueOf(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
/**
@@ -181,11 +214,9 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
}
if (mBtnLike != null) {
if (bean.getLike() == 1) {
if (mLikeAnimDrawables != null && mLikeAnimDrawables.length > 0) {
mBtnLike.setImageDrawable(mLikeAnimDrawables[mLikeAnimDrawables.length - 1]);
}
mBtnLike.setImageResource(R.mipmap.icon_video_zan_new02);
} else {
mBtnLike.setImageResource(R.mipmap.icon_video_zan_01);
mBtnLike.setImageResource(R.mipmap.icon_video_zan_new01);
}
}
if (mLikeNum != null) {
@@ -197,36 +228,36 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
if (mShareNum != null) {
mShareNum.setText(bean.getShareNum());
}
// if (u != null && mBtnFollow != null) {
// String toUid = u.getId();
// if (!TextUtils.isEmpty(toUid) && !toUid.equals(CommonAppConfig.getInstance().getUid())) {
// if (mBtnFollow.getVisibility() != View.VISIBLE) {
// mBtnFollow.setVisibility(View.VISIBLE);
// }
// if (bean.getAttent() == 1) {
// mBtnFollow.setImageDrawable(mFollowDrawable);
// } else {
// mBtnFollow.setImageDrawable(mUnFollowDrawable);
// }
// } else {
// if (mBtnFollow.getVisibility() == View.VISIBLE) {
// mBtnFollow.setVisibility(View.INVISIBLE);
// }
// }
// }
if (u != null && mBtnFollow != null) {
String toUid = u.getId();
if (!TextUtils.isEmpty(toUid) && !toUid.equals(CommonAppConfig.getInstance().getUid())) {
if (mBtnFollow.getVisibility() != View.VISIBLE) {
mBtnFollow.setVisibility(View.VISIBLE);
}
if (bean.getAttent() == 1) {
mBtnFollow.setImageDrawable(mFollowDrawable);
} else {
mBtnFollow.setImageDrawable(mUnFollowDrawable);
}
} else {
if (mBtnFollow.getVisibility() == View.VISIBLE) {
mBtnFollow.setVisibility(View.INVISIBLE);
}
}
}
if (!Constants.myUid.endsWith(bean.getUid())) {
// if (bean.getAttent() == 2) {
// mBtnFollow.setVisibility(View.VISIBLE);
// if (bean.getAttent() == 1) {
// mBtnFollow.setImageDrawable(mFollowDrawable);
// } else {
// mBtnFollow.setImageDrawable(mUnFollowDrawable);
// }
// } else {
// mBtnFollow.setVisibility(View.GONE);
// }
if (bean.getAttent() == 2) {
mBtnFollow.setVisibility(View.VISIBLE);
if (bean.getAttent() == 1) {
mBtnFollow.setImageDrawable(mFollowDrawable);
} else {
mBtnFollow.setImageDrawable(mUnFollowDrawable);
}
} else {
mBtnFollow.setVisibility(View.GONE);
}
} else {
// mBtnFollow.setVisibility(View.GONE);
mBtnFollow.setVisibility(View.GONE);
}
}
@@ -278,6 +309,17 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
return mVideoBean;
}
public void setProgress(int progresss) {
if (progressTextView != null) {
progressTextView.setText(String.valueOf(progresss));
}
}
public void setDuration(int duration) {
if (progressCount != null) {
progressCount.setText(String.valueOf(duration));
}
}
/**
* 获取到视频首帧回调
@@ -324,7 +366,7 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
return;
}
int i = v.getId();
if (i == R.id.btn_follow2) {
if (i == R.id.btn_follow) {
clickFollow();
} else if (i == R.id.btn_comment) {
clickComment();
@@ -334,12 +376,12 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
clickLike();
} else if (i == R.id.avatar2) {
clickAvatar();
} else if (i == R.id.tv_video_report) {
} /*else if (i == R.id.tv_video_report) {
if (mVideoBean == null) {
return;
}
LiveReportActivity.forward2(mContext, mVideoBean.getId());
}
}*/
}
@@ -376,15 +418,9 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
}
if (mBtnLike != null) {
if (like == 1) {
if (mLikeAnimtor == null) {
initLikeAnimtor();
}
mLikeAnimIndex = -1;
if (mLikeAnimtor != null) {
mLikeAnimtor.start();
}
mBtnLike.setImageResource(R.mipmap.icon_video_zan_new02);
} else {
mBtnLike.setImageResource(R.mipmap.icon_video_zan_01);
mBtnLike.setImageResource(R.mipmap.icon_video_zan_new01);
}
}
} else {
@@ -409,6 +445,11 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
@Override
public void callback(Integer attent) {
mVideoBean.setAttent(attent);
if (attent == 1) {
mBtnFollow.setImageDrawable(mFollowDrawable);
} else {
mBtnFollow.setImageDrawable(mUnFollowDrawable);
}
if (mCurPageShowed) {
if (mFollowAnimation == null) {
initFollowAnimation();

View File

@@ -1,9 +1,11 @@
package com.yunbao.video.views;
import android.content.Context;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
@@ -34,9 +36,7 @@ import java.util.List;
* 视频滑动
*/
public class VideoScrollViewHolder extends AbsViewHolder implements
VideoScrollAdapter.ActionListener, SwipeRefreshLayout.OnRefreshListener,
VideoPlayViewHolder.ActionListener, View.OnClickListener {
public class VideoScrollViewHolder extends AbsViewHolder implements VideoScrollAdapter.ActionListener, SwipeRefreshLayout.OnRefreshListener, VideoPlayViewHolder.ActionListener, View.OnClickListener {
private VideoPlayViewHolder mVideoPlayViewHolder;
private View mPlayView;
@@ -218,7 +218,7 @@ public class VideoScrollViewHolder extends AbsViewHolder implements
}
@Override
public void onPlayBegin() {
public void onPlayBegin(float duration) {
if (mVideoLoadingBar != null) {
mVideoLoadingBar.setLoading(false);
}
@@ -238,6 +238,14 @@ public class VideoScrollViewHolder extends AbsViewHolder implements
}
}
@Override
public void onProgress(int progress, int duration) {
if (mVideoPlayWrapViewHolder != null) {
mVideoPlayWrapViewHolder.setProgress(progress);
mVideoPlayWrapViewHolder.setDuration(duration);
}
}
/**
* 关注发生变化
*/

View File

@@ -10,7 +10,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/cover"
android:layout_width="match_parent"
@@ -18,23 +17,18 @@
android:layout_centerInParent="true"
android:scaleType="centerCrop" />
<RelativeLayout
android:layout_width="60dp"
android:layout_height="42dp"
android:layout_alignParentRight="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:layout_marginTop="48dp"
android:visibility="gone">
android:visibility="visible">
<TextView
android:id="@+id/tv_video_report"
<ImageView
android:id="@+id/back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/report"
android:textColor="@color/white"
android:textSize="15sp"
android:textStyle="bold" />
android:src="@mipmap/icon_video_back" />
</RelativeLayout>
<RelativeLayout
@@ -43,8 +37,8 @@
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="8dp"
android:layout_marginBottom="70dp"
android:visibility="gone">
android:layout_marginBottom="120dp"
android:visibility="visible">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/avatar"
@@ -57,8 +51,8 @@
<ImageView
android:id="@+id/btn_follow"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"
android:padding="3dp"
@@ -66,68 +60,73 @@
<ImageView
android:id="@+id/btn_like"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_below="@id/avatar"
android:layout_marginTop="20dp"
android:scaleX="1.16"
android:scaleY="1.16"
android:visibility="gone" />
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:padding="4dp"
android:visibility="visible" />
<TextView
android:id="@+id/like_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/btn_like"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:gravity="center"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="13sp"
android:translationY="-5dp"
android:visibility="gone" />
android:textSize="10sp"
android:visibility="visible" />
<ImageView
android:id="@+id/btn_comment"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_below="@id/btn_like"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:padding="4dp"
android:src="@mipmap/icon_video_comment"
android:visibility="gone" />
android:src="@mipmap/icon_video_comment_new"
android:visibility="visible" />
<TextView
android:id="@+id/comment_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/btn_comment"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:gravity="center"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="13sp"
android:translationY="-5dp" />
android:textSize="10sp" />
<ImageView
android:id="@+id/btn_share"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_below="@id/btn_comment"
android:layout_marginTop="18dp"
android:padding="2dp"
android:src="@mipmap/icon_video_share"
android:visibility="gone" />
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:padding="4dp"
android:src="@mipmap/icon_video_share_new"
android:visibility="visible" />
<TextView
android:id="@+id/share_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/btn_share"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:gravity="center"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="13sp"
android:translationY="-5dp"
android:visibility="gone" />
android:textSize="10sp"
android:visibility="visible" />
</RelativeLayout>
@@ -135,34 +134,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="18dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="120dp"
android:layout_marginBottom="30dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/avatar2"
android:layout_width="45dp"
android:layout_height="45dp"
android:scaleType="centerCrop"
app:riv_border_color="@color/white"
app:riv_border_width="1dp"
app:riv_oval="true" />
<ImageView
android:id="@+id/btn_follow2"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"
android:padding="3dp"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -191,4 +167,44 @@
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:id="@+id/progressTextLayout"
android:layout_width="match_parent"
android:layout_height="25dp"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="00:15"
android:textColor="@color/white" />
<TextView
android:id="@+id/progressCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="/00:45"
android:textColor="@color/gray1" />
</LinearLayout>
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:min="0" />
</LinearLayout>
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB