首页 > 解决方案 > Firebase 视频到 videoview 不起作用

问题描述

我能够录制并能够从我的 android 应用程序将该视频上传到 firebase,但无法播放或流式传输(无论可能)到 videoview。我实际上是在尝试进入回收站视图,但由于尝试更简单的方法没有用。

我在 stackoverflow 中阅读了很多帖子,并尝试了几乎所有的帖子,但都没有奏效。所以发布了新问题。

我的代码如下:

 VideoView video;
//String video_url = "http://file2.video9.in/english/movie/2014/x-men-_days_of_future_past/X-Men-%20Days%20of%20Future%20Past%20Trailer%20-%20[Webmusic.IN].3gp";//this one works if i use it
String video_url = "https://firebasestorage.googleapis.com/longidcharacters-video.mp4?alt=media&token=xxxxx"; 
//but this link from firebase does not work, i usually fetch it from online
ProgressDialog pd;
Button playButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_video);

    video = (VideoView) findViewById(R.id.Videoview1);
    playButton=(Button) findViewById(R.id.playButton1);

    pd = new ProgressDialog(ShowVideoActivity.this);
    pd.setMessage("Buffering video please wait...");
    pd.show();

    Uri uri = Uri.parse(video_url);
    video.setVideoURI(uri);


    video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            //close the progress dialog when buffering is done
            pd.dismiss();
        }
    });
    playButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            video.start();
        }
    });

它说“无法播放此视频”。格式为mp4(从相机录制)。但是,如果我玩那个 3gp 的(现在已评论),它工作正常。我能做些什么?有没有什么播放器可以试试?我只是想流式传输或播放上传到 Firebase 存储的视频。

标签: androidfirebasefirebase-storageandroid-videoview

解决方案


推荐阅读