From 0a402cdc9f7dccb483913f9b1be16c642d0f9cac Mon Sep 17 00:00:00 2001
From: Ghazi Triki <ghazi.triki@riadvice.tn>
Date: Wed, 13 Jun 2018 12:19:32 +0100
Subject: [PATCH] Correctly attach and detach streaming image with
 IOSVideoView.

---
 .../air/common/views/IOSVideoView.as            | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/clients/flash/air-client/src/org/bigbluebutton/air/common/views/IOSVideoView.as b/clients/flash/air-client/src/org/bigbluebutton/air/common/views/IOSVideoView.as
index afde87f67e..d712fbc248 100755
--- a/clients/flash/air-client/src/org/bigbluebutton/air/common/views/IOSVideoView.as
+++ b/clients/flash/air-client/src/org/bigbluebutton/air/common/views/IOSVideoView.as
@@ -17,16 +17,16 @@ package org.bigbluebutton.air.common.views
 		
 		protected var originalVideoHeight:Number;
 		
-		public function IOSVideoView():void {
-			_image = new Image();
-			addChild(_image);
-		}
-		
 		public function startStream(uri:String, streamName:String, imgWidth:Number, imgHeight:Number, meetingId:String, authToken:String, externalUserId:String):void {
 			
 			if(player) {
 				close();
 			}
+
+			_image = new Image();
+			if (numChildren == 0 ) {
+				addChild(_image);	
+			}
 			
 			this.originalVideoWidth = imgWidth;
 			this.originalVideoHeight = imgHeight;
@@ -41,7 +41,6 @@ package org.bigbluebutton.air.common.views
 			player.addEventListener(BBBRtmpPlayerEvent.DISCONNECTED, onDisconnected);
 			
 			player.play();
-			
 		}
 		
 		private function onConnecting(e:BBBRtmpPlayerEvent):void {
@@ -64,7 +63,11 @@ package org.bigbluebutton.air.common.views
 			player.removeEventListener(BBBRtmpPlayerEvent.NEW_IMAGE, onNewImage);
 			player.removeEventListener(BBBRtmpPlayerEvent.CONNECTION_FAILED, onConnectionFailed);
 			player.removeEventListener(BBBRtmpPlayerEvent.DISCONNECTED, onDisconnected);
-			_image = new Image();
+			if (getChildAt(0) == _image) {
+				removeChild(_image);
+			}
+			_image = null;
+			player = null;
 		}
 		
 		override protected function updateDisplayList(w:Number, h:Number):void {
-- 
GitLab