After some more extensive testing, I’ve explored the issue, learned a few interesting (curious?) things, and at least found an approach that should work for me.
In the past, I’ve generally specified either the files or folder I wanted to load in an XML file. This is so I, or other users / clients could switch the file locations without needed to recompile the app. I’ve generally loaded the path a string from the XML file and then used
ofSetDataPathRoot to point Open Frameworks at that folder. On a mac, I think that worked well, and I don’t remember ever having any issues with that approach.
I learned a few interesting things with this test.
OfImage.load takes a
const std::filesystem::path& and works fine in all cases.
ofVideoPlayer.load takes a
string and gives inconsistent results.
If I use
ofSetDataPathRoot to set the path, images will load fine, but videos will only load if they are on the same drive (and will load with a giant relative path).
If I don’t mess with the Data Path, and instead just provide the full file path (* with all the backslashes doubled)
it will load correctly.
and the results here:
and when I trace out the path it actually tried to load for the videos:
[notice ] video path is: ' ..\..\..\..\..\..\..\..\..\OF_testing\fingers.mov'
[notice ] video path is: ' ..\..\..\..\..\..\..\..\..\..\..\D:\OF_testing\fingers.mov'
[ error ] ofDirectShowPlayer: Cannot load video of this file type. Make sure you have codecs installed on your system. OF recommends the free K-Lite Codec pack.
[notice ] video path is: ' D:\OF_testing\fingers.mov'
So I guess my lesson here is don’t use
ofSetDataPathRoot and just store the path as a string and append it to the filename to make a full path whenever I want to load something outside of the data folder. I’m not sure why the load methods of
ofVideoPlayer take different file types, and I’m re-convinced that file paths in windows are completely stupid and backwards.
@roymacdonald thanks for the system dialog example - it helped me notice I wasn’t escaping my backslashes which causes half (but not all) of my headaches. This is the most fun I’ve had since I tried to run some web apps I had written on a Mac on a Linux server and discovered (after many wasted hours) that case sensitivity matters in Linux. I’ll also log an issue in regards to the vague
ofDirectShowPlayer error messages.