gpt4 book ai didi

java - 在回收站 View 中显示视频

转载 作者:行者123 更新时间:2023-12-02 03:17:57 28 4
gpt4 key购买 nike

我正在尝试显示从 firebase 下载并在回收器 View 中播放的视频。但由于某种原因,它无法播放,只会显示黑屏。来自 firebase 的视频下载 URL 是正确的,所以这不是问题。

这是 logcat 中显示的内容:

W/MediaPlayer: Couldn't open https://firebasestorage.googleapis.com/...
java.io.FileNotFoundException: No content provider: https://firebasestorage.googleapis.com/v0/b/creatives-4ebde.appspot.com/o/All_Uploads%2FDesign%2FVideos%2F1562657263842.mp4?alt=media&token=d08f8a8f-903f-4dd7-82c0-4b7bbc183567
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1663)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1493)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1410)
at android.media.MediaPlayer.attemptDataSource(MediaPlayer.java:1102)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1074)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1098)
at android.widget.VideoView.openVideo(VideoView.java:412)
at android.widget.VideoView.access$2200(VideoView.java:83)
at android.widget.VideoView$7.surfaceCreated(VideoView.java:694)
at android.view.SurfaceView.updateSurface(SurfaceView.java:725)
at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:151)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1088)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2743)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7595)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7319)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)

这是我的 Recycler View Adapter 类:

public class RecyclerViewAdapter2  extends RecyclerView.Adapter<RecyclerViewAdapter2.ViewHolder> {

Context context2;
List<ImageUploadInfo> MainImageUploadInfoList;


public RecyclerViewAdapter2(Context context, List<ImageUploadInfo> TempList) {

this.MainImageUploadInfoList = TempList;

this.context2 = context;
}

@Override
public RecyclerViewAdapter2.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.items2, parent, false);

ViewHolder viewHolder = new ViewHolder(view);

return viewHolder;
}

@Override
public int getItemCount() {

return MainImageUploadInfoList.size();
}

@Override
public void onBindViewHolder(RecyclerViewAdapter2.ViewHolder holder, int position) {
ImageUploadInfo UploadInfo = MainImageUploadInfoList.get(position);

holder.imageNameTextView.setText(UploadInfo.getImageName());

Uri uri = Uri.parse(UploadInfo.getImageURL());
Log.d("TAGGG" , ""+uri);
holder.videoView.setVideoPath(uri.toString());
}


class ViewHolder extends RecyclerView.ViewHolder {
public VideoView videoView;
public TextView imageNameTextView;
public SimpleExoPlayerView exoPlayerView;
public SimpleExoPlayer exoPlayer;


public ViewHolder(View itemView) {
super(itemView);

//videoView = (VideoView) itemView.findViewById(R.id.videoView2);
exoPlayerView = (SimpleExoPlayerView) itemView.findViewById(R.id.exo_player_view);
imageNameTextView = (TextView) itemView.findViewById(R.id.textView12);
}
}
}

我正在使用 VideoView 来播放视频。请帮助我。

最佳答案

使用

holder.videoView.setVideoURI(uri.toString());

而不是

holder.videoView.setVideoPath(uri.toString());

关于java - 在回收站 View 中显示视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56949530/

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