How can we play/buffer only few minutes of a video in Android?

谁说胖子不能爱 提交于 2019-12-06 09:47:19

The buffer size is pre-set into the firmware. All you can do is keep tabs on how much the buffer is filled, and even that is just on a percentage basis. The size is set in frameworks/base/media/libstagefright/include/NuCachedSource2.h

check out this bug report on code.google.com.


Edit: You can get current position of the video by usingmVideoView.getCurrentPosition(); which will return you the current position in milliseconds and now you will have to use a AsynTask

private class myAsync extends AsyncTask<Void, Integer, Void>
{
    @Override
    protected Void doInBackground(Void... params) {
        mVideoView.start();            
        do {            
            try {
                if(mVideoView.getCurrentPosition() == TimeUnit.MINUTES.toMillis(yourMinutes)){
                    mVideoView.stop();
                }
            } catch (Exception e) {
            }
        } while (mVideoView.getCurrentPosition() != mVideoView.getDuration());
        return null;
    }

You can start the AsyncTask by using new myAsync().execute(); statement.

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