songz / cordova-plugin-opentok

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

How to set video size to the exact size of the surrounding DIV? #199

Open derwaldgeist opened 8 years ago

derwaldgeist commented 8 years ago

I expected that the video would fit in the DIV that is handed over to the initPublisher() method. But on both Android and iOS, my videos are "out in Nirvana" - they appear where they want and don't have any relation to the surrounding DIV. Also, the video is way too small (approx 1/2 of the DIV's size). This happens on both Android and iOS. Is there a sample repository somewhere that shows how this scaling can be done correctly? It would also be very helpful if there was an API documentation. I had to scan the sourcecode of the JS implementation to find out that initPublisher() expected width and height statements. Otherwise, it showed errors in the console.

fatmonkey99 commented 8 years ago

I have been trying to use this plugin myself, and can tell it has been dropped in favor of https://www.npmjs.com/package/cordova-plugin-opentokjs.

The new plugin works fine in Cordova Android, but - as of today - cannot display incoming video on iOS.

See: https://github.com/aoberoi/cordova-plugin-opentokjs/issues/13

Speaking about this plugin it seems:

I will share my findings here.

fatmonkey99 commented 8 years ago

Tested and confirmed it works as of today among these:

This might help:

I can share some sample code if you are interested.

derwaldgeist commented 8 years ago

Yes, some sample code would be awesome!

fatmonkey99 commented 8 years ago

Here you go: https://github.com/fatmonkey99/cordova-plugin-opentok-example

derwaldgeist commented 8 years ago

Thanks!

derwaldgeist commented 8 years ago

I've seen that you now use the songz/cordova-plugin-opentok plugin instead of aoberoi/cordova-plugin-opentokjs, so I assume you did not get the other one working on iOS?

I'm still using the "songz" version as well, but I had to patch the JS file to make it work on all devices. To be honest, I never saw such a "crappy" JS implementation before. :-) I already decided to re-work this JS part as soon as I find some time to do it, and just keep the native side as it is. Not just because it is so weird, but also because it clutters the global namespace so much, which is not good for my Meteor app. It's a shame that OpenTok does not support Cordova properly...

fatmonkey99 commented 8 years ago

Yes, we could not make the aoberoi/cordova-plugin-opentokjs to work: the iOS would always display black square for incoming video.

If you have a better version of the songz plugin, can you share your changes? Fork and drop the code on github - that would help.

BTW, we got it to the point where it looks and works OK, all style issues are addressed, etc. If you face some other problems feel free to reach out, we can share code.

Good luck!

martyzz1 commented 8 years ago

Hi guys,

did you ever make any of your tweaks public anywhere? We're struggling to build just a simple fullscreen video with the local cam overlayed and display an end call and switch camera button...

Just wondering if you managed to handle this? We've got a forked version - updated to 2.7 sdks, and we have reliable video ios/android, but now trying to tidy it up. which I guess is the "pain points" people refer to. So hoping to not to reinvent the wheel.

We'll push our fork public once we've got this sorted (and I find time to move it out of our private app repo)..

Any help, pointers ideas would be welcome...

byronalfonso commented 8 years ago

@martyzz1 - If you want to make your video fullscreen. Get the width and height of the window object then pass/set that as a parameter when you instantiate the opentok object.

Example:

var fullwidth = window.innerWidth;
var fullheight = window.innerHeight;
var options = {width:fullwidth, height: fullheight};
TB.initPublisher('myPublisherDiv', options);

Hope this helps! :)

dxe4 commented 8 years ago

i think the problem on this issue is the devicePixelRatio (half on ionic at least on the devices i tested) there's a fix on another issue but you need to edit the js https://github.com/songz/cordova-plugin-opentok/issues/187#issuecomment-191893064

dxe4 commented 8 years ago

to be a bit more clear, using window.innerHeight and window.innerWidth the plugin styles the html element correctly, but if innerHeight is 500px and devicePixerlRatio is 2 then for the native code the height is 1000px, which is why you get the video shown as half size.