omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Pythonista trigger screen mirror motion control

    Pythonista
    shortcut motion control trigger screen mirrorin
    4
    16
    3893
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • smiddleton
      smiddleton last edited by

      Hey guys,
      I am trying to write a script that will activate the screen mirror shortcut on my iphone, for my Apple tv. I want to be able to "flick" my phone and have it start screen mirroring from that, instead of swiping down and hitting the screen mirroring button, and selecting from the options.

      What I have learned so far: I can write the motion control, "flick" part of the script using , motion.get_user_acceleration(), and motion.get_attitude(). However, I can't find a way to activate the screen mirror shortcut. Any ideas or help would be very appreciated. Thanks in advance for your time and help.
      Steve

      mikael cvp 3 Replies Last reply Reply Quote 0
      • mikael
        mikael @smiddleton last edited by

        @smiddleton, you can create a second window for your Pythonista app, and get that window up on your Apple TV. You can then put your own app content in that window. Let me know if this option in any way helps you, and I can dig for some sample code.

        You cannot turn on the general iPhone mirroring to Apple TV with Pythonista, but you might be able to call a Apple Shortcuts action to do that -- but no, at least based on a quick check I could not find an AirPlay mirroring action there.

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @smiddleton last edited by cvp

          @smiddleton don't ask me more than that, but try

          from objc_util import *
          import ui
          
          class MyView (ui.View):
          	@on_main_thread
          	def __init__(self, *args, **kwargs):
          		ui.View.__init__(self, *args, **kwargs)
          		frame = CGRect(CGPoint(0, 0), CGSize(self.width, self.height))
          		AVRoutePickerView = ObjCClass('AVRoutePickerView').alloc().initWithFrame_(frame)
          		self_objc = ObjCInstance(self)
          		self_objc.addSubview_(AVRoutePickerView)
          
          def main():
          	# create main view
          	mv = ui.View()
          	mv.name = 'Test AVRoutePickerView for @smiddleton'
          	mv.background_color = 'white'
          	mv.present('fullscreen')
          	w,h = ui.get_screen_size()
          	# Create and present a MapView:
          	v = MyView(frame=(10,10,100,100))
          	mv.add_subview(v)
          
          if __name__ == '__main__':
          	main()
          


          tap on button, then you get

          1 Reply Last reply Reply Quote 0
          • cvp
            cvp @smiddleton last edited by

            @smiddleton but what do you want to see on your AppleTV? Your Pythonista screen?

            1 Reply Last reply Reply Quote 0
            • smiddleton
              smiddleton last edited by

              Thanks for the code sample! It worked perfectly for opening airplay. Is that the same thing as screen mirror?

              cvp 2 Replies Last reply Reply Quote 0
              • cvp
                cvp @smiddleton last edited by cvp

                @smiddleton yes and no. It is for mirroring a player, like a music player or a video player, but, I think (not sure) that it is not for IPhone screen mirroring. But you could test by tapping Apple TV and see what occurs on your tv.

                But I don't know anything about that. I just have found the objectiveC class used in my little script.

                1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @smiddleton last edited by cvp

                  @smiddleton But if is to mirror your Pythonista screen, it is possible via a secondary screen, your AppleTV, like @mikael said.

                  1 Reply Last reply Reply Quote 0
                  • smiddleton
                    smiddleton last edited by

                    That makes sense. Would it work to use something like IFTTT to trigger the screen mirror shortcut? I read that pythonista and IFTTT can work together.

                    cvp 1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp @smiddleton last edited by

                      @smiddleton said:

                      IFTTT to trigger the screen mirror

                      Not sure that any app could access to this feature..

                      1 Reply Last reply Reply Quote 0
                      • JonB
                        JonB last edited by

                        You can run a pythonista script from ifft, shortcuts, or a home screen icon. But turning screen mirroring on requires user action.

                        cvp 1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp @JonB last edited by cvp

                          @JonB said:

                          You can run a pythonista script from

                          and from
                          iPhone flicking (settings/accessibility/touch/..)
                          widget
                          notification

                          1 Reply Last reply Reply Quote 0
                          • cvp
                            cvp last edited by

                            Even MPAudioVideoRoutingPopoverController (Belongs to private API, not public, don't use it) does not support any more mirroring

                            The app was terminated due to an Objective-C exception. Details below:
                            
                            2021-05-19 15:54:01.491399
                            Mirroring is no longer supported by MPAudioVideoRoutingPopoverController
                            
                            1 Reply Last reply Reply Quote 0
                            • smiddleton
                              smiddleton last edited by

                              Well, the airdop script worked great, just for sound though. It showed my apple TV, but only for speaker use. I looked for screen mirroring in accessibility, and couldn't find a shortcut there.

                              cvp 1 Reply Last reply Reply Quote 0
                              • cvp
                                cvp @smiddleton last edited by

                                @smiddleton I think you can forget it. No way for an app to set screen mirroring for all apps. Security...

                                1 Reply Last reply Reply Quote 0
                                • smiddleton
                                  smiddleton last edited by

                                  Thanks for the help everyone. I did learn a lot, and that is a win!

                                  cvp 1 Reply Last reply Reply Quote 0
                                  • cvp
                                    cvp @smiddleton last edited by cvp

                                    @smiddleton but it is so sad to terminate on a "no way"...
                                    I guess you know that your "flick" can open the control center without any swipe, but you should still to have to tap on screen mirroring and on AppleTV.

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post
                                    Powered by NodeBB Forums | Contributors