How to get the top-left position of widget

  • 1
  • Question
  • Updated 3 years ago
  • Answered
To support seamless and smooth video playback in android device, we should use native video players instead of html5 video tag.
So we need to find the top-left position of our widget to place native components in the screen.
We are able to get width and height of widget (rsW, rsH) but unable get the top-left position.
When we were using 'Gadgets', we were able to get it via javascript function, by finding the position of iframe.
But after we migrated to widget, javascript functions won't work, and it throws exception of cross domain.


Please help us to solve this issue.
Photo of Prince Francis

Prince Francis

  • 122 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Prince Francis

Prince Francis

  • 122 Points 100 badge 2x thumb
The same question was asked by William - https://community.risevision.com/rise_vision_inc/topics/getting_the_left_and_top_numbers_from_the_ga...
Let me try it. Hope that it will help us to solve the problem.
Photo of Stephen Garrett

Stephen Garrett, Champion

  • 2,674 Points 2k badge 2x thumb
What are you using to open the presentation viewer? How are you combining native elements and Rise presentations? I have had to deal with cross site stuff on our systems when I develop because we don't have the right CORS settings setup on our servers. So when I open up the Rise stuff on my local machine, I open Chrome with the "--disable-web-security" tag and I can test without getting cross site scripting errors.
Photo of Ashleigh

Ashleigh

  • 3,740 Points 3k badge 2x thumb
Hi Prince,

Did William's thread help you out?

Kindly forward your presentation so I can take a closer look at the code you are using.

Ashleigh
Photo of Prince Francis

Prince Francis

  • 122 Points 100 badge 2x thumb
Hi Ashleigh,

<<Did William's thread help you out?>> No, still we got Permission error when accessing the parent DOM.

We do the following steps to play videos in the native player
1. From the js method 'play' (registered via gadgets.rpc.register("rscmd_play_" + id, play)), we pass the width, height, top, left, and other parameters to our android application using a post request to a local servlet.
2. The local servlet create a video view and append to the screen in the specified position passed by the 'play' method.
3. we are able to get 'width and height' using the API https://help.risevision.com/developer/widget-api/widget-parameters

Please help us to find the top-left position if widget.

This is our current widget.js file https://www.dropbox.com/s/tkbpzp1j7w4ek0q/widget.js?dl=0
and widget.html file https://www.dropbox.com/s/3av6ihkypuzhadr/widget.html?dl=0
Photo of Prince Francis

Prince Francis

  • 122 Points 100 badge 2x thumb
Hi Stephen,

We use webview to open presentations in our android devices. Web view doesn't support '--disable-web-security' 
We run a local web server in our android device, to communicate from methods in widget.js to our application. So to place the native video player in the screen, we require height, width, top, left of the widget.
Photo of Stephen Garrett

Stephen Garrett, Champion

  • 2,674 Points 2k badge 2x thumb
Ah, this isn't something I have had experience with. I have been working inside the system with all that I have been doing. Our end point is always Chrome or some form of it. Good luck!
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
I was working on something similar and it would be nice to add (rsT, rsL) top and left to the list of things a widget can use or get. Other uses would also include live tv from a device. The code from the link was to use live tv on a samsung smart signage tv and it worked for a gadget but not widgets. Hopefully Rise will add this in as a needed part of widgets.  
Photo of Robb

Robb, Official Rep

  • 76,676 Points 50k badge 2x thumb
Prince and William,

We were discussing this internally, and given the direction we are going in in regards to the Viewer mechanism for Presentations, this functionality (rsT, rsL) isn't something we can support.

We will certainly keep everyone updated as this changes, but for now, this is not something we are going to be introducing.

Please let me  know if you have any questions.

Thanks!
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
I understand but how can someone get the top and left of a placeholder in a widget without getting access denied. The only options would be to either allow certain domains access to the iframe or the functionality i mentioned. This hurts live tv for samsung sssp as well because i used top and left in a gadget to make it work.  
Photo of Prince Francis

Prince Francis

  • 122 Points 100 badge 2x thumb
Thanks Robb for your reply,
Waiting for the solution.
Our live streaming, power point, video widgets are depending on it.
Photo of Alan Clayton

Alan Clayton, Official Rep

  • 8,788 Points 5k badge 2x thumb
All - 

Two new parameters have been added to the Widget URL for retrieving the Top and Left position of the Widget within the Presentation. These variables are available in the Widget itself via the gadgets.getPrefs object, and their names are rsT and rsL.<br><br><span style="font-family: Helvetica, Arial, sans-serif; font-size: 14.6667px;">Thanks!</span><br>
Photo of Prince Francis

Prince Francis

  • 122 Points 100 badge 2x thumb
Thanks Alan for your help,
We'll use it in our widget.

Regards,
Prince Francis.
Photo of Stephen Garrett

Stephen Garrett, Champion

  • 2,674 Points 2k badge 2x thumb
Sweet! I'll think of something to do with this!