Search code examples
androidfirebasevideo-streamingandroid-videoviewmediacontroller

video streaming from firebase using media controller


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;
    }

}

my video is not streaming and is showing can't play the video file


Solution

  • Call this method to play the video -

    videoView.start();
    

    As done below -

    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();