jwcao / opentok-titanium

Titanium module for using Opentok with iOS and Android
6 stars 3 forks source link

Enable publisher view on top of the subscriber view #8

Open grebulon opened 4 years ago

grebulon commented 4 years ago

If you want to show a small publisher view on top of the subscriber view, you need to add the following line to PublisherProxy#createView:

((GLSurfaceView)v).setZOrderOnTop(true);

The code should be:

@Kroll.method
public OpentokViewProxy createView(KrollDict options) {
    try {
        EventHelper.Trace("AndroidOpentok PublisherProxy createView", "Creating a new OpentokViewProxy");
        view = new OpentokViewProxy();
        view.handleCreationDict(options);
        // Small publisher view should appear on top of the subscriber. Without this, the publisher view will not
        // be displayed on top of the full screen subscriber.
        if (v instanceof GLSurfaceView) {
            ((GLSurfaceView)v).setZOrderOnTop(true);
        }
        if (publisher != null) {
            view.setAndroidView(publisher.getView());
        }
        return view;
    } catch (Exception e) {
        EventHelper.Error("AndroidOpentok PublisherProxy createView", "Hit an exception creating the view : " + e.getLocalizedMessage());
        return null;
    }
}