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 onContext:
- Take the resolution from
videoResolutionand 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
displaySize. - 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 3 and 4 but just use the provided videoResolution.