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.

18 comments:

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

    ReplyDelete
  2. 07-23 16:05:16.765: E/On item click url(23046):
    07-23 16:05:16.820: I/VideoView(23046): start()
    07-23 16:05:16.828: D/VideoView(23046): onMeasure()
    07-23 16:05:16.828: I/VideoView(23046): Setting size: 240x282
    07-23 16:05:16.828: D/VideoView(23046): onMeasure()
    07-23 16:05:16.828: I/VideoView(23046): Setting size: 240x282
    07-23 16:05:16.890: I/MediaPlayer(23046): path is null
    07-23 16:05:16.890: D/MediaPlayer(23046): Couldn't open file on client side, trying server side
    07-23 16:05:16.906: E/MediaPlayer(23046): error (1, -2147483648)
    07-23 16:05:16.953: E/MediaPlayer(23046): Error (1,-2147483648)
    07-23 16:05:16.953: D/VideoView(23046): Error: 1,-2147483648
    07-23 16:05:16.953: D/VideoView(23046): onMeasure()
    07-23 16:05:16.953: I/VideoView(23046): Setting size: 240x282
    07-23 16:05:16.953: D/VideoView(23046): onMeasure()
    07-23 16:05:16.953: I/VideoView(23046): Setting size: 240x282


    This showing what can i do ?

    ReplyDelete
  3. video not playing, Error- can't play this video

    ReplyDelete
  4. The video is removed in the link!!! Try a different link and it'll work

    ReplyDelete
  5. how to start this video from specific point

    ReplyDelete
  6. you need API Key for play video in youtube link.use this http://www.itcuties.com/android/play-youtube-video/ for more information..

    ReplyDelete
  7. Getting Error as : MediaPlayer﹕ Couldn't open file on client side, trying server side

    ReplyDelete
  8. video not playing, Error- can't play this video

    ReplyDelete
  9. I find a professional yet easy to play mp4 on android
    athttp://www.avdshare.com/play-mp4-on-android

    ReplyDelete
  10. I am beginner for android... my code is working good when i placed video in raw folder... then i have tried to play a video from Mobile phone sdcard so how can i set my sdcard path ??? please help me guys..

    ReplyDelete
    Replies
    1. if you need answer please email me
      tabbasam.malik25@gmail.com

      Delete
  11. tnx man! how can i record this streaming video in my sd card?

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. I find a article that introduces how to solve can't play MP4 on Android
    https://www.idealshare.net/video-converter/play-mp4-on-android.html

    After have a test, it also helps to play MKV, FLV, MOV, WMV, AVI, AVCHD, MXF, WTV, RMVB, TS, etc on Andriod.

    ReplyDelete
  14. We are the best online Academic Writing Assistance around, and you will not have to worry about submitting an assignment that has been written in the wrong context.

    ReplyDelete
  15. boom beach diamond hack
    Boom Beach Hack 2018 Unlimited Gold, Wood, Stones, Iron and Diamonds Online Resources Generator

    ReplyDelete
  16. The system is cost effective in the way it utilizes hardware facilities. assignment expert

    ReplyDelete