relative paths and Quicktime

Sivakatirswami katir at hindu.org
Wed Dec 5 20:24:02 EST 2001


on 12/4/01 9:24 PM, Steve  wrote:

> 2.  I want to include large quicktime movies with my application but I want
> to include them in a data folder that will use a relative path. Try as I
> might I am not able to figure out how this is done. I have reviewed the
> documentation regarding relative vs absolute paths and I understand the
> difference between the two.

Steve: First of all, the directory thing may "drive you crazy" in the
beginning, especially if you are a Mac user, because you may never know
exactly where you are and Rev/Metacard is based on UNIX paradigm of
dynamically setting the directory location.  But after a while the haze will
fade. Since this was a source of a lot of blood, sweat and tearing of hair
(grin) out of compassion we offer this experience, hope it helps:

Note,  if you are making CD's and put a standalone on the top level of the
CD and your media in a separate directory also on the top level, it may not
work on Windows. I don't know if microBrain every fixed this bug, but it
appears in other contexts as well, and has nothing to do with Rev or
Metacard, but files on the top level of a CD don't seem to know "where they
are" on Windows.... That said, this works for us here and we can move the
entire show to any server on the LAN and Ethernet clients can play it over
the network and all the  path thing works regardless of where it is:

a) Make a folder/directory, call it "My Great Multi-Media Show"
b) put your main stack (or standalone) inside that folder and then
c) put your media folders on the same level inside that folder, Movies,
Sounds, Images, Text etc
d) use the following script in your stack script.


global gRootDir

on preOpenStack
   #find and set the root Directory
   #for all subsequent file references to "lower" media
  
     setRootDir

# now your other preopenStack script go here

end preopenStack

on setRootDir
  put the filename of this stack into stackLocation
  set the itemdel to "/"
  delete the last item of stackLocation
  put stackLocation into gRootDir
  set the directory to gRootDir
end setRootDir

Later you can use the global gRootDir to "get home" as needed
for scripts like the one below. During runtime development you can just type
in the message box "setRootDir"  if file refs seem not to be working.

MAJOR CAVEAT: Note, if you are manually clicking in the properties window to
set the filename reference to link images, you will want to be careful to
delete the path info that is "higher" than your gRootDir in the filename
link field of the image properties dialog box.  e.g. if you choose the image
it might put a ref like this:

 /MyhardDrive/workingProjects/GreatShow/movies/intro.mov

even though your stack is actually in the GreatShow directory...but, using
the above script in the preopen stack will set your working directory to

 /MyhardDrive/workingProjects/GreatShow/

and your full path links WILL BREAK. So you have to manually cut out the
leading path information and just leave:

movies/intro.mov

Because this is very tedious due to

a) the field being too short and
b) the lack of cursor control bug in that field (as you previously noted)

I prefer to create custom tools/buttons on a working palette to set the file
ref by script to exactly the needed directory path. i.e. point to a file
with ask file, parse the file name by script build the path
"movies/intro.mov" put it into some var tFileRef and then set the filename
of some image/player to  tFileRef. all under script control, then you never
have to "touch" or deal with the problems of that field in the properties
box.... well worth the time to get that button working on your own floating
development tools palette if you plan, as we did, to be linking  lots of
media. I actually found it easier to dynamically set the filename ref by
script to just a minimum of image objects and movie players for almost all
media presented.

  Be sure to declare your global (obviously gRootDir) as needed in other
separate object scripts. Good luck.

The following plays a slide show of randomly selected images behind a talk
with soft background music. A top card level button passes the four
parameters to this stack script. Note this uses the very "frowned on" mouse
is down test to make the script break if the user wants to bail out of the
show. But I couldn't find any other way to bail out of a repeat loop like
this. My scripting skills failed on that one...kept creating more problems

global gRootDir
on runTalk  thePixFolder, theRate, theTalk, theMusic
  
  open stack Theater
  
  set the directory to "Innersearch CD/Media/"
     --the above moves the directory "down" to make subsequent file refs
     --require nothing more than their own file name
  set the filename of player "talkPlayer" to theTalk
  set the playloudness of player "MusicPlayer" to 100
  set the filename of player "MusicPlayer" to theMusic
  set the playloudness of player "MusicPlayer" to 5
  start player "MusicPlayer"
  wait 1 secs
  start player "talkPlayer"
  set the directory to thePixFolder
  put the files into tShow
  set the filename of image 1 to line (random(the number of lines of tShow))
of tShow
  show image 1
  move image 1 from -680,-680 to  400,270 in 100 ticks without waiting
  repeat until the mouse is down
-- there is supposed to be a better way to do this
-- but I don't know what it is...
-- i.e. let the user quit the show with a mouseclick
    wait theRate secs with messages
    hide image 1 with dissolve slowly
    set the filename of image 1 to  \
        line (random(the number of lines of tShow)) of tShow
    show image 1 with reveal very slowly
    if  the currentTime of player "talkPlayer"= the duration of player
"talkPlayer" then
      stop player "talkPlayer"
      stop player "MusicPlayer"
      set the  directory to gRootDir
      close this stack
    end if
  end repeat
end runTalk

Hope that helps!

Hinduism Today

Sivakatirswami
Editor's Assistant/Production Manager
katir at hindu.org 
www.HinduismToday.com, www.HimalayanAcademy.com,
www.Gurudeva.org, www.hindu.org

Read The Master Course Lesson of the Day at
http://www.gurudeva.org/lesson.shtml




More information about the use-livecode mailing list