Movie problems in LiveCode

Devin Asay devin_asay at byu.edu
Thu Apr 2 11:53:36 EDT 2015


On Mar 31, 2015, at 3:14 PM, stgoldberg at aol.com wrote:

> 
> Yes, Devin, in using your script for Macintosh using LC 6.7 and higher:
> 
> set the filename of player 1 to the defaultFolder & "/media/mymovie.mov"
> 
> that appears to let the movie show after the standalone is transferred to other Mac or Windows computers.
> I thank you for pointing that out. However, with that script, I am now unable to see the movie in the stack prior to creating the standalone. 
> Any suggestion for that?  Thanks.
> 
> Stephen Goldberg

Stephen,

Yes, the defaultFolder is, by default, set to the folder where the LiveCode engine is located. That means that in standalones the defaultFolder is the folder where the .app bundle (on Macs) or .exe file (on Windows) is located. However, when working in the IDE the engine is the LiveCode application. Thus, in the IDE the defaultFolder is initially the folder containing the LC application, something like /Applications on my Mac, or C:\Program Files(x86)\RunRev\LiveCode on Windows. That means you need to do something different while working in the IDE.

In most of my projects I check the environment before setting the folder path for external media resources, similar to this:

  # In the script where I’m setting the filepath of the player (or image) object:

  set the filepath of player “myplayer” to mediaFolderPath() & “/media/mymovie.mov”

In the stack script I’ll include functions like this:

  function mediaFolderPath
    put the environment into tEnv
    if tEnv is “development” then
      return enclosingFolder()
    else if tEnv is “standalone” then
      return the defaultFolder
    else if tEnv is “mobile” then
      return specialFolderPath(“engine”)
    end if
  end mediaFolderPath

  function enclosingFolder
    set the itemDelimiter to “/“
    return item 1 to -2 of the effective filename of this stack
  end enclosingFolder

There is one interesting wrinkle with setting the defaultFolder on Mac OS X that allows you to “hide” your media assets inside the .app bundle. If you choose to set the defaultFolder to enclosingFolder() in the standalone environment, the defaultFolder will be the ApplicationName.app/Contents/MacOS folder *inside* the .app bundle. If you choose NOT to set the defaultFolder in the standalone, it will remain, by default, the folder that encloses the .app bundle. Of course, if you choose to “hide” your media assets using this technique you must be sure to move them into the Contents/MacOS folder at build time. This is most easily done by using the Copy Files tab in the Standalone Application Settings.

(Some time ago I added a note regarding this "quirk"—I happen to think it’s a “feature”—of Mac OS X to the defaultFolder entry in the LC dictionary. You may also find that helpful.)

Regards,

Devin

Devin Asay
Office of Digital Humanities
Brigham Young University





More information about the Use-livecode mailing list