How to set up VLCMediaPlayerMBS

I’d like to use VLCMediaPlayerMBS with Xojo 2021r2.1 and MBS 23.3 to create a Mac/Win cross-platform app.

There seem to be several dylibs needed under MacOS for this class, but I don’t see anything in the documentation about where to get them or how to install them.

When I try to run the example app on an M1 Mac I get some messages about incompatibility with ARM architecture. Is the plugin not compatible with ARM? These are followed by “Failed to load library. No such file.”

When I try to run it under Windows 11 I get a message “Failed to load library. The specified module could not be found.”

Complete instructions would be appreciated, thanks.

You need to download VLC app, install it and then you can copy the libraries from it.

The Windows example loads the DLLs directly from the installed VLC application.

VLC app is installed and it works.

I added a Build Step to the example app to copy the libraries, and I still get errors about target architecture:

I see that SoftDeclareMBS is deprecated, so I tried DeclareLibraryMBS instead, but it gives me an UnsupportedOperationException (Failed to read library), using either FolderItem or path Constructor:

Project is set to Intel and you have the Apple Silicon version, which doesn’t work together.

Please make sure architectures match.

You can continue with SoftDeclareMBS. It is not going away.

1 Like

OK, that was stupid of me, thanks. Project now runs and works on my Mac. Every time I quit the app, however, I get a crash:

Process: Show video sample.debug [29421]
Path: /Users/USER/*/Show video video sample.debug
Identifier: Show video sample.debug
Version: ???
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
User ID: 501

Date/Time: 2023-11-20 09:46:13.6245 -0500
OS Version: macOS 13.3 (22E252)
Report Version: 12
Anonymous UUID: BF1976E1-A18B-5301-8389-0B623F6C90D2

Sleep/Wake UUID: 228D0C0A-8830-4499-B3B4-3E393E381E79

Time Awake Since Boot: 80000 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue:

Exception Codes: KERN_INVALID_ADDRESS at 0x000000010b3f4bc8
Exception Codes: 0x0000000000000001, 0x000000010b3f4bc8

Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [29421]

VM Region Info: 0x10b3f4bc8 is not in any region. Bytes after previous region: 2821065 Bytes before following region: 898104
CoreAnimation 10b140000-10b144000 [ 16K] r–/r-- SM=PRV
—> GAP OF 0x38c000 BYTES
VM_ALLOCATE 10b4d0000-10b4d4000 [ 16K] r–/r-- SM=PRV

Thread 0 Crashed:: Dispatch queue:
0 libobjc.A.dylib 0x184643f00 objc_retain + 16
1 CoreFoundation 0x184a43244 __NSSingleObjectArrayI_new + 88
2 CoreFoundation 0x184a68edc -[NSArray initWithArray:range:copyItems:] + 368
3 AppKit 0x1884a7540 -[NSView _windowWillOrderOffScreen] + 84
4 AppKit 0x1884a7598 -[NSView _windowWillOrderOffScreen] + 172
5 AppKit 0x1884a7598 -[NSView _windowWillOrderOffScreen] + 172
6 AppKit 0x187eda6cc -[NSWindow _doWindowWillBecomeHidden] + 76
7 AppKit 0x1884bc5ec -[NSWindow _reallyDoOrderWindowOutRelativeTo:] + 192
8 AppKit 0x1884bca94 -[NSWindow _reallyDoOrderWindow:] + 80
9 AppKit 0x1884bcce4 -[NSWindow _doOrderWindow:] + 264
10 AppKit 0x1884b8580 -[NSWindow _finishClosingWindow] + 232
11 AppKit 0x187f68f38 -[NSWindow _close] + 276
12 XojoFramework 0x103ab4d78 WindowImpCocoa::HideWindow() + 24
13 XojoFramework 0x103c5c61c Window::Close() + 36
14 XojoFramework 0x103b1591c RuntimeView::UnifiedClose(bool) + 584
15 XojoFramework 0x103b077f0 0x1039f8000 + 1112048
16 XojoFramework 0x103c5d430 IterateWindowList(unsigned char ()(Window, void*), void*) + 920
17 XojoFramework 0x103b076a4 TestApplicationQuit() + 152

@Christian_Schmitz any idea about this crash? It’s the MBS “Show Video Sample” example app.

Not really.
But since that is happening in window, you may check if you need to cleanup the player and remove it from the window before closing it.

I haven’t seen this one before.

In CancelClose, I set the player to nil, I set the VLCMediaMBS to nil, and I set

System.EnvironmentVariable("VLC_PLUGIN_PATH") = ""

but it still crashes on quit.

The crash doesn’t happen under Windows and it doesn’t happen if I don’t play the movie before quitting.

The crash may be cause because you set something to nil (too early).
As something gets accessed later when the crash happens, which isn’t there anymore.

If you set NSObject for VLCMediaPlayerMBS to add NSView, maybe set this to nil in window.close event?