Skip to content

Commit d71d5af

Browse files
committed
fixes android
1 parent 864b16a commit d71d5af

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/android/com/dooble/phonertc/PhoneRTCPlugin.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ public void run() {
188188
}
189189

190190
_videoParams = new WebView.LayoutParams(
191-
_videoConfig.getContainer().getWidth() * _videoConfig.getDevicePixelRatio(),
192-
_videoConfig.getContainer().getHeight() * _videoConfig.getDevicePixelRatio(),
193-
_videoConfig.getContainer().getX() * _videoConfig.getDevicePixelRatio(),
194-
_videoConfig.getContainer().getY() * _videoConfig.getDevicePixelRatio());
191+
(int)(_videoConfig.getContainer().getWidth() * _videoConfig.getDevicePixelRatio()),
192+
(int)(_videoConfig.getContainer().getHeight() * _videoConfig.getDevicePixelRatio()),
193+
(int)(_videoConfig.getContainer().getX() * _videoConfig.getDevicePixelRatio()),
194+
(int)(_videoConfig.getContainer().getY() * _videoConfig.getDevicePixelRatio()));
195195

196196
if (_videoView == null) {
197197
// createVideoView();
@@ -340,8 +340,8 @@ public void removeRemoteVideoTrack(VideoTrack videoTrack) {
340340

341341
private void createVideoView() {
342342
Point size = new Point();
343-
size.set(_videoConfig.getContainer().getWidth() * _videoConfig.getDevicePixelRatio(),
344-
_videoConfig.getContainer().getHeight() * _videoConfig.getDevicePixelRatio());
343+
size.set((int)(_videoConfig.getContainer().getWidth() * _videoConfig.getDevicePixelRatio()),
344+
(int)(_videoConfig.getContainer().getHeight() * _videoConfig.getDevicePixelRatio()));
345345

346346
_videoView = new VideoGLView(cordova.getActivity(), size);
347347
VideoRendererGui.setView(_videoView, null);
@@ -395,16 +395,16 @@ private void refreshVideoView() {
395395

396396
int widthPercentage = videoSizeAsPercentage;
397397
int heightPercentage = videoSizeAsPercentage;
398-
while((x + widthPercentage) > 100){
399-
widthPercentage--;
398+
if((x + widthPercentage) > 100){
399+
widthPercentage = widthPercentage - x;
400400
}
401-
while((y + heightPercentage) > 100){
402-
heightPercentage--;
401+
if((y + heightPercentage) > 100){
402+
heightPercentage = heightPercentage - y;
403403
}
404404

405405
pair.setVideoRenderer(new VideoRenderer(
406406
VideoRendererGui.create(x, y, widthPercentage, heightPercentage,
407-
RendererCommon.ScalingType.SCALE_ASPECT_FILL, true)));
407+
RendererCommon.ScalingType.SCALE_ASPECT_BALANCED, true)));
408408

409409
pair.getVideoTrack().addRenderer(pair.getVideoRenderer());
410410

src/android/com/dooble/phonertc/VideoConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class VideoConfig {
88

99
private VideoLayoutParams _container;
1010
private VideoLayoutParams _local;
11-
private int _devicePixelRatio;
11+
private float _devicePixelRatio;
1212

1313
public VideoLayoutParams getContainer() {
1414
return _container;
@@ -29,7 +29,7 @@ public void setLocal(VideoLayoutParams _local) {
2929
public static VideoConfig fromJSON(JSONObject json) throws JSONException {
3030
VideoConfig config = new VideoConfig();
3131
config.setContainer(VideoLayoutParams.fromJSON(json.getJSONObject("containerParams")));
32-
config.setDevicePixelRatio(json.getInt("devicePixelRatio"));
32+
config.setDevicePixelRatio((float)json.getDouble("devicePixelRatio"));
3333

3434
if (json.has("local")) {
3535
config.setLocal(VideoLayoutParams.fromJSON(json.getJSONObject("local")));
@@ -38,11 +38,11 @@ public static VideoConfig fromJSON(JSONObject json) throws JSONException {
3838
return config;
3939
}
4040

41-
public int getDevicePixelRatio() {
41+
public float getDevicePixelRatio() {
4242
return _devicePixelRatio;
4343
}
4444

45-
public void setDevicePixelRatio(int _devicePixelRatio) {
45+
public void setDevicePixelRatio(float _devicePixelRatio) {
4646
this._devicePixelRatio = _devicePixelRatio;
4747
}
4848

www/phonertc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ function getLayoutParams(videoElement) {
158158
if (cordova.platformId === 'android') {
159159
return {
160160
position: [boundingRect.left + window.scrollX, boundingRect.top + window.scrollY],
161-
size: [videoElement.offsetWidth, videoElement.offsetHeight]
161+
size: [boundingRect.width, boundingRect.height]
162162
};
163163
}
164164

165165
return {
166166
position: [boundingRect.left, boundingRect.top],
167-
size: [videoElement.offsetWidth, videoElement.offsetHeight]
167+
size: [boundingRect.width, boundingRect.height]
168168
};
169169
}
170170

0 commit comments

Comments
 (0)