3

I want to stream a video from vlc to android app.I tired number of times.I referred http://www.howtogeek.com/118075/how-to-stream-videos-and-music-over-the-network-using-vlc/ tutorial.And this is my Java(Android) code block

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    VideoView mVideoView = (VideoView) findViewById(R.id.videoView1);
    String vidAddress = "http://10.0.2.2:8082/makeing_massina.mp4";
    Uri vidUri = Uri.parse(vidAddress);
    mVideoView.setVideoURI(vidUri);
    mVideoView.start();
}

Every time i got 'Can't play this video' message.Please help me..

Tharanga
  • 377
  • 3
  • 8
  • 18

2 Answers2

0

Use Following Code...

String vidAddress = "http://10.0.2.2:8082/makeing_massina.mp4";
@Override
protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      VideoView mVideoView = (VideoView) findViewById(R.id.videoView1);
      mVideoView.setVideoURI(Uri.parse(vidAddress));
      mVideoView.start();
}

And In given code you are using standred class of android VideoView. If you want to use VLC-plugin, you need to use Native Developement Kit (NDK).

If you want to use VLC plugin, to set up VLC library see here and how to use, see here

Rohit
  • 2,646
  • 6
  • 27
  • 52
0

is the video located on your video server somewhere? if yes, please try the URI like this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    VideoView vidView = (VideoView)findViewById(R.id.myVideo);
    MediaController vidControl = new MediaController(this);
    vidControl.setAnchorView(vidView);
    vidView.setMediaController(vidControl);
    String vidAddress = "http://137.110.92.231/~albertchen/BBC.mp4";
    vidView.setVideoURI(vidUri);
    vidView.start();
}

Also you need to make sure your cell phone has the access to the server. You can easily test the URI by copy paste that in your browser. You don't need to specify the port of the server.

BTW, I have already setup an Apache server on my computer, and put a video in the root folder of user "albertchen". If you want to try Apache server, please have a look at here, if you want to use some internet resource, please try here.

Community
  • 1
  • 1
Albert Chen
  • 1,331
  • 1
  • 12
  • 13