Standalone application problem

Devin Asay devin_asay at byu.edu
Thu Apr 19 12:19:15 EDT 2007


On Apr 18, 2007, at 5:21 PM, Andrew Lian -nswc wrote:

> Dear All
>
> Please forgive yet another newbie question.
>
> I have stack which plays a sound file played through a  
> playerobject. Its path is identified in the player's "Source"  
> property. Let's say it is C:/sounds/apl.wav.
>
> The file plays perfectly well in the development environment and on  
> my computer.
>
> I now make a standalone application - and it is produced ok.  
> However, my sound file can no longer be heard. Either it has not  
> been automatically packaged into the application or there is a path  
> problem.
>
> I have tried to include the relevant file in the package by using  
> the "Copy Files" setting of the "Standalone application settings"  
> but that seems to make no difference. Is there some legible  
> documentation somewhere of how to prepare the files so that the  
> whole package gets produced correctly with the correct paths? DO I  
> have to respect the original paths and recreate them on any  
> computer which tries to run the standalone?

Andrew,

Most often it's easiest to leave the external media files in a place  
relative to the defaultFolder. The problem is the default value of  
the defaultFolder changes when running as a standalone vs. in the  
development environment. In the IDE, the defaultFolder is the folder  
containing the Revolution executable. In the standalone environment,  
the stack in essence becomes the executable, so the defaultFolder is  
the folder containing the standalone. If you don't explicitly set the  
defaultFolder to another place on the disk, it will work if you set  
the filename ("source") property of the player to 'sounds/apl.wav',  
and then making sure the sounds folder is in the same folder as the  
standalone. To deal with the difference between the IDE and  
standalone, I often include the scripting similar to this in my  
mainstack's stack script:

on preOpenStack
   # set the root folder for all resources
   if the environment is "development" then
     set the defaultFolder to enclosingFolder(the name of me)
   end if

   ## Do this for local data and media files.
   set the baseDir of me to the defaultFolder & "/" & "resources"
end preOpenStack

function enclosingFolder pStName
   get the filename of pStName
   set the itemDelimiter to "/"
   return item 1 to -2 of it
end enclosingFolder

The situation for Mac OS X is slighter more complicated, but easy  
enough to understand, if you're interested.

One last thing... I never use the "copy files" part of the standalone  
builder. I find it easiest just to build my standalone then move the  
needed files or stacks into the appropriate folder.

HTH

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list