@@ -43,7 +43,6 @@ package com.videojs.providers{
4343 private var _loadStarted : Boolean = false ;
4444 private var _loadCompleted : Boolean = false ;
4545 private var _loadErrored : Boolean = false ;
46- private var _pauseOnStart : Boolean = false ;
4746 private var _pausePending : Boolean = false ;
4847 private var _onmetadadataFired : Boolean = false ;
4948
@@ -277,27 +276,28 @@ package com.videojs.providers{
277276 _loadErrored = false ;
278277 _loadStarted = false ;
279278 _loadCompleted = false ;
280- if (_model . preload) {
279+ if (_model . preload == "auto" ) {
281280 initNetConnection();
282281 }
283282 }
284283
285- public function load ():void {
286- _pauseOnStart = true ;
287- _playbackStarted = false ;
288- initNetConnection();
284+ public function load ():void {
285+ if (! _loadStarted ){
286+ _playbackStarted = false ;
287+ initNetConnection();
288+ }
289289 }
290290
291291 public function play ():void {
292292 // if this is a fresh playback request
293293 if (! _loadStarted ){
294- _pauseOnStart = false ;
295- _playbackStarted = false ;
296294 _metadata = {};
297- initNetConnection();
298- }
299- // if the asset is already loading
300- else {
295+ _model . addEventListener (VideoPlaybackEvent. ON_STREAM_READY , function (): void {
296+ play ();
297+ });
298+ load ();
299+ } else {
300+ // if the asset is already loading
301301 if (_hasEnded ) {
302302 _hasEnded = false ;
303303 _ns . seek (0 );
@@ -397,6 +397,8 @@ package com.videojs.providers{
397397 public function die ():void {
398398 if (_videoReference )
399399 {
400+ // Clears the image currently displayed in the Video object.
401+ _videoReference . clear ();
400402 _videoReference . attachNetStream (null );
401403 }
402404
@@ -487,7 +489,6 @@ package com.videojs.providers{
487489 if (_src . path === null ) {
488490 _pausePending = true ;
489491 }
490-
491492 _model . broadcastEvent(new VideoPlaybackEvent(VideoPlaybackEvent. ON_STREAM_READY , {ns: _ns }));
492493 }
493494
@@ -551,7 +552,7 @@ package com.videojs.providers{
551552 _throughputTimer . reset ();
552553 _throughputTimer . start ();
553554
554- if (! _pauseOnStart || _model . autoplay){
555+ if (_model . autoplay){
555556 _model . broadcastEventExternally(ExternalEventName. ON_RESUME );
556557 _model . broadcastEvent(new VideoPlaybackEvent(VideoPlaybackEvent. ON_STREAM_START , {info : e. info }));
557558 }
@@ -651,10 +652,6 @@ package com.videojs.providers{
651652 }
652653
653654 public function onMetaData (pMetaData :Object ):void {
654- if (_onmetadadataFired ) {
655- return ;
656- }
657-
658655 _metadata = pMetaData;
659656 if (pMetaData. duration != undefined ){
660657 _isLive = false ;
@@ -666,10 +663,14 @@ package com.videojs.providers{
666663 _canSeekAhead = false ;
667664 }
668665 _model . broadcastEvent(new VideoPlaybackEvent(VideoPlaybackEvent. ON_META_DATA , {metadata : _metadata }));
669- _model . broadcastEventExternally(ExternalEventName. ON_METADATA , _metadata );
670- _model . broadcastEventExternally(ExternalEventName. ON_CAN_PLAY );
671666
672- _model . broadcastEventExternally(ExternalEventName. ON_BUFFER_FULL );
667+ // the first time metadata is encountered, trigger loadedmetadata, canplay, and loadeddata
668+ if (! _onmetadadataFired ) {
669+ _model . broadcastEventExternally(ExternalEventName. ON_METADATA , _metadata );
670+ _model . broadcastEventExternally(ExternalEventName. ON_CAN_PLAY );
671+ _model . broadcastEventExternally(ExternalEventName. ON_BUFFER_FULL );
672+ }
673+
673674 _onmetadadataFired = true ;
674675 }
675676
0 commit comments