使用媒体控制器从Firebase传输视频流

时间:2018-07-09 14:59:45

标签: android firebase video-streaming android-videoview mediacontroller

public class MessageFragent extends Fragment {


    private VideoView videoView;
    private Uri videoUrl;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_message,container, false);


        videoView = v.findViewById(R.id.vviewVideo);
        videoUrl = Uri.parse("https://firebasestorage.googleapis.com/v0/b/login-app-3bb2f.appspot.com/o/%E0%AC%9A%E0%AC%89%E0%AC%A0%E0%AC%BF%20%E0%AC%B0%E0%AC%BE%E0%AC%A4%E0%AC%BF%20--%20new%20odia%20comedy%20video%20--%20odia%20talking%20Tom%20video%20--%20Hasi%20hasi%20gadi%20jebe%20--%20odia%20jokes--.mp4?alt=media&token=4f74b5f7-5cfd-4338-936f-7b518bb9bc55");
        videoView.setVideoURI(videoUrl);

        MediaController mediaController = new MediaController(getActivity());
        videoView.setMediaController(mediaController);
        mediaController.setAnchorView(videoView);

        return v;
    }

}

我的视频没有流,并且显示无法播放视频文件

1 个答案:

答案 0 :(得分:0)

调用此方法播放视频-

videoView.start();

如下所述-

videoView = v.findViewById(R.id.vviewVideo);
videoUrl = Uri.parse("https://firebasestorage.googleapis.com/v0/b/login-app-3bb2f.appspot.com/o/%E0%AC%9A%E0%AC%89%E0%AC%A0%E0%AC%BF%20%E0%AC%B0%E0%AC%BE%E0%AC%A4%E0%AC%BF%20--%20new%20odia%20comedy%20video%20--%20odia%20talking%20Tom%20video%20--%20Hasi%20hasi%20gadi%20jebe%20--%20odia%20jokes--.mp4?alt=media&token=4f74b5f7-5cfd-4338-936f-7b518bb9bc55");
videoView.setVideoURI(videoUrl);
videoView.start();