mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.28k stars 2.9k forks source link

Dragging files on window broken on OS X 10.10 #1202

Closed ChrisK2 closed 9 years ago

ChrisK2 commented 10 years ago

Dragging video files or subtile files on the window to play them / add them doesn't work on 10.10. Instead of the file path the system now hands over some kind of ID which mpv can't make any use of:

Playing: /.file/id=6571367.10596333
[file] Cannot open file '/.file/id=6571367.10596333': Not a directory
Failed to open /.file/id=6571367.10596333.
pigoz commented 10 years ago

https://bugreports.qt-project.org/browse/QTBUG-40449 it looks like it's Apple's fault.

I tried the following diff but it doesn't work (trips on itself when escaping characters I think producing stuff like /Users/pigoz/Yarr!!!/Animu/[Horrib20p%5D.mkv):

diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m
index 7d03021..b44eb9c 100644
--- a/osdep/macosx_events.m
+++ b/osdep/macosx_events.m
@@ -440,7 +440,8 @@ void cocoa_set_input_context(struct input_ctx *input_context)
     size_t num_files  = [files count];
     char **files_utf8 = talloc_array(NULL, char*, num_files);
     [files enumerateObjectsUsingBlock:^(id obj, NSUInteger i, BOOL *_){
-        char *filename = (char *)[obj UTF8String];
+        NSString *url  = [[[NSURL URLWithString:obj] filePathURL] absoluteString];
+        char *filename = (char *)[url UTF8String];
         size_t bytes   = [obj lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
         files_utf8[i]  = talloc_memdup(files_utf8, filename, bytes + 1);
     }];
Nyx0uf commented 10 years ago

As I said on IRC, I don't have the problem on my mba with 10.10 though (latest git master).

Only thing notable I did was disabling some stuff (Gate Keeper for ex): https://gist.github.com/brandonb927/3195465/7c234e6e2e1a693e42e791ad5b05349d577cc5f4