Created
June 16, 2014 07:10
-
-
Save shvyrev/eaf6c9c03d82e2877a41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by s.shvyrev on 23.05.2014. | |
*/ | |
package com.comdi.kraken.player.utils.environment_test { | |
import com.comdi.kraken.player.utils.environment_test.event.EnvironmentTestErrorEvent; | |
import flash.events.EventDispatcher; | |
import flash.events.IEventDispatcher; | |
import flash.events.TimerEvent; | |
import flash.net.NetStream; | |
import flash.utils.Timer; | |
import org.osmf.media.MediaPlayer; | |
public class NetStreamWatcher extends EventDispatcher { | |
private var _netStream:NetStream; | |
private var _traceLoader:TraceNetLoader; | |
private var _timer:Timer = new Timer(1000); | |
private var _minBitrate:int; | |
private var _player:MediaPlayer; | |
public function NetStreamWatcher(target:IEventDispatcher = null) { | |
_timer.addEventListener(TimerEvent.TIMER, handler_timer); | |
_timer.start(); | |
super(target); | |
} | |
private function handler_timer(event:TimerEvent):void { | |
if(!_netStream) | |
return; | |
if(_minBitrate < _netStream.info.maxBytesPerSecond){ | |
dispatchEvent(new EnvironmentTestErrorEvent(EnvironmentTestErrorEvent.BANDWIDTH_ERROR, "Low bit rate: " + _netStream.info.maxBytesPerSecond, true, false)); | |
} | |
} | |
public function get traceLoader():TraceNetLoader { | |
_traceLoader = null; | |
_traceLoader = new TraceNetLoader(); | |
_traceLoader.onNetStream = getNetStream; | |
return _traceLoader; | |
} | |
public function set netStream(value:NetStream):void { | |
_netStream = value; | |
} | |
private function getNetStream(value:NetStream):void { | |
log("getNetStream", value); | |
_netStream = value; | |
} | |
public function get minBitrate():int { | |
return _minBitrate; | |
} | |
public function set minBitrate(value:int):void { | |
_minBitrate = value; | |
} | |
public function set player(value:MediaPlayer):void { | |
_player = value; | |
} | |
} | |
} |
donotfeedaslender
commented
Jul 18, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment