1919import com .red5pro .streaming .event .R5ConnectionEvent ;
2020import com .red5pro .streaming .event .R5ConnectionListener ;
2121import com .red5pro .streaming .source .R5Camera ;
22- import com .red5pro .streaming .view .R5VideoView ;
2322
2423import java .util .concurrent .ExecutionException ;
2524
@@ -33,7 +32,6 @@ public class SubscribeReconnectTest extends SubscribeTest {
3332
3433
3534 public boolean stopped = false ;
36- public int reconnectDelay = 5 ;
3735
3836 @ Override
3937 public View onCreateView (LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) {
@@ -55,30 +53,10 @@ public boolean onTouch(View v, MotionEvent event) {
5553 return view ;
5654 }
5755
58- protected void reconnect () {
59- Subscribe ();
60- SetupListener ();
61- }
62-
63- protected void delayReconnect (int delay ) {
64-
65- final SubscribeReconnectTest subscribeTest = this ;
66- Handler h = new Handler (Looper .getMainLooper ());
67- h .postDelayed (new Runnable () {
68- @ Override
69- public void run () {
70- subscribeTest .reconnect ();
71- }
72- }, delay );
73-
74- }
7556
7657 public void SetupListener (){
7758
78- final SubscribeReconnectTest subscribeTest = this ;
7959 final R5ConnectionListener additionalListener = this ;
80- final R5Stream subscriber = this .subscribe ;
81- final R5VideoView view = this .display ;
8260
8361 subscribe .setListener (new R5ConnectionListener () {
8462 @ Override
@@ -89,36 +67,19 @@ public void onConnectionEvent(R5ConnectionEvent r5ConnectionEvent) {
8967
9068 if (r5ConnectionEvent == R5ConnectionEvent .CLOSE && !SubscribeReconnectTest .this .stopped ) {
9169
70+
9271 Handler h = new Handler (Looper .getMainLooper ());
9372 h .postDelayed (new Runnable () {
9473 @ Override
9574 public void run () {
9675
9776 if (!stopped ) {
98- reconnectDelay = 5 ;
99- subscribeTest . reconnect ();
77+ Subscribe () ;
78+ SetupListener ();
10079 }
10180
10281 }
103- }, reconnectDelay );
104-
105- }
106- else if (r5ConnectionEvent == R5ConnectionEvent .NET_STATUS && r5ConnectionEvent .message .equals ("NetStream.Play.UnpublishNotify" )) {
107-
108- reconnectDelay = 1000 ;
109- Handler h = new Handler (Looper .getMainLooper ());
110-
111- h .postDelayed (new Runnable () {
112- @ Override
113- public void run () {
114-
115- subscriber .setListener (null );
116- subscriber .stop ();
117- view .attachStream (null );
118- subscribeTest .delayReconnect (reconnectDelay );
119-
120- }
121- }, reconnectDelay );
82+ }, 5 );
12283
12384 }
12485 }
0 commit comments