当我用stage.stageVideos实例化一个新的StageVideo实例时,一切都很好,但当我离开显示视频的视图时,它仍然停留在舞台上。因此,当我转到另一个视图时,它仍然显示在后台的舞台上。我尝试设置sv = null,删除事件listeners...etc。我已经创建了一个在mxml中实例化的StageVideoDisplay类,如下所示:在视图初始化时,我调用了一个play()方法:
if ( _path )
{
//...
// Connections
_nc = new NetConnection();
_nc.connect(null);
_ns = new NetStream(_nc);
_ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
_ns.client = this;
// Screen
_video = new Video();
_video.smoothing = true;
// Video Events
// the StageVideoEvent.STAGE_VIDEO_STATE informs you whether
// StageVideo is available
stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY,
onStageVideoState);
// in case of fallback to Video, listen to the VideoEvent.RENDER_STATE
// event to handle resize properly and know about the acceleration mode running
_video.addEventListener(VideoEvent.RENDER_STATE, videoStateChange);
//...
}在视频舞台活动中:
if ( stageVideoInUse ) {
try {
_rc = new Rectangle(0,0,this.width,this.height);
_sv.viewPort = _rc;
} catch (e:Error) {}
} else {
try {
_video.width = this.width;
_video.height = this.height;
} catch (e:Error) {}
}和舞台视频可用性事件:
protected function toggleStageVideo(on:Boolean):void
{
// To choose StageVideo attach the NetStream to StageVideo
if (on)
{
stageVideoInUse = true;
if ( _sv == null )
{
try {
_sv = stage.stageVideos[0];
_sv.addEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange);
_sv.attachNetStream(_ns);
_sv.depth = 1;
} catch (e:Error) {}
}
if (classicVideoInUse)
{
// If you use StageVideo, remove from the display list the
// Video object to avoid covering the StageVideo object
// (which is always in the background)
stage.removeChild ( _video );
classicVideoInUse = false;
}
} else
{
// Otherwise attach it to a Video object
if (stageVideoInUse)
stageVideoInUse = false;
classicVideoInUse = true;
try {
_video.attachNetStream(_ns);
stage.addChildAt(_video, 0);
} catch (e:Error) {}
}
if ( !played )
{
played = true;
_ns.play(path);
}
} 在视图中发生的情况是,当我使用navigator.popView()时,stageVideo仍然留在舞台上,甚至在其他视图中也是如此,当返回到该视图播放不同的流时,相同的流在顶部被“烧录”。我想不出一个摆脱它的方法!提前感谢!
发布于 2012-09-03 00:50:46
在Flash Player 11中,Adobe向NetStream类添加了dispose()方法。
当您使用完Video或StageVideo对象时,这对于清除它很有用。
在运行时调用dispose()方法时,可能会出现异常,指示NetStream对象上没有名为dispose的属性。
这是因为Flash Builder未使用正确的SWF版本编译应用程序。要解决这个问题,只需将以下代码添加到您的编译器指令:
-swf-version=13
在新的Flash Builder 4.7中,我们希望不必指定SWF版本来使用新的Flash Player功能。
这似乎是最好的解决方案,但如果您不能使用Flash 11 (或最新的Adobe AIR),其他一些解决方法将是:
stage
viewPort设置为在应用程序下方显示width=0和height=0
DisplayObject)发布于 2012-09-03 02:06:06
好的,问题实际上是,尽管它看起来像是在使用舞台视频,因为我在状态中得到了“加速”的消息,它实际上是视频渲染,甚至运行,经典视频实际上正在使用中。我唯一需要做的就是将stage.removeChild( _video )添加到类中的close()事件中!
https://stackoverflow.com/questions/12237184
复制相似问题