0

I wont to play a video in my application ... I write the code as below:

import android.os.Bundle;  
import android.app.Activity; 
import android.view.Menu; 
import android.widget.TextView;

public class MainActivity extends Activity {

    public TextView counter = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    setContentView(R.layout.welcomepage);
    videoView = (VideoView)findViewById(R.id.VideoView); 
    Log.e("ok","ok");
    videoView.setVideoPath("animationgif/vid.flv");
    videoView.start();  }
}

but it doesn't work !!! have anyone any solution plz !

Panup Pong
  • 1,871
  • 2
  • 22
  • 44
  • Please provide a bit more about "doesn't work" and what you've tried to fix it. – ChiefTwoPencils Aug 23 '13 at 20:31
  • Error: animationgif/vid.flv doesnot existe !!! –  Aug 23 '13 at 20:42
  • You're not pointing to a real path. Also Android doesn't support FLV. See this link for supported media formats http://developer.android.com/guide/appendix/media-formats.html – Nick Aug 24 '13 at 00:25

1 Answers1

0

In order to set a video from external storage (sdcard or phone):

videoView.setVideoPath(Environment.getExternalStorageDirectory()+"/folder/file.mp4");

To do it from the raw folder:

videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() +"/"+R.raw.video));

Android doesn't support flv. It supports mp4 and 3gp (mkv starting with Android 4.0). See this link for supported media formats http://developer.android.com/guide/appendix/media-formats.html.

Nick
  • 1,854
  • 1
  • 13
  • 16