I’m having a little issue, I’m trying to size the UI of my extension based on the current size of the video being displayed. So when onContext fires I’m doing a little resizing of a few UI elements.
The issue I have is Theatre mode. When in theatre mode the display res is classed as the red arrows (sort of arrows anyway) in the attached image. Where as the extension is restricted to the video itself (blue arrows).
Anyone else solved this in a different way?
If I understand your problem correctly, you want to bound your extension by the actual video in Theater Mode, as opposed to the the bounds provided by
displaySize which include the padding for maintaining aspect ratio.
If that’s the case, you can use the aspect ratio to define new bounds from the data received by
- Take the resolution from
videoResolution and calculate the aspect ratio
- Calculate the video size as segment of the
displaySize (red arrows in your illustration):
width_of_displaySize / aspect_ratio = height
- Take this new segment and vertically or horizontally center it (depending on aspect ratio) within the area defined by
- All the above should give you the top and left coordinates and width and height of the video itself as positioned in Theater Mode.
You may not even need to calculate the aspect ratio, on second thought. In which case, you simply do steps
4 but just use the provided