1

I have used a VideoView on my main.xml (with a relative layout) and tried to play an mp4 video (via instantiating a MediaPlayer and ...), but there is an error which says: this video can't be played.

When I watch the logcat, I see that it says:

the Parent view is not a TextView

Would you please help me?

My main.xml is as follows:

<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"
tools:context=".Main">

<VideoView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/videoView1"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />
 </RelativeLayout>

and my Main.java is as follows:

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.MediaController;
import android.widget.VideoView;


public class Main extends Activity {

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

    VideoView vv = (VideoView) findViewById(R.id.videoView1);
    vv.setVideoPath("/storage/extSdCard/vid.mp4");
    vv.setMediaController(new MediaController(this));
    vv.start();
    vv.requestFocus();
}

}
  • You can most likely ignore the 'Parent view is not a textview' error (http://stackoverflow.com/questions/24005959/android-can-i-ignore-the-errors-parent-view-is-not-a-textview-and-senduse). For the video not playing this i most likely a video format issues - can you post the video type and also the logical when the video does not play – Mick Mar 27 '15 at 22:32

1 Answers1

0

you can analysis this tutorial: http://mrbool.com/how-to-play-video-formats-in-android-using-videoview/28299

altan yuksel
  • 173
  • 1
  • 6