How to access a file on a remote computer
Peter Haworth
pete at lcsql.com
Sun Jan 18 22:16:33 EST 2015
Hi Scott,
Thanks for the tip. That's actually where I started with all this. Please
bear with me on this somewhat lengthy explanation.
I made this player as kind of an iTunes lite so I could just play tracks
from my iTunes library without the extra bloat of iTunes.
First time it runs, it asks for the location of the iTunes folder. I then
parse the iTunes Library.xml file to get all the info about tracks and
playlists. One of the items of track information is its location which is
in exactly the format you mentioned, with the exception that it starts with
"file://localhost/".
Here's an example:
file://localhost/Volumes/External1/iTunes/iTunes%20Music/A%20Wanton%20Fling/MR%20Possibles/Pipes-The%20Wee%20Eddie%20Reel.mp3
When I choose a track to play, I feed that location info to the player as
it's filename. That all works great as long as I'm looking at an iTunes
folder on the local computer. But if I point the player to an iTunes
folder on another computer on the network, the player doesn't like the
location as a filename because of the "localhost".
I had hoped that if I simply replaced "localhost" with what OSX claims is
the remote computer's name on the network, all would just work. The name I
mean is the one shown in the System Settings/Sharing dialog when you go to
the File sharing section. In my case, it's "petes-imac". It seems like
that should work to me but the player didn't like it. Interestingly, it
does work on the computer named petes-imac but not on a different computer
that is trying to access it.
Next thing I tried was massaging the location info so it looked like this:
file://Volumes/iTunes/iTunes%20Music/A%20Wanton%20Fling/MR%20Possibles/Pipes-The%20Wee%20Eddie%20Reel.mp3
That's what I get if I drag the file into a Terminal window, minus the
"file:/" and without the "%20"'s. But that didn't work either.
At that point I tried a number of different ways of getting the filepath,
some using the location info and some not. Another complication I have to
deal with is that some of the filenames have unicode in them. I'm not
using LC 7 yet but I managed to get around that one.
I finally got it working but then ran into this problem with the ampersand
and whatever other characters need to be escaped.
So that's how I ended up in this situation.
Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
On Sun, Jan 18, 2015 at 5:31 PM, Scott Rossi <scott at tactilemedia.com> wrote:
> Hi Pete:
>
> Many years ago I ran into path issues with players and (from my notes)
> wound up with a workaround that involved using the “full” file path like
> this:
>
> set fileName of player 1 to \
> "file:///volumes/primary/users/dude/really_long_filename_here.mp3”
>
> I also had in my notes to specifically replace spaces with “%20”.
>
> These modifications were for older versions of LC, so not sure if they
> will make any difference now. If you continue to have issues you might try
> urlEncoding the path as well.
>
> Regards,
>
> Scott Rossi
> Creative Director
> Tactile Media, UX/UI Design
>
>
> On Jan 18, 2015, at 4:50 PM, Peter Haworth <pete at lcsql.com> wrote:
>
> > I'm almost there.
> >
> > The reason I'm looking into this is because I'm setting the filename of a
> > player control to the name of a mp3 file on a remote computer.
> >
> > I thought I had it all working but the player control does not like
> > filenames with an ampersand in them.
> >
> > I tried escaping the ampersand with a "\" character (that's what I see
> if I
> > drag the filename into a Terminal window) but still no joy.
> >
> > Same problem with filenames including an apostrophe. I'm guessing there
> are
> > other characters that cause the same problem
> >
> > Any ideas?
> >
> > Pete
> > lcSQL Software <http://www.lcsql.com>
> > Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> > SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
> >
> > On Sun, Jan 18, 2015 at 9:56 AM, Peter Haworth <pete at lcsql.com> wrote:
> >
> >> Thanks Kay and Kee, your suggestions put me on the right track.
> >>
> >> Kay: there is a mount command available though Terminal but I've never
> >> used it so don;t know if it would do what you're suggesting.
> >>
> >> Pete
> >> lcSQL Software <http://www.lcsql.com>
> >> Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> >> SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
> >>
> >> On Sun, Jan 18, 2015 at 3:39 AM, Kay C Lan <lan.kc.macmail at gmail.com>
> >> wrote:
> >>
> >>> Kee,
> >>>
> >>> that had me confused and I looked a little deeper. It appears that
> >>> I've just been lucky in the simple URL way I've been accessing files
> >>> across my LAN - this is as tested on OS X 10.9.5.
> >>>
> >>> The URL method I posted earlier, and the open file for read methods do
> >>> NOT seem to work unless the actual network folder the file resides in
> >>> is mounted on your system - i.e. the Eject symbol needs to present not
> >>> just the server and or folder icon visible. After a quick test the
> >>> simplest way I've found within LC to mount the network folder/file and
> >>> get the exact path name is to use - answer folder/file
> >>>
> >>> answer file "Choose a file:" --navigate to a network TEXT file to test
> >>> put "file:" & it into tFilePath
> >>> put URL tFilePath into msg
> >>>
> >>> For ages I've been using LC to 'do as AppleScript' to tell BBEdit to
> >>> open a network file. I've then been using the 'put URL xxxx into tVar'
> >>> and 'put tContent into URL xxxx' without a hiccup. I didn't realise
> >>> that LC needed the file to be mounted first and BBEdit was doing it
> >>> automatically for me.
> >>>
> >>> Does anyone know if there is a command to force OS X to mount a folder
> >>> that you have appropriate access rights to? I can think of a million
> >>> reasons why you would want to bypass the 'answer folder/file' step. It
> >>> would be nice if either the put URL, or open file methods
> >>> automatically mounted the folder, or a 'mount fiolder' command that
> >>> acted like a faceless 'answer folder'; you gave it a folder path and
> >>> it mounted just like answer folder/file is doing now but without the
> >>> dialog box.
> >>>
> >>> If no one knows of a faceless way to mount a folder on OS X I can put
> >>> in an enhancement request.
> >>>
> >>> Do those on Win and Linux have automatic mounting of network
> >>> folders/files or is this a problem on those platforms as well?
> >>>
> >>> Oh and one last thing. One MAJOR difference between the URL method and
> >>> the open file for read method. If you use open file for read, whilst
> >>> ever it is open if you try and unmount the server/folder, i.e. click
> >>> on the Eject icon, you will get a System warning telling you "The disk
> >>> xxxxx couldn't be ejected because LiveCode is using it". With the URL
> >>> method it is possible to Eject the server/folder without any warning
> >>> so may unwittingly stop your stack from doing what it's suppose to.
> >>>
> >>> I think I better go back and change my URL method to open file for
> read.
> >>>
> >>> _______________________________________________
> >>> use-livecode mailing list
> >>> use-livecode at lists.runrev.com
> >>> Please visit this url to subscribe, unsubscribe and manage your
> >>> subscription preferences:
> >>> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>>
> >>
> >>
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list