获取缓冲的数据exoplayer [英] get buffered data exoplayer

查看:528
本文介绍了获取缓冲的数据exoplayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对构建Android应用程序不是很有经验,我正在尝试使用ExoPlayer制作一个小型应用程序.所以希望你们能原谅我的无知.我本质上是在尝试查看是否有一种方法可以访问缓冲的文件.我四处搜寻,但似乎没有答案.我看到人们在谈论cacheDataSource,但是后来我想,是不是因为数据缓冲已经在缓存数据了?例如,当视频开始播放时,它开始缓冲.即使按下暂停,它仍会继续这样做.如果我正确理解这一点,则视频实际上是从缓冲数据中播放的.我认为这些数据必须存储在某个地方.在这种情况下是缓存数据吗?如果没有,那么什么是缓存数据?这有什么区别?最后,我如何才能真正访问到这是什么?我一直在尝试查看其存储位置和存储位置(意味着某种文件可能存储在其中),然后到达DefaultAllocator类,该类似乎有此行

I am not very experienced building Android apps and I am trying to make a small app using ExoPlayer. So hopefully you guys can pardon my ignorance. I am essentially trying to see if there is a way to get access to the buffered files. I searched around, but there doesn't seem to be an answer for this. I saw people talking about cacheDataSource, but then I thought, isn't the data already being cache by virtue of it buffering? For instance, when a video starts, it start buffering. I t continues to do so even if pause is pressed. If I am understanding this correctly, the video actually plays from the buffered data. I assume that this data must be stored somewhere. Is this cache data in this case? if not, then what is cache data? what is the difference here? and finally, how can I actually get access to whatever this is? I'v been trying to see where its being stored as and as what(meaning some kind of file may be), and I reached the DefaultAllocator class, which seems to have this line

availableAllocations[i] = new Allocation(initialAllocationBlock,allocationOffset);//is this it??

这在DefaultAllocator.java文件中.不确定即时通讯是否在正确的位置...

this is in the DefaultAllocator.java file. Not sure if im looking in the right place...

我无法弄清缓冲区是什么以及如何存储. YouTube存储.exo文件.通过打印getCacheDir(),我可以在data/data/myAppName/cache中看到一个缓存文件夹,但这似乎发出了一些java.io.fileAndSomeRandomChars.当播放器最小化或打开另一个应用程序时,缓冲区也将被删除.

I am not able to make sense of what the buffer even is and how its stored. Youtube stores .exo files. I can see a cache folder in data/data/myAppName/cache by printing the getCacheDir(), but that seems to be giving out some java.io.fileAndSomeRandomChars. The buffer also gets deleted when the player is minimized or another app is opened.

ExoPlayer是否也将文件存储为大块?

Does the ExoPlayer also store files in chunks?

任何对此的见解将非常有帮助!我被困在这几天了.超级傻瓜很感激!

Any insight on this would be seriously super helpful!. Iv been stuck on this for a few days now. Super duper appreciate it!

推荐答案

缓冲区不是文件,缓冲区存储在应用程序内存中,在此示例中,它们是

Buffers are not files, buffers are stored in application memory, and in this example they are instances of ByteBuffer class. ExoPlayer buffers are passed through instances of MediaCodecRenderer using processOutputBuffer() method.

缓冲区通常是字节数组或其他类型的数据,而ByteBuffer类在其周围添加了一些有用的方法,可使用标记等在缓冲区的最后访问位置跟踪缓冲区的大小.

Buffers are usually arrays of bytes or maybe some other kind of data, while ByteBuffer class adds some helpfull methods around it for tracking size of buffer ot its last accessed position using marker and so on.

我访问缓冲区的方式是扩展我正在使用的渲染器的实现,然后像这样覆盖processOutputBuffer():

The way how I access buffers is by extending the implementation of renderer that I am using and then override processOutputBuffer() like this:

public class CustomMediaCodecAudioRenderer extends MediaCodecAudioRenderer
{
     @Override
     protected boolean processOutputBuffer( long positionUs, long elapsedRealtimeUs, MediaCodec codec, ByteBuffer buffer, int bufferIndex, int bufferFlags, long bufferPresentationTimeUs, boolean shouldSkip ) throws ExoPlaybackException
     {

        boolean fullyProcessed;

        //Here you use the buffer
        doSomethingWithBuffer( buffer );


        //Here we allow renderer to do its normal stuff
        fullyProcessed = super.processOutputBuffer( positionUs,
            elapsedRealtimeUs,
            codec,
            buffer,
            bufferIndex,
            bufferFlags,
            bufferPresentationTimeUs,
            shouldSkip );





        return fullyProcessed;
    }

}

这篇关于获取缓冲的数据exoplayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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