- Timestamp:
- 10/23/09 15:38:14 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fl5/src/com/longtailvideo/jwplayer/media/RTMPMediaProvider.as
r501 r523 45 45 } 46 46 47 47 48 /** Constructor; sets up the connection and display. **/ 48 49 public override function initializeMediaProvider(cfg:PlayerConfig):void { … … 68 69 /** Catch security errors. **/ 69 70 protected function errorHandler(evt:ErrorEvent):void { 70 stop(); 71 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_ERROR, {message: evt.text}); 71 error(evt.text); 72 72 } 73 73 … … 92 92 _item = itm; 93 93 _position = 0; 94 _config.mute == true ? setVolume(0) : setVolume(_config.volume); 94 setState(PlayerState.BUFFERING); 95 sendBufferEvent(0); 95 96 if (getConfigProperty('loadbalance') as Boolean == true) { 96 97 smil = item.file; 97 98 loader.load(new URLRequest(smil)); 98 99 } else { 99 media = video; 100 connection.connect(item.streamer); 100 finishLoad(); 101 101 } 102 102 } … … 108 108 item.streamer = xml.children()[0].children()[0].@base.toString(); 109 109 item.file = xml.children()[1].children()[0].@src.toString(); 110 media = video; 110 finishLoad(); 111 } 112 113 /** Finalizes the loading process **/ 114 private function finishLoad():void { 115 if (!media){ 116 media = video; 117 } 111 118 connection.connect(item.streamer); 112 } 113 119 _config.mute == true ? setVolume(0) : setVolume(_config.volume); 120 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_LOADED); 121 } 114 122 115 123 /** Get metadata information from netstream class. **/ … … 118 126 video.width = dat.width; 119 127 video.height = dat.height; 128 resize(_width, _height); 129 } 130 if (dat.duration && item.duration < 0) { 131 item.duration = dat.duration; 120 132 } 121 133 if (dat.type == 'complete') { 122 clearInterval(interval); 123 setState(PlayerState.IDLE); 124 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_COMPLETE); 134 complete(); 125 135 } else if (dat.type == 'close') { 126 136 stop(); … … 156 166 var bfr:Number = Math.round(stream.bufferLength / stream.bufferTime * 100); 157 167 if (bfr < 95 && position < Math.abs(item.duration - stream.bufferTime - 1)) { 158 //TODO: Swapped159 168 if (state == PlayerState.PLAYING && bfr < 20) { 160 169 stream.pause(); … … 163 172 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_META, {metadata: {bufferlength: _config.bufferlength}}); 164 173 } 165 sendBufferEvent(bfr);166 174 } else if (bfr > 95 && state == PlayerState.BUFFERING) { 167 super.play(); 168 stream.resume(); 175 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_BUFFER_FULL); 169 176 stream.bufferTime = _config.bufferlength * 4; 170 177 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_META, {metadata: {bufferlength: _config.bufferlength * 4}}); 171 178 } 172 if (position < item.duration) { 179 180 var bufferPercent:Number = Math.round((_position + stream.bufferLength) / item.duration * 100); 181 if (state == PlayerState.BUFFERING) { 182 // Totally accurate, but it looks strange 183 // sendBufferEvent(bufferPercent); 184 } else if (position < item.duration) { 173 185 if (state == PlayerState.PLAYING && position >= 0) { 186 // Totally accurate, but it looks strange 187 // sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_TIME, {position: position, duration: item.duration, bufferPercent:bufferPercent}); 174 188 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_TIME, {position: position, duration: item.duration}); 175 189 } 176 190 } else if (!isNaN(position) && item.duration > 0) { 177 stream.pause(); 178 clearInterval(interval); 179 if (started && item.duration == 0) { 180 stop(); 181 } 182 setState(PlayerState.IDLE); 183 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_COMPLETE); 191 complete(); 184 192 } 185 193 } … … 209 217 interval = setInterval(positionInterval, 100); 210 218 stream.play(getID(item.file)); 211 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_LOADED);212 _config.mute == true ? setVolume(0) : setVolume(_config.volume);213 setState(PlayerState.BUFFERING);214 sendBufferEvent(0);215 219 } 216 220 … … 246 250 } 247 251 } catch (err:Error) { 248 stop();249 252 var msg:String = evt.info.code; 250 253 if (evt.info['description']) { 251 254 msg = evt.info['description']; 252 255 } 253 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_ERROR, {message: msg});256 error(msg); 254 257 } 255 258 break; … … 260 263 unpublished = false; 261 264 } else { 262 stop(); 263 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_ERROR, {message: "Stream not found: " + item.file}); 265 error("Stream not found: " + item.file); 264 266 } 265 267 break; 266 268 case 'NetConnection.Connect.Failed': 267 stop(); 268 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_ERROR, {message: "Server not found: " + item.streamer}); 269 error("Server not found: " + item.streamer); 269 270 break; 270 271 case 'NetStream.Play.UnpublishNotify': … … 278 279 /** Destroy the stream. **/ 279 280 override public function stop():void { 280 if (stream ) {281 if (stream && stream.time) { 281 282 stream.close(); 282 283 }
Note: See TracChangeset
for help on using the changeset viewer.
