how to play video from url

前端 未结 9 1860
别那么骄傲
别那么骄傲 2020-11-29 03:56

I am beginner in android development and try to play video from link. But it\'s giving error \"sorry,we can\'t play this video\". I tried so many links but for

9条回答
  •  [愿得一人]
    2020-11-29 04:31

    I also got stuck with this issue. I got correct response from server, but couldn`t play video. After long time I found a solution here. Maybe, in future this link will be invalid. So, here is my correct code

        Uri video = Uri.parse("Your link should be in this place "); 
        mVideoView.setVideoURI(video); 
    
       mVideoView.setZOrderOnTop(true); //Very important line, add it to Your code
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 
            @Override 
            public void onPrepared(MediaPlayer mediaPlayer) {
      // here write another part of code, which provides starting the video
      }}
    

提交回复
热议问题