I am trying to play video from google drive using shareable link in video view but unable to play what is the solution for this?

前端 未结 1 1244
一整个雨季
一整个雨季 2021-01-26 06:58

this is my code

mVideoView = (VideoView) findViewById(R.id.videoview);

VideoView videoView = findViewById(R.id.videoview);
// videoPath=\"https://drive.google.c         


        
相关标签:
1条回答
  • 2021-01-26 07:07

    You have to edit the link. Use String functions to edit the text.

    • Replace open? with uc?authuser=0&.

    • Add &export=download at URL text ending.

    so videoPath= like below:

    https://drive.google.com/open?id=1dXndP-MjQL7USlP0EtaElx67mXujqCSX
    

    becomes:

    https://drive.google.com/uc?authuser=0&id=1dXndP-MjQL7USlP0EtaElx67mXujqCSX&export=download
    

    Example code:

    //# fix path
    videoPath = videoPath.replace("open?", "uc?authuser=0&");
    videoPath = videoPath + "&export=download";
    
    //# try to play
    Uri uri = Uri.parse(videoPath);
    videoView.setVideoURI(uri);
    
    MediaController mediaController = new MediaController(this);
    videoView.setMediaController(mediaController);
    mediaController.setAnchorView(videoView);
    
    0 讨论(0)
提交回复
热议问题