0

I have downloaded a video from VideoView. Video works fine, but not displayed on the screen.

Other question is, if I use .3gp videos then it works fine , but if I use .mp4 vidoes then it slows down.

Below is my code :

public class MyActivity extends Activity implements View.OnClickListener {
    /**
     * Called when the activity is first created.
     */
    public Button btn;
    public VideoView vv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn = (Button) findViewById(R.id.button);
        btn.setOnClickListener(this);
        vv = (VideoView) findViewById(R.id.videoView);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.button:
                vv.setVideoURI(Uri.parse("http://m.ochepyatki.ru/video.php?vkey=6991aa4&f=21395228200"));
                vv.setMediaController(new MediaController(this));
                vv.requestFocus(0);
                vv.start();
                break;
        }
    }
}
Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69
IP696
  • 181
  • 1
  • 2
  • 11

1 Answers1

0

1) replace vv.setMediaController(new MediaController(this)); with following code:

MediaController mediaCtrl = new MediaController(this);
mediaCtrl.setMediaPlayer(vv);
vv.setMediaController(mediaCtrl);

2) replace vv.start() with following code:

vv.setOnPreparedListener(new OnPreparedListener()
{
    public void onPrepared(MediaPlayer mp)
    {
        mp.start();
    }
}); 
brbabu
  • 340
  • 2
  • 15