0

My first question goes here. Finding specific examples on PyOBJC is a challenge to say the least, so I thought I might try just asking.. My python script:

from MediaLibrary import * mediaLibrary = MLMediaLibrary.alloc().initWithOptions_(None)

Throws this error:

[MLMediaLibraryImpl connectToService]_block_invoke connection interrupted 2019-10-31 17:33:56.384 Python[77412:20497679] MLMediaLibrary error obtaining remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.MediaLibraryService" UserInfo={NSDebugDescription=connection to service named com.apple.MediaLibraryService}

the mediaLibrary does get instantiated but is not able to fin any mediasources.

I have seen someone have problems with this in Xcode and Objective-C, saying it might be a sandboxing or entitlements issue, but in Xcode on my Mac this runs fine without any of those.

any ideas? help?

ForceBru
  • 43,482
  • 10
  • 63
  • 98
  • Odd: I got the same error you did, then tried it again, and it seemed to work. It might also be helpful to alloc once, then call initWithOptions_(None) in a try block, and try it again if it fails. – Dylan McNamee Oct 31 '19 at 18:19
  • 1
    OK, I see what you are saying, instantiating again removes the error but makes the object unresponsive to KeyValue-Observation. I found [link](https://stackoverflow.com/questions/27372330/what-is-error-in-connection-block-invoke-2-connection-interrupted-in-ios) which talks about the `_block_invoke connection interrupted` part might be a memory limitation, but since the error is thrown before any assets are fetched or even sources found I'm still a stumped.. – KAjohansen Nov 01 '19 at 07:16

1 Answers1

0

This appears to be a limitation on how this library can be used, the SO question "XPC error when using MLMediaLibrary from command line daemon" mentions that this framework can only be used from an app bundle.

Ronald Oussoren
  • 2,715
  • 20
  • 29
  • Thank you for your answer! Yes maybe, but it's difficult to be completely confident that that is what it is. Because I too have the MediaLibrary framework running and loading all assets in a commandline tool. No entitlements or even playlist file included. I am currently trying to use this[py2app](https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/) tutorial to make it as much like a native App as I can but I'm not sure if there is an **OPTION** in the setup.py file I can set, or something to make it more like an app bundle? – KAjohansen Jan 14 '20 at 14:47