Tip for handling external media files
Richard Gaskin
ambassador at fourthworld.com
Mon Jul 15 19:57:01 EDT 2002
When using media external to a stack, such as QuickTime files, you can use
paths relative to the standalone (e.g., "/mediafolder/mymovie.mov"). This
works well at runtime, but during development it requires that you keep your
work files in the same folder as the Rev application. If you're like me,
maintaining many different code bases for different projects, keeping
everything in the Rev folder is a lot less convenient than keeping them
separate with other files related to each project.
A solution I use here is to ignore the defaultFolder as often as possible,
and instead rely on a handy lil' function:
function AppPath
get the filename of stack "MyAppManStack"
set the itemDel to "/"
delete last item of it
return it&"/"
end AppPath
When assigning media, AppPath is called like this:
set the filename of player 1 to AppPath()&"Media/Movie1.mov"
The nifty thing about this approach is that it works equally well whether my
stack is running as a standalone or within the Rev IDE, regardless of where
the mainstack file os located. As long as I keep my work files together in
one folder to maintain their own relative paths, I can move that folder
anywhere -- across drives or even across machines.
If you access a lot of external files from a given folder, you can further
simplify your scripts with something like this:
function MediaPath pShortFileName
return AppPath()&"Media/"&pShortFileName
end MediaPath
You can then assign media with:
set the filename of player 1 to MediaPath("Movie1.mov")
You can add error-chrecking for a more complete implementation:
function MediaPath pShortFileName
get AppPath()&"Media/"&pShortFileName
if there is not a file it then
answer "Couldn't find file ""e&it"e
exit to top
else return it
end MediaPath
--
Richard Gaskin
Fourth World Media Corporation
Custom Software and Web Development for All Major Platforms
Developer of WebMerge 2.0: Publish any Database on Any Site
___________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
Tel: 323-225-3717 AIM: FourthWorldInc
More information about the use-livecode
mailing list