Docs

Help documentation

Vitamio video buffer handling

Generally speaking, when we play web videos, those videos are always buffered

due to the speed of network and other reasons. So we could increase the size of buffer and display
the buffer progress bar to improve user experience.

Key code

/**The variable needResume is used to test whether or not to resume playing video automatically.  */
    private boolean needResume;

    @Override
    public boolean onInfo(MediaPlayer arg0, int arg1, int arg2) {
        switch (arg1) {
        case MediaPlayer.MEDIA_INFO_BUFFERING_START:
            //Begin buffer, pause playing
            if (isPlaying()) {
                stopPlayer();
                needResume = true;
            }
            mLoadingView.setVisibility(View.VISIBLE);
            break;
        case MediaPlayer.MEDIA_INFO_BUFFERING_END:
            //The buffering is done, resume playing
            if (needResume)
                startPlayer();
            mLoadingView.setVisibility(View.GONE);
            break;
        case MediaPlayer.MEDIA_INFO_DOWNLOAD_RATE_CHANGED:
            //Display video download speed
            Logger.e("download rate:" + arg2);
            break;
        }
        return true;
    }

 

Usage 

Register the setOnInfoListener of MediaPlayer or VideoPlayer.

© 2011-2013 Xuan Yi Xia Inc. All rights reserved