Changeset 805
- Timestamp:
- 01/20/10 20:04:00 (3 years ago)
- Location:
- trunk/fl5
- Files:
-
- 1 added
- 8 edited
-
player.swf (modified) (previous)
-
src/com/longtailvideo/jwplayer/media/VideoMediaProvider.as (modified) (8 diffs)
-
src/com/longtailvideo/jwplayer/model/PlayerConfig.as (modified) (2 diffs)
-
src/com/longtailvideo/jwplayer/model/PlaylistItem.as (modified) (2 diffs)
-
src/com/longtailvideo/jwplayer/model/PlaylistItemLevel.as (added)
-
src/com/longtailvideo/jwplayer/parsers/MediaParser.as (modified) (3 diffs)
-
src/com/longtailvideo/jwplayer/player/PlayerV4Emulation.as (modified) (3 diffs)
-
src/com/longtailvideo/jwplayer/player/PlayerVersion.as (modified) (1 diff)
-
src/com/longtailvideo/jwplayer/view/View.as (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fl5/src/com/longtailvideo/jwplayer/media/VideoMediaProvider.as
r797 r805 26 26 /** ID for the position interval. **/ 27 27 protected var _positionInterval:Number; 28 /** Load offset for bandwidth checking. **/29 protected var _loadTimer:Number;30 28 /** Whether the buffer has filled **/ 31 29 private var _bufferFull:Boolean; 32 30 /** Whether the enitre video has been buffered **/ 33 31 private var _bufferingComplete:Boolean; 32 /** Whether we have checked the bandwidth. **/ 33 private var _bandwidthChecked:Boolean; 34 /** Whether to switch on bandwidth detection **/ 35 private var _bandwidthSwitch:Boolean = true; 36 /** Bandwidth check interval **/ 37 private var _bandwidthTimeout:Number = 2000; 34 38 35 39 … … 50 54 _stream.bufferTime = config.bufferlength; 51 55 _stream.client = new NetClient(this); 56 _transformer = new SoundTransform(); 52 57 _video = new Video(320, 240); 53 58 _video.smoothing = config.smoothing; 54 59 _video.attachNetStream(_stream); 55 _transformer = new SoundTransform();56 60 } 57 61 … … 68 72 _bufferFull = false; 69 73 _bufferingComplete = false; 74 if (itm.levels.length > 0) { 75 itm.setLevel(itm.getLevel(config.bandwidth, config.width)); 76 _bandwidthChecked = false; 77 } else { 78 _bandwidthChecked = true; 79 } 80 70 81 if (!item || item.file != itm.file || _stream.bytesLoaded == 0) { 71 82 media = _video; … … 87 98 sendBufferEvent(0); 88 99 } 100 clearInterval(_positionInterval); 89 101 _positionInterval = setInterval(positionHandler, 200); 90 _loadTimer = setTimeout(loadTimerComplete, 3000);91 102 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_LOADED); 92 103 config.mute == true ? setVolume(0) : setVolume(config.volume); 93 104 } 94 95 96 /** timeout for checking the bitrate. **/97 protected function loadTimerComplete():void {98 var obj:Object = new Object();99 obj.bandwidth = Math.round(_stream.bytesLoaded / 1024 / 3 * 8);100 if (item.duration) {101 obj.bitrate = Math.round(_stream.bytesTotal / 1024 * 8 / item.duration);102 }103 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_META, {metadata: obj});104 }105 106 105 107 106 /** Get metadata information from netstream class. **/ … … 138 137 /** Interval for the position progress **/ 139 138 protected function positionHandler():void { 139 if (!_bandwidthChecked && _stream.bytesLoaded > 0) { 140 _bandwidthChecked = true; 141 setTimeout(checkBandwidth, _bandwidthTimeout, _stream.bytesLoaded); 142 } 143 140 144 var _streamTime:Number = Math.min(_stream.time, item.duration); 141 145 _position = Math.round(_streamTime * 10) / 10; 142 146 var bufferPercent:Number = _stream.bytesLoaded / _stream.bytesTotal * 100; 143 147 var bufferTime:Number = _stream.bufferTime < (item.duration - _streamTime) ? _stream.bufferTime : Math.floor(Math.abs(item.duration - _streamTime)); 144 var bufferFill:Number = bufferTime == 0 ? 100 : Math. ceil(_stream.bufferLength / bufferTime * 100);148 var bufferFill:Number = bufferTime == 0 ? 100 : Math.floor(_stream.bufferLength / bufferTime * 100); 145 149 146 150 … … 149 153 _stream.pause(); 150 154 setState(PlayerState.BUFFERING); 151 } else if (bufferFill > 95 && state == PlayerState.BUFFERING && _bufferFull == false ) {155 } else if (bufferFill > 95 && state == PlayerState.BUFFERING && _bufferFull == false && bufferTime > 0) { 152 156 _bufferFull = true; 153 157 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_BUFFER_FULL); … … 170 174 } 171 175 176 private function checkBandwidth(lastLoaded:Number):void { 177 var currentLoaded:Number = _stream.bytesLoaded; 178 var bandwidth:Number = ((currentLoaded - lastLoaded) / 1024) * 8 / (_bandwidthTimeout / 1000); 179 if (currentLoaded < _stream.bytesTotal) { 180 if (bandwidth > 0) { 181 config.bandwidth = bandwidth; 182 var obj:Object = {bandwidth:bandwidth}; 183 if (item.duration > 0) { 184 obj.bitrate = Math.round(_stream.bytesTotal / 1024 * 8 / item.duration); 185 } 186 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_META, {metadata: obj}); 187 } 188 if (_bandwidthSwitch) { 189 _bandwidthSwitch = false; 190 if (item.currentLevel != item.getLevel(config.bandwidth, config.width)) { 191 load(item); 192 return; 193 } 194 } 195 } 196 setTimeout(checkBandwidth, _bandwidthTimeout, currentLoaded); 197 } 172 198 173 199 /** Seek to a new position. **/ … … 212 238 _stream.seek(0); 213 239 } 214 _loadTimer = undefined;215 240 clearInterval(_positionInterval); 216 241 _positionInterval = undefined; -
trunk/fl5/src/com/longtailvideo/jwplayer/model/PlayerConfig.as
r730 r805 18 18 protected var _playlistfile:String = null; 19 19 20 protected var _autostart:Boolean = false; 20 protected var _autostart:Boolean = false; 21 protected var _bandwidth:Number = 1500; 21 22 protected var _bufferlength:Number = 5; 22 protected var _displaytitle:Boolean = true;23 protected var _displaytitle:Boolean = true; 23 24 protected var _fullscreen:Boolean = false; 24 25 protected var _item:Number = 0; 25 protected var _linktarget:String = "_blank";26 protected var _mute:Boolean = false;27 protected var _repeat:String = RepeatOptions.NONE;26 protected var _linktarget:String = "_blank"; 27 protected var _mute:Boolean = false; 28 protected var _repeat:String = RepeatOptions.NONE; 28 29 protected var _shuffle:Boolean = false; 29 protected var _smoothing:Boolean = true; 30 protected var _smoothing:Boolean = true; 31 30 32 //TODO: Move to ENUM class 31 protected var _stretching:String = "uniform";32 protected var _volume:Number = 90;33 protected var _stretching:String = "uniform"; 34 protected var _volume:Number = 90; 33 35 34 36 protected var _backcolor:Color = null; 35 37 protected var _frontcolor:Color = null; 36 38 protected var _lightcolor:Color = null; 37 protected var _screencolor:Color = null;39 protected var _screencolor:Color = null; 38 40 39 41 //TODO: Move to ENUM class 40 protected var _controlbar:String = "bottom";41 protected var _dock:Boolean = true;42 protected var _height:Number = 400;43 protected var _icons:Boolean = true;42 protected var _controlbar:String = "bottom"; 43 protected var _dock:Boolean = true; 44 protected var _height:Number = 400; 45 protected var _icons:Boolean = true; 44 46 protected var _logo:String = null; 45 47 protected var _playlist:String = "none"; 46 48 protected var _playlistsize:Number = 180; 47 49 protected var _skin:String = null; 48 protected var _width:Number = 280;50 protected var _width:Number = 280; 49 51 50 52 protected var _plugins:String = ""; //plugins initial string 51 53 protected var _pluginConfig:Object = {}; 52 54 53 protected var _playerready:String = "";55 protected var _playerready:String = ""; 54 56 protected var _debug:String = Logger.NONE; 55 57 … … 282 284 public function set autostart(x:Boolean):void { _autostart = x; } 283 285 286 /** Automatically start the player on load. @default false **/ 287 public function get bandwidth():Number { return _bandwidth; } 288 public function set bandwidth(x:Number):void { _bandwidth = x; } 289 284 290 /** 285 291 * Number of seconds of the file that has to be loaded before starting. Set this to a low value to enable instant-start and to a -
trunk/fl5/src/com/longtailvideo/jwplayer/model/PlaylistItem.as
r542 r805 11 11 public var description:String = ""; 12 12 public var duration:Number = -1; 13 public var file:String = "";14 13 public var image:String = ""; 15 14 public var link:String = ""; … … 21 20 public var provider:String = ""; 22 21 22 protected var _file:String = ""; 23 protected var _currentLevel:Number = -1; 24 protected var _levels:Array = []; 25 23 26 public function PlaylistItem(obj:Object = null) { 24 27 for (var itm:String in obj) { 25 28 if (this[itm] && typeof(this[itm]) == typeof(0)) { 26 29 this[itm] = Number(obj[itm]); 30 } else if (itm == "levels" && obj[itm] is Array) { 31 var levels:Array = obj[itm] as Array; 32 for each (var level:Object in levels) { 33 if (level['file'] && level['bitrate'] && level['width']) { 34 addLevel(new PlaylistItemLevel(level['file'], level['bitrate'], level['width'])); 35 } 36 } 27 37 } else { 28 38 this[itm] = obj[itm]; 29 39 } 40 } 41 } 42 43 /** File property is now a getter, to take levels into account **/ 44 public function get file():String { 45 if (_levels.length > 0 && _currentLevel > -1 && _currentLevel < _levels.length) { 46 return (_levels[_currentLevel] as PlaylistItemLevel).file; 47 } else { 48 return _file; 49 } 50 } 51 52 /** File setter. Note, if levels are defined, this will be ignored. **/ 53 public function set file(f:String):void { 54 _file = f; 55 } 56 57 /** The quality levels associated with this playlist item **/ 58 public function get levels():Array { 59 return _levels; 60 } 61 62 /** Insert an additional bitrate level, keeping the array sorted from highest to lowest. **/ 63 public function addLevel(newLevel:PlaylistItemLevel):void { 64 if (_currentLevel < 0) _currentLevel = 0; 65 for (var i:Number = 0; i < _levels.length; i++) { 66 var level:PlaylistItemLevel = _levels[i] as PlaylistItemLevel; 67 if (newLevel.bitrate > level.bitrate) { 68 _levels.splice(i, 0, newLevel); 69 return; 70 } else if (newLevel.bitrate == level.bitrate && newLevel.width > level.width) { 71 _levels.splice(i, 0, newLevel); 72 return; 73 } 74 } 75 76 _levels.push(newLevel); 77 } 78 79 public function get currentLevel():Number { 80 return _currentLevel; 81 } 82 83 public function getLevel(bitrate:Number, width:Number):Number { 84 for (var i:Number=0; i < _levels.length; i++) { 85 var level:PlaylistItemLevel = _levels[i] as PlaylistItemLevel; 86 if (bitrate >= level.bitrate && width >= level.width * 0.9) { 87 return i; 88 } 89 } 90 return _levels.length - 1; 91 } 92 93 /** Set this PlaylistItem's level to match the given bitrate and height. **/ 94 public function setLevel(newLevel:Number):void { 95 if (newLevel >= 0 && newLevel < _levels.length) { 96 _currentLevel = newLevel; 97 } else { 98 throw(new Error("Level index out of bounds")); 30 99 } 31 100 } -
trunk/fl5/src/com/longtailvideo/jwplayer/parsers/MediaParser.as
r540 r805 22 22 **/ 23 23 public static function parseGroup(obj:XML, itm:Object):Object { 24 var ytp:Boolean = false; 25 24 26 for each (var i:XML in obj.children()) { 25 27 if (i.namespace().prefix == MediaParser.PREFIX) { … … 37 39 if (i.children().length() > 0) { 38 40 itm = MediaParser.parseGroup(i, itm); 41 } 42 if (i.@width && i.@bitrate) { 43 if (!itm.levels) { 44 itm.levels = new Array(); 45 } 46 itm.levels.push({ 47 width:i.@width.toString(), 48 bitrate:i.@bitrate.toString(), 49 file:i.@url.toString() 50 }); 39 51 } 40 52 break; … … 56 68 case 'player': 57 69 if (i.@url.indexOf('youtube.com') > 0) { 58 var ytp:Boolean= true;70 ytp = true; 59 71 itm['file'] = i.@url.toString(); 60 72 } -
trunk/fl5/src/com/longtailvideo/jwplayer/player/PlayerV4Emulation.as
r773 r805 13 13 import com.longtailvideo.jwplayer.model.Model; 14 14 import com.longtailvideo.jwplayer.model.PlaylistItem; 15 import com.longtailvideo.jwplayer.model.PlaylistItemLevel; 15 16 import com.longtailvideo.jwplayer.plugins.IPlugin; 16 17 import com.longtailvideo.jwplayer.plugins.PluginConfig; … … 349 350 cfg['version'] = _player.version; 350 351 cfg['item'] = _player.playlist.currentIndex; 352 cfg['level'] = _player.playlist.currentItem.currentLevel; 351 353 352 354 return cfg; … … 386 388 for (var i:String in item) { 387 389 obj[i] = item[i]; 390 } 391 392 if (item.levels.length > 0) { 393 obj['levels'] = []; 394 for each (var level:PlaylistItemLevel in item.levels) { 395 obj['levels'].push({url:level.file, bitrate:level.bitrate, width:level.width}); 396 } 388 397 } 389 398 -
trunk/fl5/src/com/longtailvideo/jwplayer/player/PlayerVersion.as
r802 r805 3 3 4 4 public class PlayerVersion { 5 protected static var _version:String = "5.1.80 2";5 protected static var _version:String = "5.1.805"; 6 6 7 7 public static function get version():String { -
trunk/fl5/src/com/longtailvideo/jwplayer/view/View.as
r801 r805 355 355 _plugins[id] = plugDO; 356 356 _pluginsLayer.addChild(plugDO); 357 //_pluginsLayer[id] = plugDO;358 357 } 359 358 } catch (e:Error) {
Note: See TracChangeset
for help on using the changeset viewer.
