Changeset 1240
- Timestamp:
- 08/26/10 11:42:54 (3 years ago)
- Files:
-
- 4 edited
-
testing/settings.js (modified) (2 diffs)
-
trunk/fl5/player.swf (modified) (previous)
-
trunk/fl5/src/com/longtailvideo/jwplayer/media/RTMPMediaProvider.as (modified) (17 diffs)
-
trunk/fl5/src/com/longtailvideo/jwplayer/player/PlayerVersion.as (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
testing/settings.js
r1236 r1240 147 147 }, 148 148 'RTMP live stream (not always on)': { 149 file:' isight',149 file:'tuxcast', 150 150 streamer:'rtmp://fml.12E5.edgecastcdn.net/2012E5/', 151 151 'rtmp.subscribe':true, … … 154 154 }, 155 155 'RTMP live dvr stream (not always on)': { 156 file:' isight',156 file:'tuxcast', 157 157 'rtmp.dvr':true, 158 'rtmp.subscribe':true,159 158 streamer:'rtmp://fml.12E5.edgecastcdn.net/3012E5/', 160 159 height:240, -
trunk/fl5/src/com/longtailvideo/jwplayer/media/RTMPMediaProvider.as
r1236 r1240 67 67 /** Whether or not the buffer is full **/ 68 68 private var _bufferFull:Boolean = false; 69 /** Duration of the DVR stream (grows with a timer). **/ 70 private var _dvrDuration:Number = 0; 71 /** Total duration of the DVR stream (set by configuration). **/ 72 private var _dvrTotalDuration:Number = 0; 73 /** If the item's duration should be set back to 0 on load. **/ 74 private var _dvrResetDuration:Boolean = false; 75 /** How long to wait between updates to DVR duration **/ 76 private var _dvrCheckDelay:Number = 1000; 77 /** Interval ID for growing the DVR duration. **/ 78 private var _dvrInterval:Number; 69 /** Duration of the DVR stream at the time the client connects. **/ 70 private var _dvrStartDuration:Number = 0; 71 /** Is the DVR stream currently recording? **/ 72 private var _dvrStartDate:Number = 0; 79 73 /** Whether we should pause the stream when we first connect to it **/ 80 74 private var _lockOnStream:Boolean = false; … … 134 128 /** Try pulling info from a DVRCast application. **/ 135 129 private function doDVRInfo(id:String):void { 136 _connections[_connection].call("DVRGetStreamInfo", new Responder(doDVRInfoCallback), id); 137 Logger.log("calling DVRGetStreamInfo for "+id); 130 _connections[_connection].call("DVRGetStreamInfo", new Responder(doDVRInfoCallback), id); 138 131 }; 139 132 … … 142 135 private function doDVRInfoCallback(info:Object):void { 143 136 if(info.code == "NetStream.DVRStreamInfo.Success") { 144 setStream(); 145 Logger.log(info.data.currLen,"DVRCast"); 137 if(info.data.currLen < 60) { 138 setTimeout(doDVRInfo,5000,getID(item.file)) 139 } else { 140 _dvrStartDuration = info.data.currLen - 10; 141 if(info.data.isRec) { 142 _dvrStartDate = new Date().valueOf(); 143 if(_dvrStartDuration > 60) { 144 _timeoffset = _dvrStartDuration - 60; 145 } 146 } 147 setStream(); 148 } 146 149 } else if (info.code == "NetStream.DVRStreamInfo.Retry") { 147 150 setTimeout(doDVRInfo,2000,getID(item.file)); 148 151 } 152 for (var itm:String in info.data) { 153 info[itm] = info.data[itm]; 154 } 155 delete info.data; 149 156 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_META, {metadata: info}); 150 157 }; … … 156 163 } 157 164 158 159 /** If there's a DVR stream, calcluate the position by incrementing it via a setInterval(). **/160 private function dvrPosition():void {161 _dvrDuration += Math.ceil(_dvrCheckDelay / 1000);162 if(_dvrTotalDuration > 0) {163 var bufferPct:Number = Math.min(100, Math.ceil(100 * _dvrDuration / _dvrTotalDuration));164 sendBufferEvent(bufferPct);165 } else {166 if (item.duration == 0) { _dvrResetDuration = true; }167 item.duration = _dvrDuration;168 }169 }170 165 171 166 /** Catch security errors. **/ … … 221 216 _position = 0; 222 217 _bufferFull = false; 223 _bandwidthSwitch = false; 224 _lockOnStream = false; 218 _bandwidthSwitch = false; 219 _lockOnStream = false; 225 220 _timeoffset = item.start; 226 221 if (item.levels.length > 0) { item.setLevel(item.getLevel(config.bandwidth, config.width)); } 227 228 if (_dvrResetDuration) { item.duration = 0; }229 _dvrTotalDuration = item.duration;230 _dvrDuration = 0;231 clearInterval(_dvrInterval);232 _dvrInterval = 0;233 222 234 223 clearInterval(_positionInterval); … … 329 318 if (_transitionLevel >= 0) { _transitionLevel = -1; } 330 319 } else { 331 if (dat.duration) { 332 if (isDVR) { 333 // Save the DVR duration differently, adding a small buffer. 334 _dvrDuration = dat.duration + 3; 335 } else if (duration <= 0) { 336 item.duration = dat.duration; 337 } 338 } 320 if (dat.duration) { 321 item.duration = dat.duration; 322 } 339 323 } 340 324 if (dat.type == 'complete') { … … 356 340 } 357 341 342 358 343 /** Pause playback. **/ 359 344 override public function pause():void { … … 362 347 return; 363 348 } 364 365 clearInterval(_positionInterval); 349 //clearInterval(_positionInterval); 366 350 super.pause(); 367 351 if (_stream) { … … 371 355 } 372 356 } 357 373 358 374 359 /** Resume playing. **/ … … 401 386 } 402 387 403 if ( state != PlayerState.PLAYING) {388 if (!getConfigProperty('dvr') && state != PlayerState.PLAYING) { 404 389 return; 405 390 } 406 407 391 if (pos < duration) { 408 392 _position = pos; 409 393 sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_TIME, {position: position, duration: duration}); 410 } else if (position > 0 && duration > 0 && (!isDVR || _dvrTotalDuration > 0)) {394 } else if (position > 0 && duration > 0) { 411 395 _stream.pause(); 412 396 clearInterval(_positionInterval); … … 431 415 /** Seek to a new position. **/ 432 416 override public function seek(pos:Number):void { 433 if (isDVR && pos > _dvrDuration) { pos = _dvrDuration; }434 417 _transitionLevel = -1; 435 418 _transitionPlanned = false; 419 if(getConfigProperty('dvr') && _dvrStartDate && pos > duration - 60) { 420 pos = duration - 60; 421 } 436 422 _timeoffset = pos; 437 423 clearInterval(_positionInterval); … … 449 435 play(); 450 436 } 451 452 if(isDVR) { 453 if(state != PlayerState.PLAYING) { 454 try { 455 _stream.play(getID(item.file),0,-1); 456 } catch(e:Error) { 457 error("Could not play DVR stream: " + e.message); 458 } 459 } 460 if(_timeoffset > 0) { 461 _stream.seek(_timeoffset); 462 } 463 if (!_dvrInterval) { _dvrInterval = setInterval(dvrPosition,1000); } 464 } else { 465 if (_currentFile != item.file) { 466 _currentFile = item.file; 467 try { 468 _stream.play(getID(item.file)); 469 } catch(e:Error) { 470 Logger.log("Error: " + e.message); 471 } 472 } 473 if (_timeoffset > 0 || state == PlayerState.IDLE) { 474 if (_stream) { 475 _stream.seek(_timeoffset); 476 } 477 } 478 if (_dynamic) { 479 _bandwidthInterval = setInterval(getBandwidth, 1000); 480 } 481 } 482 _isStreaming = true; 483 _positionInterval = setInterval(positionInterval, 100); 484 } 437 438 if (_currentFile != item.file) { 439 _currentFile = item.file; 440 try { 441 if(_dvrStartDate) { 442 _stream.play(getID(item.file),10); 443 } else { 444 _stream.play(getID(item.file)); 445 } 446 } catch(e:Error) { 447 Logger.log("Error: " + e.message); 448 } 449 } 450 if ((_timeoffset > 0 || state == PlayerState.IDLE) && _stream) { 451 _stream.seek(_timeoffset); 452 } 453 if (_dynamic) { 454 _bandwidthInterval = setInterval(getBandwidth, 1000); 455 } 456 _isStreaming = true; 457 _positionInterval = setInterval(positionInterval, 100); 458 } 459 485 460 486 461 /** Start the netstream object. **/ … … 527 502 checkDynamic(evt.info.data.version); 528 503 } 529 if (getConfigProperty('subscribe')) { 530 if(isDVR) { 531 _connections[_connection].call("DVRSubscribe", null, getID(item.file)); 532 setTimeout(doDVRInfo,2000,getID(item.file)); 533 } else { 534 _subscribeInterval = setInterval(doSubscribe, 2000, getID(item.file)); 535 } 536 } else { 504 if(getConfigProperty('dvr')) { 505 _connections[_connection].call("DVRSubscribe", null, getID(item.file)); 506 setTimeout(doDVRInfo,2000,getID(item.file)); 507 } else if (getConfigProperty('subscribe')) { 508 _subscribeInterval = setInterval(doSubscribe, 2000, getID(item.file)); 509 } else { 537 510 if (item.levels.length > 0) { 538 511 if (_dynamic || _bandwidthChecked) { … … 606 579 break; 607 580 case 'NetStream.Play.Stop': 608 if( isDVR) { stop(); }581 if(getConfigProperty('dvr')) { stop(); } 609 582 break; 610 583 … … 628 601 _position = 0; 629 602 _timeoffset = item ? item.start : -1; 603 _dvrStartDuration = _dvrStartDate = 0; 630 604 super.stop(); 631 605 if (item && item.hasOwnProperty('smil')) { … … 643 617 } 644 618 645 /** Get the streamlength returned from the connection. **/ 646 private function streamlengthHandler(len:Number):void { 647 if (isDVR && _dvrTotalDuration > 0) { 648 _dvrDuration = len; 649 } else if (!isDVR && len && duration <= 0) { 650 item.duration = len; 651 } 652 } 619 620 /** Get the streamlength returned from the connection. **/ 621 private function streamlengthHandler(len:Number):void { 622 item.duration = len; 623 } 624 653 625 654 626 /** Dynamically switch streams **/ … … 690 662 return (!(duration > 0) && _stream && _stream.bufferLength > 0); 691 663 } 692 693 protected function get isDVR():Boolean { 694 return Boolean(getConfigProperty('dvr')); 695 } 696 664 665 697 666 protected function get duration():Number { 698 if (isDVR) { 699 return _dvrTotalDuration > 0 ? _dvrTotalDuration : item.duration; 700 } else { 667 if(getConfigProperty('dvr')) { 668 var dur:Number = _dvrStartDuration; 669 if(_dvrStartDate) { 670 dur += (new Date().valueOf() - _dvrStartDate) / 1000; 671 } 672 return Math.round(dur); 673 } else { 701 674 return item.duration; 702 675 } -
trunk/fl5/src/com/longtailvideo/jwplayer/player/PlayerVersion.as
r1238 r1240 3 3 4 4 public class PlayerVersion { 5 protected static var _version:String = "5.3.12 38";5 protected static var _version:String = "5.3.1240"; 6 6 7 7 public static function get version():String {
Note: See TracChangeset
for help on using the changeset viewer.
