簡體   English   中英

NetStream:雙閾值緩沖,並在緩沖區之外查找

[英]NetStream: dual threshold buffering, and seeking beyond buffer

是有關雙閾值緩沖的有用文章。 它解釋說,你可以聽的NetStream.Buffer.FullNetStream.Buffer.Empty對事件NetStream和調整NetStream相應的緩沖時間,使可用帶寬的最佳利用,也得到了快速的視頻啟動時間。 我遇到了一個問題。 當我經過NetStream中視頻的緩沖部分時,緩沖區再次為空,但沒有得到NetStream.Buffer.Empty事件。 NetStream的緩沖時間仍然設置為我的擴展緩沖時間,因此我失去了快速啟動時間的優勢。 您如何實施此策略,以使其在這種情況下正常工作? 您如何得知緩沖區再次為空,或者您已尋找了可用緩沖區以外的地方?

編輯:我可能應該提到我正在使用緩沖區內搜索(智能搜索)。 我認為如果不是這樣的話,這將不是問題,因為在未啟用此功能的情況下,閃存會在每次搜索時刷新緩沖區。

對我來說,解決方案是僅重置每次搜索的緩沖時間。 您仍然會收到NetStream.Buffer.Full事件,如果您碰巧發現緩沖區已經大於最小緩沖區的位置,它將立即觸發,因此您的NetStream.Buffer.Full處理程序將立即設置緩沖時間回到您的擴展緩沖時間。 這是一個例子:

var videoStream:NetStream = new NetStream(nc);

videoStream.addEventListener(NetStatusEvent.NET_STATUS, function (event:NetStatusEvent):void {
    switch(event.info.code) {
        case "NetStream.Buffer.Full":
            // this will keep the buffer filling continuously while there is bandwidth
            videoStream.bufferTime = Settings.maxBuffer;
            State.buffering = false;
            break;
        case "NetStream.Buffer.Empty":
            // if we run out of buffer we'll reset the buffer time to the min
            videoStream.bufferTime = Settings.minBuffer;
            State.buffering = true;
            break;
    }
}

_view.addEventListener(SeekEvent.SEEK, function (event:SeekEvent):void {
    State.buffering = true;
    videoStream.bufferTime = Settings.minBuffer;
    videoStream.seek(event.seek * (_duration || 0));
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM