'java.net.ProtocalException while using certain URL in VideoView android

I have the below list of test video links which i am am trying to set it on my VideoView. The first two works fine but the third one shows java.net.ProtocalException and I have the same problem when i user the link from my local Spring Web Application Server. How to play such link in videoView?

The list of links

1. VIDEO_SOURCE = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/SubaruOutbackOnStreetAndDirt.mp4";                    
2. VIDEO_SOURCE = "https://media.geeksforgeeks.org/wp-content/uploads/20201217192146/Screenrecorder-2020-12-17-19-17-36-828.mp4?_=1";
3. VIDEO_SOURCE = "https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4";

VideoView Code

if( URLUtil.isValidUrl(VIDEO_SOURCE)){
    try{
        videoUri = getMedia(VIDEO_SOURCE);
        // Set up the media controller widget and attach it to the video view.
        MediaController controller = new MediaController(_CourseContents.this);
        // anchor view for the videoView
        controller.setAnchorView(mVideoView);
        // sets the media player to the videoView
        controller.setMediaPlayer(mVideoView);
        // sets the media controller to the videoView
        mVideoView.setMediaController(controller);
        mVideoView.setVideoURI(videoUri);
        try {
             HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
             HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
            } catch (Exception e) {
                  e.printStackTrace();
            }
            progressBar.setVisibility(View.GONE);
      }
      catch(Exception e){
           Toast.makeText(getApplicationContext(), "Cannot parse video source:" + e.getMessage(), Toast.LENGTH_LONG).show();
           finish();
      }}else {
        Toast.makeText(getApplicationContext(), "Invalid video source.", Toast.LENGTH_LONG).show();
         finish();
                }

The Error enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source