Making video load faster in videoview

三世轮回 提交于 2019-12-10 16:19:05

问题


I play a video in a videoview from an URL...everything works fine and even the video plays

But the only problem is that the video takes almost 10 seconds to start playing which might be kind of annoying to the user

I have tried different URLs and its the same, the videos are 360p and 6sec long

Is it the default media player that is slow?

I have the stack overflow but could not find a suitable answer and ever searched for various 3 rd party videos libraries but could not find one

Even tried google's exoplayer library but the documentation is not that good in my view

Is there any solution how to overcome this problem?

my code

    public class MainActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            String videeourl = "http://techslides.com/demos/sample-videos/small.3gp";

            VideoView videoView = (FastVideoView)findViewById(R.id.video);
            videoView.setMediaController(new MediaController(this));
            videoView.setVideoPath(videeourl); 

            videoView.start();
        }
    }

回答1:


Consider using Exoplayer. You can find the open source project here: https://github.com/google/ExoPlayer

It uses Dynamic Adaptive Streaming over HTTP (DASH),breaks long content into HTTP segments.




回答2:


You can follow this tutorial step-by-step to integrate ExoPlayer (ExoPlayer is the video player running in the Android YouTube app.) to your app, it's not that complicated as you thought.
https://codelabs.developers.google.com/codelabs/exoplayer-intro/index.html#0
By the way, there are a lot of good assignments in Google CodeLabs, you should check it out.



来源:https://stackoverflow.com/questions/35812914/making-video-load-faster-in-videoview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!