Skip to content Skip to sidebar Skip to footer

How To Play A Video File From Sd Card

I want to play a video file on android emulator that I have stored in sd card. This is my code.. public class AndroidVideoViewActivity extends Activity { private VideoView vid

Solution 1:

Please check this link

OR

Replace videoView.setVideoPath("mnt/sdcard/bmxskills.3gp");

with videoView.setVideoPath("/sdcard/bmxskills.3gp");

Solution 2:

Use below code for that.

main.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:text="@string/hello"/><LinearLayoutandroid:orientation="vertical"android:layout_width="fill_parent"android:layout_height="wrap_content"><VideoViewandroid:id="@+id/myvideoview"android:layout_width="fill_parent"android:layout_height="wrap_content"/></LinearLayout></LinearLayout>

MainActivity.java

publicclassMainActivityextendsActivity {

    StringSrcPath="/sdcard/Video/Android in Spaaaaaace!_low.mp4";

    /** Called when the activity is first created. */@OverridepublicvoidonCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        VideoViewmyVideoView= (VideoView)findViewById(R.id.myvideoview);
        myVideoView.setVideoPath(SrcPath);
        myVideoView.setMediaController(newMediaController(this));
        myVideoView.requestFocus();
        myVideoView.start();
    }
}

Solution 3:

You should not test running video on the emulator itself, if you have a device laying around, use that instead. The Android emulator is quite terrible when it coming to handling videos correctly, so you may get a lot of problems that wouldn't normally be there on any Android device.

Post a Comment for "How To Play A Video File From Sd Card"