0
votes

Problem with a FLVPlayback component and the stop() play() method. Here is the code of my class, videoPlayer is a FLVPlayback component on the stage. The array holds videos in the format [videos/s1.flv,videos/s2.flv,videos/s3.flv] When I call the stopVideo() function while the first video is still playing it stops and rewinds to frame 1 of the video (working as intended) but then when I call the playVideo() method it doesnt play the video again. It works when I stop the FLVPlayback while its playing the 2nd or 3rd video. I know the READY event isnt invoked at the 1st video because it was invoked at the beginning. What I'm doing wrong?

public class Intro extends MovieClip {
                    private var intros:XML;
                    private var currentVideo:uint = 0;
                    private var _data:XML;


 private var videos:Array;

                public function Intro(data:XML) {
                          _data = data;

                          videoPlayer.addEventListener(VideoEvent.COMPLETE, completeHandler);
                          videoPlayer.addEventListener(VideoEvent.READY, videoReady);
                          videoPlayer.opaqueBackground = 0x000000;
                          videoPlayer.autoRewind = true;
                }

                function completeHandler(evt:Event):void {
                          trace("video complete");
                          currentVideo++;


                          if (currentVideo < videos.length) {
                                    videoPlayer.source = videos[currentVideo];
                          } else {
                                    currentVideo = 0;
                          }
                }

                public function playVideo():void {
                          trace(currentVideo);
                          if (currentVideo == 0) {
                                    trace(videos[currentVideo]);
                                    videoPlayer.play(videos[currentVideo]);
                          } else {
                                    videoPlayer.source = videos[currentVideo];
                          }
                }

                public function prepareVideos(introVideos:XML):void {
                          intros = introVideos;
                          var list:XMLList = intros.entry;
                          var entry:XML;
                          var len:int = list.length();
                          videos = new Array();

                          for (var i:int = 0; i < len; i++) {
                                    entry = list[i];
                                    videos.push(entry);
                          }
                          dispatchEvent(new Event(Event.COMPLETE));
                }

                public function stopVideo():void {
                          if (videoPlayer.playing) {
                                    trace("video stopped");
                                    videoPlayer.stop();
                                    currentVideo = 0;
                          }
                }

                private function resetVideo(e:VideoEvent):void {
                          videoPlayer.seek(0);
                }

                private function videoReady(e:VideoEvent):void {
                          trace("video ready");
                          videoPlayer.play();
                }
      }
1

1 Answers

0
votes

you only want to specificy the video name in the play method when first playing the video. after that (ie, after applying a stop() )just use the play() method with no parameter