Baka-MPlayer
Baka-MPlayer copied to clipboard
Open with not working on OSX
Right-click -> open with -> other.. -> select baka-mplayer -> ok This loads up baka-mplayer but doesn't load up the file. Should probably look into how OSX gives arguments to applications.
Looking at this, I'm under the impression that Mac OSX is passing other arguments--Baka would then try to open those, maybe i'll just ignore things that start with '-' to fix it.
void BakaEngine::Open()
{
mpv->LoadFile(QFileDialog::getOpenFileName(window,
tr("Open File"),mpv->getPath(),
QString("%0 (%1);;").arg(tr("Media Files"), Mpv::media_filetypes.join(" "))+
QString("%0 (%1);;").arg(tr("Video Files"), Mpv::video_filetypes.join(" "))+
QString("%0 (%1);;").arg(tr("Audio Files"), Mpv::audio_filetypes.join(" "))+
QString("%0 (*.*)").arg(tr("All Files")),
0, QFileDialog::DontUseSheet));
}
@KennyDiff this line of code is for the OpenFile dialog. Files that are opened through a file manager should get passed arguments of the opened file. It works the way it should on Windows and Linux, not sure why OSX is different. It may very well be passing extra stuff that we ignore in our very primitive command-line argument handling (we just try to load the first argument).
int main(int argc, char *argv[])
{
#if defined(Q_OS_WIN)
FreeConsole();
#endif
QApplication a(argc, argv);
setlocale(LC_NUMERIC, "C"); // for mpv
MainWindow w;
w.show();
// parse command line
QStringList args = QApplication::arguments(); // <-- here we get command line args
QStringList::iterator arg = args.begin();
if(++arg != args.end())
w.Load(*arg); // <-- here we try to play the argument
else
w.Load();
return a.exec();
}
If you're able to debug this--simply print out what args is. You might want to try skipping - preceded arguments.
while(++arg != args.end() && arg.startsWith("-"));
if(arg != args.end())
w.Load(*arg);
else
w.Load();