cordova-plugin-opentok icon indicating copy to clipboard operation
cordova-plugin-opentok copied to clipboard

Android sizing problems

Open Pentiado opened this issue 9 years ago • 13 comments

I've seen there #66 that something like year ago similar issue was reported and later fixed but now I'm getting this. On iOS everything is fine and on Android size is few times smaller than it should be.

[email protected]

screenshot_2015-07-20-10-50-40

Pentiado avatar Jul 20 '15 09:07 Pentiado

I had the same issue. 1 of the last 13 commits must have introduced a regression error to the specific builds we're using. When I installed from the fork at https://github.com/pfreitag/cordova-plugin-opentok, the sizing problem is no longer there. Note that this seems to use the android sdk <2.5 which triggers a Google Play openssl warning. Thoughts?

rhaker avatar Jul 23 '15 15:07 rhaker

I have the same problem, any ideas?

ghost avatar Jul 31 '15 06:07 ghost

We're evaluating different options than Tokbox. After that long with TB I believe nothing can be worst but in meantime I made a fork where I just multiply size by three and it looks fine.

Pentiado avatar Jul 31 '15 08:07 Pentiado

Got it working, too, but let me know what you find.

rhaker avatar Aug 02 '15 01:08 rhaker

I think the issue is that the pixels for the native views do not correspond to the pixels in the web view.

I got it working with the following fix inside OpenTokAndroidPlugin.java:

add

import android.util.DisplayMetrics;

then replace

widthRatio = (float) mProperty.getDouble(ratioIndex);
heightRatio = (float) mProperty.getDouble(ratioIndex + 1);

with

DisplayMetrics metrics = new DisplayMetrics();
cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);

widthRatio = (float) mProperty.getDouble(ratioIndex) * metrics.density;
heightRatio = (float) mProperty.getDouble(ratioIndex + 1) * metrics.density;

Hope this helps. Not sure if this is the ideal fix but it works.

ghost avatar Aug 03 '15 00:08 ghost

Also, the video views in android are shrinked to fit the container, as opposed to the iOS version where they are stretched to fill the container.

To do the latter (which should be the default imo), add

import com.opentok.android.BaseVideoRenderer;

and

mSubscriber.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);

ghost avatar Aug 04 '15 00:08 ghost

Agreed. The stretch-to-fill seems a better UI experience imo, too. I've got it working by adding

mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);

after mPublisher.setPublisherListener(this);

and

mSubscriber.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);

after mSubscriber.setSubscriberListener(this);

Do you see any bugs/problems with putting it in these locations?

rhaker avatar Aug 09 '15 02:08 rhaker

I was having the same issue and @asanin-2sol's DisplayMetrics-based solution worked for me. Thanks!

mukulmajmudar avatar Aug 17 '15 00:08 mukulmajmudar

Hi

sureshkoduri avatar Sep 10 '15 06:09 sureshkoduri

Hi rhaker,

It is worked for me. Thanks for your Help..

sureshkoduri avatar Oct 14 '15 08:10 sureshkoduri

You need edit opentok.js library.

In this function replace the return.

getPosition = function(divName) { ... return { top:(curtop + marginTop) * window.devicePixelRatio, left:(curleft + marginLeft) * window.devicePixelRatio, width:(width - (marginLeft + marginRight)) * window.devicePixelRatio, height:(height - (marginTop + marginBottom)) * window.devicePixelRatio }

pniaz avatar Oct 30 '15 18:10 pniaz

this seemed to be better solution for me, in case it helps worked perfectly fine:

  TBGetScreenRatios = function() {
    return {
      widthRatio: window.devicePixelRatio,
      heightRatio: window.devicePixelRatio
    };
  };

dxe4 avatar Mar 03 '16 18:03 dxe4

screenshot_20160907-180557 I had the same issue and I solved with @asanin-2sol solution, but both Android and IOS show the default play icon/image over the video. Some help?

angelious avatar Sep 07 '16 16:09 angelious