Skip to content

Commit

Permalink
Merge pull request #98 from red5pro/revert-96-develop
Browse files Browse the repository at this point in the history
Revert "Develop"
  • Loading branch information
Jessica Palmer authored Nov 29, 2017
2 parents dc02c76 + fb455f5 commit 554a240
Showing 1 changed file with 4 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.red5pro.streaming.event.R5ConnectionEvent;
import com.red5pro.streaming.event.R5ConnectionListener;
import com.red5pro.streaming.source.R5Camera;
import com.red5pro.streaming.view.R5VideoView;

import java.util.concurrent.ExecutionException;

Expand All @@ -33,7 +32,6 @@ public class SubscribeReconnectTest extends SubscribeTest {


public boolean stopped = false;
public int reconnectDelay = 5;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand All @@ -55,30 +53,10 @@ public boolean onTouch(View v, MotionEvent event) {
return view;
}

protected void reconnect () {
Subscribe();
SetupListener();
}

protected void delayReconnect (int delay) {

final SubscribeReconnectTest subscribeTest = this;
Handler h = new Handler(Looper.getMainLooper());
h.postDelayed(new Runnable() {
@Override
public void run() {
subscribeTest.reconnect();
}
}, delay);

}

public void SetupListener(){

final SubscribeReconnectTest subscribeTest = this;
final R5ConnectionListener additionalListener = this;
final R5Stream subscriber = this.subscribe;
final R5VideoView view = this.display;

subscribe.setListener(new R5ConnectionListener() {
@Override
Expand All @@ -89,36 +67,19 @@ public void onConnectionEvent(R5ConnectionEvent r5ConnectionEvent) {

if (r5ConnectionEvent == R5ConnectionEvent.CLOSE && !SubscribeReconnectTest.this.stopped) {


Handler h = new Handler(Looper.getMainLooper());
h.postDelayed(new Runnable() {
@Override
public void run() {

if(!stopped) {
reconnectDelay = 5;
subscribeTest.reconnect();
Subscribe();
SetupListener();
}

}
}, reconnectDelay);

}
else if (r5ConnectionEvent == R5ConnectionEvent.NET_STATUS && r5ConnectionEvent.message.equals("NetStream.Play.UnpublishNotify")) {

reconnectDelay = 1000;
Handler h = new Handler(Looper.getMainLooper());

h.postDelayed(new Runnable() {
@Override
public void run() {

subscriber.setListener(null);
subscriber.stop();
view.attachStream(null);
subscribeTest.delayReconnect(reconnectDelay);

}
}, reconnectDelay);
}, 5);

}
}
Expand Down

0 comments on commit 554a240

Please sign in to comment.