3

I am trying to play a mp4 videoin my simple android VideoView. Here is my code

VideoView videoView;
videoView = (VideoView) findViewById(R.id.videoViewa);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
//URI either from net
Uri video = Uri.parse("http://www.fieldandrurallife.tv/videos/Benltey%20Mulsanne.mp4");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();

my layout looks like

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

<VideoView
    android:id="@+id/videoViewa"
    android:layout_width="match_parent"
    android:layout_gravity="center"
    android:layout_height="match_parent" />


</RelativeLayout>

Manifest looks like

    android:targetSdkVersion="18" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

I am getting the following error when I trying to launch application

Couldn't open file on client side, trying server side
error (1, -1004)

Has anyone faced the same ?

Please help Thanks in advance

ramesh
  • 4,008
  • 13
  • 72
  • 117
  • 1
    FIXED !!! For someone having the same problem please note that Android will play only H.264 compressed video. The problem get solved once I tried with the above mentioned video – ramesh Dec 17 '13 at 07:26

1 Answers1

0

Your code seems good, I think the problem comes from the server side. I don't know how did you use your server. But try use your own server. Please setup an Apache web server to test your local video. The tutorial to set up Apache is here

If you don't want to use your own server, please use the online mp4 link here, this is the test file I was using.

The easiest way to test this link is using a web browser to open the link to check whether the file is accessible, just copy paste the URL to the browser.

Also you can test that link on your android side, if you already have the "adb". use the command:

adb shell am start -a android.intent.action.VIEW -d http://169.228.179.91/username/abc.mp4
Albert Chen
  • 1,331
  • 1
  • 12
  • 13