Including media in an application


    Apr 17 2016 | 4:00 pm
    Greetings! After my previous rookie error, I'm finally ready to build my application!
    On doing so, it seems to work fine, but opening it on a different PC doesn't work, as it cant find the music and videos. IS there a simple way to solve this? I'd included the folder in the application build, but it doesn't seem to do what I think it does. The two video folders are dragged into the playlists, similarly for the sounds folder.
    Apologies for the massive sprawling mess that is my patch(es), I don't doubt that there is a much more refined way of achieving my goals, and in time I hope to find them! Any pointers much appreciated!

    • Apr 18 2016 | 8:14 am
      Congratulations. I have had alot of problems with this particular issue in the past, and by appearances the process has changed since I wrote something on it, but I did make a note here:
      I'm about to try again, so perhaps we can work together on solving the problem?
    • Apr 18 2016 | 8:33 am
      Hi, thanks for the reply.
      Wow, who'd have thought it would be so convoluted!
      It feels like a bit of an elephant in the room, I'm astonished that this is an issue in the 7th iteration of Max (I don't doubt it has come on leaps and bounds since it began, but this feels like a biggy!).
      Perhaps it is too early here but your linked solution goes over my head, having only recently stated to tinker with Max!
    • Apr 18 2016 | 8:54 am
      On first try, it seems to be working MUCH BETTER :) I can make collectives and apps, but I can write JSON preset files out yet. Here is what seems to work in Windows64:
      1. Open your top level patch. Put all; your media in the same folder as the top-level patch and make sure it opens the media files properly right there. Add a standalone object. Include the parts you need. IN the standalone object, also turn on 'make application subfolder.' Turn off 'search for missing files.' 2. From the top-level patcher main menu, select File->save as project. The 'save as' window opens. It wants to provide a name for a subfolder in your 'My documents/Max 7/Projects.' Choose your subfolder name carefully with a version number, because the paths in the project are absolute and you can't move any of the files. 3. Everything disappears momentarily. Wait. 4. Max reappears and the project window opens. Ignore the 'mxe' file shown as implicit and missing.' The project window has no menu, instead you use buttons on the bottom toolbar. You may want to click the 'show project folder' button so you can see the file operations, but it's not necessary. Click the plus sign on the right and select 'add existing file' from the popup menu. 5. A 'file open' dialog appears. If it isn't where your original files were, navigate to where your original files were. Select a media file, press 'open' 6. The media file doesn''t open though, the media file is copied to the same folder you made when you created the project. That's what you want. Repeat for all remaining media and data files. 7. Now for the scary part. Look along the icons until you find a menu option called 'Consolidate.' Select it. All the media and data files are moved to other subfolders. Don't change the path or mcve anything. The project expects the files in the subfolders when your patcher said they are in the same folder as the patcher. Don't change any paths or move any files after you press 'consolidate'. Leave it like it decides to move them. 8. Now select 'build collective/application' from the project window toolbar NOT from the Max patcher file menu. Save it right there where it asks with the name it provides. 9. Things blink and disappear again. Wait. Magically, they reappear. IN the project window, the red file declared as missing and explicit has disappeared. Your collective/application has been built. 10. Save the project file in the root folder of the folder tree it made, not anywhere else, or you won't be able to re-use your work. 11. You can open the collective/application from the project window now. But probably you want to close it, and click on the new .mxf or .exe file which is in one of the subfolders of the project subfolder yobu made. Tada, it contains the media and the paths work.
      Haven't quite figured out how to save a json preset from the collective when closing the app. What I think one has to do is, not use '@savemode 3' in the pattrstorage object, and instead use some event to save the data in the patcher.
    • Apr 18 2016 | 8:59 am
      Wow, really fast work! Thanks, I'll give this a whirl this morning!
      It would be great if Max simply had a "collect files" feature like After Effects, but alas, not yet!
    • Apr 18 2016 | 11:19 am
      A few more notes
      12> After you build your project, you can open and edit patches from the project window. However, doing so causes the project to delete the built support files. So if you make any modifications to the included files, it's a good idea to zip them up and put them somewhere else, then copy them back. However, be careful, because if you add objects to the patcher, they may require more support files.
      13. If you are using a pattrstorage object, you have to set it with "@autorestore 0 @savemode 0 @fileusagemode 1". I think this means it has no properties when you initialize it, so if you just read a json file, it won't have anywhere to put the data. So also, before reading a json file, you have to send it a message "subscribe ctrl ctrl2..." etc where ctrl and ctrl2 etc are the names of the fields you want to read in. Then after subscribing, you can send a read command to read in a json file. And it sees the files in the data subfolder as in the same folder as the patcher. But you can't have more than one json file with the same name on the search path, so if you write the data, you must be sure to write the data to the same folder as the patcher with the same name, and it will overwrite the file in the data folder with the same name. That's as far as I got.
      You will have the same issue with media files; you have to make sure there is only one copy of the media file on the search path. What is better is, the console window actually tells you it found multiple files and which one it decided to use. It doesn't crash when you try to build a project with an external .json file now, which I don't believe has been true since Max 5, and it does a much better job at including files. However, the option to include the audio settings in the menu is gone.
    • Apr 18 2016 | 7:50 pm
      I may be missing something here, but I have always found using the 'Include Folder' option does not work and I simply copy the files I need to the finished application folder.
      If I want to keep things tidy and have my media files inside a folder then I normally use the 'path' message to [thispatcher] in the top level patcher to get an absolute file path and select the folder and files I want. However, I seem to recall that this doesn't work on a standalone and you need to use the '; max sendapppath' message to max in a message box instead, there's something about it here: https://docs.cycling74.com/max5/vignettes/core/messages_to_max.html
      All this being said, I don't think I have tried to build anything on Windows since I moved to Max 7