how to play video from url

前端 未结 9 1881
别那么骄傲
别那么骄傲 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:45

    You can do it using FullscreenVideoView class. Its a small library project. It's video progress dialog is build in. it's gradle is :

    compile 'com.github.rtoshiro.fullscreenvideoview:fullscreenvideoview:1.1.0'
    

    your VideoView xml is like this

    
    

    In your activity , initialize it using this way:

        FullscreenVideoLayout videoLayout;
    
    videoLayout = (FullscreenVideoLayout) findViewById(R.id.videoview);
            videoLayout.setActivity(this);
    
            Uri videoUri = Uri.parse("YOUR_VIDEO_URL");
            try {
                videoLayout.setVideoURI(videoUri);
    
            } catch (IOException e) {
                e.printStackTrace();
            }
    

    That's it. Happy coding :)

    If want to know more then visit here

    Edit: gradle path has been updated. compile it now

    compile 'com.github.rtoshiro.fullscreenvideoview:fullscreenvideoview:1.1.2'
    

提交回复
热议问题