我们怎样才能播放/缓冲区只在Android上的视频几分钟? [英] How can we play/buffer only few minutes of a video in Android?

查看:487
本文介绍了我们怎样才能播放/缓冲区只在Android上的视频几分钟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打第2分钟的视频中。使用onBufferingUpdate()我得到缓冲的百分比。而是由prepared的时间称为我得到缓冲%为40.这是一个视频的超过2分钟。 (考虑到我有30分钟的视频)

I need to play first 2 mins of a video. Using onBufferingUpdate() i get the percentage that is buffered. But by the time onPrepared is called i get buffered % as 40. Which is more than 2 mins of a video. (Considering i have a video of 30 mins)

有什么办法,我可以播放/只有2分钟的缓冲视频?

Is there any way i can play/buffer video for only 2 mins ?

感谢。

推荐答案

缓冲区大小是pre-套入固件。所有你能做的就是保持对缓冲区多少填满标签,甚至认为只是一个百分比的基础。
大小设置在框架/基/媒体/ libstagefright /有/ NuCachedSource2.h

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

检查出$此 bug报告 C $ c.google.com。

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



修改
您可以通过使用获得的视频当前位置 mVideoView.getCurrentPosition(); 这将返回以毫秒为单位的当前位置,现在你将不得不使用一个 AsynTask


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;
    }

您可以启动的AsyncTask 使用新myAsync()执行(); 语句

这篇关于我们怎样才能播放/缓冲区只在Android上的视频几分钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆