Ticket #1601 (closed enhancement: fixed)
HLS: investigate using SEEK appendbytesaction instead of RESET
| Reported by: | jeroen | Owned by: | jeroen |
|---|---|---|---|
| Priority: | Normal | Milestone: | Plugins |
| Component: | flash | Keywords: | |
| Cc: | Forum thread: |
Description
Here's the code from Moses. Investigate if this improves stability:
// Adaptive.as
/** Start playing an new adaptive stream. **/
public function play(url:String,start:Number=0):void {
_buffer.play(url, start, _getter);
};
// Buffer.as
/** Create the buffer. **/
public function Buffer(adaptive:Adaptive, loader:Loader, video:Object):void {
_adaptive = adaptive;
_loader = loader;
_video = video;
_adaptive.addEventListener(AdaptiveEvent.MANIFEST,_manifestHandler);
_connection = new NetConnection();
_connection.connect(null);
_transform = new SoundTransform();
_transform.volume = 0.9;
_setState(AdaptiveStates.IDLE);
};
public function play(url:String, start:Number, _getter:Getter):void { // #MG
startPosition = start;
_stream = new NetStream(_connection);
_video.attachNetStream(_stream);
_stream.play(null);
_stream.soundTransform = _transform;
_stream.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
_stream.appendBytes(FLV.getHeader());
_getter.load(url);
};
public function pause():void {
_stream.pause();
clearInterval(_interval);
_setState(AdaptiveStates.PAUSED);
};
public function resume():void {
_setState(AdaptiveStates.BUFFERING);
_stream.resume();
clearInterval(_interval);
_interval = setInterval(_checkBuffer,100);
};
/** Start playing data in the buffer. **/
public function seek(position:Number):void {
if(_levels.length) {
var level:Level = (_levels[_level] as Level);
if(_adaptive.getType() == AdaptiveTypes.LIVE) {
position = level.duration - 20;
} else if (position > level.duration - 1) {
position = level.duration - 1;
}
_buffer = new Vector.<Tag>();
_start = 0;
_tag = 0;
_stream.inBufferSeek = true;
_stream.seek(0); // #MG value is arbitrary. this plus RESET_SEEK flushes the FIFO buffer.
_stream.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);
_next = level.indexOf(position);
_start = level.fragments[_next].start;
_setState(AdaptiveStates.BUFFERING);
clearInterval(_interval);
_interval = setInterval(_checkBuffer,100);
}
};
Change History
Note: See
TracTickets for help on using
tickets.

Added the main fix in this patch (using RESET_SEEK instead of RESET_BEGIN for seeks in netstream).