mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 23:32:26 +00:00
macosx_application: handle mpv:// links
Pretty useful for people writing userscripts for web browsers. Links starting with 'mpv://' are forwarded to the mpv OSX bundle. The leading 'mpv://' is stripped from the recived url and the rest of the string is inserted as is in the playlist.
This commit is contained in:
parent
b0797e8fe9
commit
494d408583
@ -186,6 +186,16 @@
|
||||
<true/>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>mpv Custom Protocol</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>mpv</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "osdep/macosx_application_objc.h"
|
||||
#include "osdep/macosx_compat.h"
|
||||
|
||||
#define MPV_PROTOCOL @"mpv://"
|
||||
|
||||
static pthread_t playback_thread_id;
|
||||
|
||||
@interface Application (PrivateMethods)
|
||||
@ -241,6 +243,11 @@ static NSString *escape_loadfile_name(NSString *input)
|
||||
NSString *url =
|
||||
[[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
||||
|
||||
url = [url stringByReplacingOccurrencesOfString:MPV_PROTOCOL
|
||||
withString:@""
|
||||
options:NSAnchoredSearch
|
||||
range:NSMakeRange(0, [MPV_PROTOCOL length])];
|
||||
|
||||
self.files = @[url];
|
||||
|
||||
if (self.willStopOnOpenEvent) {
|
||||
|
Loading…
Reference in New Issue
Block a user