當我通過stage.stageVideos [0]實例化一個新的StageVideo insta時,一切都很好,但是當我離開我的視圖時,它將顯示它在舞臺上的視頻。所以當我轉到另一個視角時,它仍然在背景舞臺上顯示。我試着設置sv = null,刪除事件監聽器等等。 我創建它在MXML像實例化的StageVideoDisplay類:和視圖初始化我所說的play()方法:Flex Mobile 4.6 StageVideo不會從舞臺上移除
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仍然在舞臺上,甚至在其他視圖,並返回到何時該觀點發揮不同的流,同一個流是一種「燒」在上面。我無法想出擺脫它的辦法!提前致謝!
謝謝。不幸的是,這似乎沒有做任何事情。它似乎有助於視頻在離開視圖時不在背景中播放。然而,stageVideo仍然出現在舞臺上時,轉向另一種觀點。另外,當移動到相同的視圖,並試圖播放另一個視頻時,同一個視頻仍然處於暫停狀態或剛剛位於頂部的某個位置... – Michael
適用於網絡上的我,我從未嘗試過w /空氣。這是發生在設備和模擬器上嗎?看到更多的代碼或者你正在做什麼的簡單例子可能會有幫助。請記住,舞臺視頻位於您的應用下方,因此作爲最後一招,您可以隱藏它。 –
你好,是的,它在AIR 3.3(最新版本)和Android設備上。我基本上遵循了教程,並創建了一個StageVideoDisplay類,它具有一個play()方法,可以實現簡單的網絡連接和網絡流對象。之後,我只是檢查可用性,並使用視頻對象或stage.stageVideos [0]對象。當我點擊後退按鈕時,我嘗試將所有內容全部刪除並刪除監聽器,但這似乎並沒有做任何事情。在視圖初始化我調用在mxml <組件中實例化類的play()函數:StageVideoDisplay /> – Michael