Android Video Streaming using Video View (video vi

2019-02-27 15:56发布

I have managed to stream video from internet using Video View

  Uri uri=Uri.parse(videoFileList[0]);
    VideoView vv=(VideoView) this.findViewById(R.id.vv);

    vv.setVisibility(1);
    vv.bringToFront();
    vv.setVideoURI(uri);        
    vv.setMediaController(new MediaController(this));
    vv.requestFocus();

But the video page displays as blank at first. Only if I click on the blank space the video view appeares.

Can any body give a solution to display it automatically?

1条回答
Fickle 薄情
2楼-- · 2019-02-27 16:43

Try this. It worked for me.

void playvideo(String url) 
{
    String  link=url;
    Log.e("url",link);
    view1 = (VideoView) findViewById(R.id.myVideoView); 
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    MediaController mc = new MediaController(this); 
    mc.setMediaPlayer(view1); 
    view1.setMediaController(mc); 
    view1.setVideoURI(Uri.parse(link)); 
    view1.requestFocus(); 
    view1.start();
}
查看更多
登录 后发表回答