Can't play mp4 video in my Android app

后端 未结 3 663
春和景丽
春和景丽 2021-02-04 21:21

I very want to play mp4 video in my android app. I even wrote a bit of code for it:

String sourceUrl = \"http://tvstream.cn.ru/storage/1kanal/20120530/\"
                


        
3条回答
  •  难免孤独
    2021-02-04 21:53

    Try this

    File clip=new File(Environment.getExternalStorageDirectory(),
                           "test.mp4");
    
        if (clip.exists()) {
          video=(VideoView)findViewById(R.id.video);
          video.setVideoPath(clip.getAbsolutePath());
    
          ctlr=new MediaController(this);
          ctlr.setMediaPlayer(video);
          video.setMediaController(ctlr);
          video.requestFocus();
          video.start();
    

提交回复
热议问题