read file into jit.movie (if present) OR prompt user for location

Shane's icon

Hi all,

This seems like it should be super simple, and it probably is...

I'm looking for a way to read a movie into jit.movie IF it is present in a specified location, or ELSE to prompt the user to specify the location (just like if you pass the message "read" with no filename attached).

I'd be very grateful for any tips! And apologies for the noob question...

Shane

richard barber's icon

https://docs.cycling74.com/reference/absolutepath/ use [absolutepath] to check for existence.

Shane's icon

Thanks so much! This is really helpful.

I am assuming that this will only work in a patch (not in a standalone). Is that correct?

Thanks again!

Source Audio's icon

if you send absolute path or just a file name to absolutepath object,

it will pass path if found, or output notfound message

which you can use to trigger open dialog.

it does not matter if max patch or standalone.

the only difference make search paths that max and standalone

don't share when you only provide file name.

P.S. - yes you need to connect right outlet to read $1, sorry ...

Shane's icon

Thank you so much for this, Source Audio -- it's really helpful! I discovered I needed to add a [prepend read] in the case that the file was found, but after that it works flawlessly if used in a patch.

However, when I compile a standalone, the behavior is not as expected: if the mp4 file is present, it still opens a dialog window to select it, and the console is throwing an error: "absolutepath could not convert to pathname"

Any ideas? Thanks again!

Shane's icon

Update: never mind -- after I tried compiling the standalone again, everything works as expected! No idea what was wrong (I didn't change anything...), but it's all good now.

Thanks again for your help!

Shane's icon

OK, I'm not as clear on this as I thought. I have two scenarios:

1) If I include a video file in a standalone, the embedded video plays flawlessly if I bang a message "read myvideo.mp4" --> [jit.movie].

2) But if I instead use the [absolutepath] object as described above, so that the app looks for a copy of myvideo.mp4 to play but prompts for input if not found, this only works if the video is saved external to the app (in the same folder), not if I include it in the standalone. Even if it is included in the standalone, it will not read the video file and I will be prompted for an external file. Here is the relevant part of the patch:

I assume this is because [absolutepath] does not work the same and/or paths get changed when the .mxf file is compiled. Is that correct?

And more importantly: is there a workaround or solution to this?

Thanks!

Source Audio's icon

where do you place that video within app ?

In resources next to mxf file must work.

in correctly configured standalone inspector also activate

Don't build standalones using projects !

other than that you can allways use absolute path to the file.

like

HD2:/My-VideoPlayer.app/Contents/Resources/myvideo.mp4

to get that path combine app resources path with the rest.

Shane's icon

Thank you, Source Audio -- this is really helpful!

I recently learned the hard way that projects don't work to build standalones... But I didn't think simply to copy my files into the already compiled standalone. I was trying to use the "include folder" option when building -- which works to a certain extent: it doesn't seem to properly include any subfolders, or at least it can never find the files in them, but if everything is in one folder it more or less works -- but things get messy, and in cases like this it didn't work anyway...

This workaround will make my life so much easier! Thanks!!

Source Audio's icon

Glad that it helped.

If you need further assistance - feel free to ask.

Subfolders are also no problem at all,

as long as you know where they are.