FLVPlayback停止/播放

时间:2014-01-20 04:23:04

标签: actionscript-3

FLVPlayback组件和stop()play()方法存在问题。这是我的类的代码,videoPlayer是舞台上的FLVPlayback组件。该阵列以[videos / s1.flv,videos / s2.flv,videos / s3.flv]格式保存视频当我在第一个视频仍在播放时调用stopVideo()函数时,它停止并回到第1帧的视频(按预期工作),但是当我调用playVideo()方法时,它不再播放视频。它在我播放第二或第三视频时停止FLVPlayback时有效。我知道在第一个视频中没有调用READY事件,因为它在开始时被调用。我做错了什么?

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 个答案:

答案 0 :(得分:0)

您只想在第一次播放视频时在播放方法中指定视频名称。之后(即,在应用stop()之后)只需使用不带参数的play()方法