Android – How to show video in android from google drive url

androidgoogle-drive-api

I want to show video in android application. I have searched on Google and found below code

VideoView videoView = (VideoView) findViewById(R.id.videoView);

String vidAddress = "https://docs.google.com/a/user.co.jp/file/d/something..private cookie/preview";

Uri videoUri = Uri.parse(vidAddress);

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

videoView.setVideoURI(videoUri); videoView.start();

I have placed the above code in onCreate method of activity.

When I run application It gives error "Sorry, this video cannot be played."

Log are displayed as below

07-15 13:58:13.110: V/MediaPlayer-JNI(19546): native_setup
07-15 13:58:13.110: V/MediaPlayer(19546): constructor
07-15 13:58:13.125: V/MediaPlayer(19546): setListener
07-15 13:58:13.125: I/MediaPlayer(19546): path is null
07-15 13:58:13.125: D/MediaPlayer(19546): Couldn't open file on client side, trying server side
07-15 13:58:13.140: V/MediaPlayer(19546): setVideoSurfaceTexture
07-15 13:58:13.140: V/MediaPlayer-JNI(19546): setAudioStreamType: 3
07-15 13:58:13.140: V/MediaPlayer(19546): MediaPlayer::setAudioStreamType
07-15 13:58:13.140: V/MediaPlayer(19546): setVideoSurfaceTexture
07-15 13:58:13.140: V/MediaPlayer(19546): prepareAsync
07-15 13:58:16.810: V/MediaPlayer(19546): message received msg=100, ext1=1, ext2=-2147483648
07-15 13:58:16.810: E/MediaPlayer(19546): error (1, -2147483648)
07-15 13:58:16.810: V/MediaPlayer(19546): callback application
07-15 13:58:16.810: V/MediaPlayer(19546): back from callback
07-15 13:58:16.815: E/MediaPlayer(19546): Error (1,-2147483648)
07-15 13:58:16.815: D/VideoView(19546): Error: 1,-2147483648

I am able to see the video on browser.

Uploaded video file type are mpg, mp4 and wmv

Please help if any one have solution.

Thanks

Edit : After some work I came to know that one reason is Android version 4.0.3. Above mentioned code is working for sample url like
http://download.itcuties.com/teaser/itcuties-teaser-480.mp4
only in 4.2.2.
Videos from Google docs url still not working. What should I do to play it on 4.0.3

Best Answer

The url that you parse to Uri is not compatible with VideoView because it just a web url for embed on Iframe in html.Please follow this here for solution.