Wednesday, 10 August 2011

How to Play mp4 Video in Android Using Remote URL ?

Add Below Code into your MainActivity.java file.

@Override
protected void onCreate(Bundle savedInstanceState)
     // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    try {
        setContentView(R.layout.videodisplay);
        String link="http://s1133.photobucket.com/albums/m590/Anniebabycupcakez/?action=view& current=1376992942447_242.mp4";
        VideoView videoView = (VideoView) findViewById(R.id.VideoView);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(videoView);
        Uri video = Uri.parse(link);
        videoView.setMediaController(mediaController);
        videoView.setVideoURI(video);
        videoView.start();
    } catch (Exception e) {
        // TODO: handle exception
        Toast.makeText(this, "Error connecting", Toast.LENGTH_SHORT).show();
    }
}

Enjoy :-)

Don’t forget to provide feedback or follow this blog, if you find this blog is useful.

4 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
    Replies
    1. Hello Chetan,

      Don't post that type of comment, if you have any problem then post here and if you have any problems from Gujarati People then it is your problem.

      Delete
  2. hi, how to play a youtube url(video) in a webview..?

    ReplyDelete