songz / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
Other
162 stars 270 forks source link

Video location/size does not account for viewport scaling #196

Open dested opened 9 years ago

dested commented 9 years ago

I am building an ionic/cordova app that utilizes viewport scaling, and my video is not appearing in the correct location on the screen. After modifying the openTok.js to calculate based on the window.devicePixelRatio it is pixel perfect. The following code needs to be modified in OTHelpers.coffee

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

I will try to make a pull request, but if this is immediately burning anyone, this seems to be the solution.

derwaldgeist commented 9 years ago

This did not work for me, because also the surrounding DIVs became too large. I managed to fix the video size somehow by adding the device pixel ratio in the Cordova exec command. But it still looks quirky, the borders are not set correctly. And it only works on Android, on iOS the video is somewhere it definitely does not belong.

BTW: This is for the local video stream. Do you happen to know how I can position the remote video stream that is opened when the session has started? In my case, this video is placed very strangely.