how to play video from url

priyanka picture priyanka · Apr 12, 2010 · Viewed 150.1k times · Source

I am beginner in android development and try to play video from link. But it's giving error "sorry,we can't play this video". I tried so many links but for all links its show same error.

My code is the following

public class VideoDemo extends Activity {

        private static final String path ="http://demo.digi-corp.com/S2LWebservice/Resources/SampleVideo.mp4";
 private VideoView video;
 private MediaController ctlr;
 @Override
 public void onCreate(Bundle icicle) {
            super.onCreate(icicle);
            getWindow().setFormat(PixelFormat.TRANSLUCENT);
            setContentView(R.layout.videoview);

            video = (VideoView) findViewById(R.id.video);
            video.setVideoPath(path);

            ctlr = new MediaController(this);
            ctlr.setMediaPlayer(video);
            video.setMediaController(ctlr);
            video.requestFocus();
     }
}

Logcat shows following error message:

04-12 15:04:54.245: ERROR/PlayerDriver(554): HandleErrorEvent: PVMFErrTimeout

Answer

Win Myo Htet picture Win Myo Htet · Apr 17, 2010

It has something to do with your link and content. Try the following two links:

    String path="http://www.ted.com/talks/download/video/8584/talk/761";
    String path1="http://commonsware.com/misc/test2.3gp";

    Uri uri=Uri.parse(path1);

    VideoView video=(VideoView)findViewById(R.id.VideoView01);
    video.setVideoURI(uri);
    video.start();

Start with "path1", it is a small light weight video stream and then try the "path", it is a higher resolution than "path1", a perfect high resolution for the mobile phone.