Search code examples
rubymotionrubymotion-promotion

Changing Interface Orientation for BW::Media Modal in RubyMotion


I have a RubyMotion application that is completely portrait (no landscape), but loads BW::Media.play_modal for an external MP4 video URL that I'd like to play in landscape mode.

It's loaded like this using RMQ, PM, and BW:

def on_load
  rmq(@object).on(:tap) do
    BW::Media.play_modal(@object.video_url)
  end
end

I know how to enable autoRotate for an entire screen/controller, but is there a way to force landscape mode only when the modal is played?

Thanks in advance for any help!


Solution

  • Here's how I ended up solving the problem-

    1. I enabled landscape_left and landscape_right throughout the RM app.
    2. I set the should_autorotate method to false throughout the app.
    3. I added a condition using PM's modal? method that set should_autorotate to true when a modal was active.
    4. I used RMQ's rmq.orientation.landscape? method to set the view back to portrait as soon as the modal was exited.

    I hope this helps if anyone else has the same problem!