gpt4 book ai didi

android - 在 Recyclerview 中使用 videoview

转载 作者:行者123 更新时间:2023-12-05 07:49:55 24 4
gpt4 key购买 nike

我想将 videoview 插入到我的 recyclerview 中。我有 View 的 url,但是当我尝试这样做时,我在我的 recyclerview 中看到了 videoview 的黑色图形。我想看视频但不播放,只是停止了视频。我的适配器:

public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.VideoViewHolder> {
List<Video> call;
RecyclerViewAdapter(List<Video> call){
this.call = call;

}
@Override
public VideoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view_row,parent,false);
VideoViewHolder videoViewHolder = new VideoViewHolder(v);
return videoViewHolder;
}

@Override
public void onBindViewHolder(VideoViewHolder holder, int position) {
String video_url = call.get(position).getClipUrl();
Log.d("Recycler Adapter", "videourl " + video_url);
holder.videoView.setVideoURI(Uri.parse(video_url));
Log.d("Recycler Adapter", "title " + call.get(position).getTitle());
Log.d("Recycler Adapter", "video_like " + call.get(position).getScore());

holder.video_name.setText(call.get(position).getTitle());
holder.video_like.setText(String.valueOf(call.get(position).getScore()));
}

@Override
public int getItemCount() {
return call.size();
}

public class VideoViewHolder extends RecyclerView.ViewHolder {
CardView cardView;
VideoView videoView;
TextView video_name;
TextView video_like;
public VideoViewHolder(View itemView) {
super(itemView);
cardView = (CardView) itemView.findViewById(R.id.card_view);
videoView = (VideoView)itemView.findViewById(R.id.videoview);
video_name = (TextView) itemView.findViewById(R.id.Videoname_textView);
video_like = (TextView) itemView.findViewById(R.id.like_textview);
}
}
}

enter image description here

最佳答案

像这样使用 seek 将其放在特定的秒上:

videoView.seekTo(requiredTime);

requireTime 是图片将被看到的时间

关于android - 在 Recyclerview 中使用 videoview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36797972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com