Possible?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Possible?

Post by dalkin » Tue Mar 08, 2011 6:18 am

I'm in the process of building an app that (hopefully) will let a user read a new haiku every day. In order to do this, I don't want to pre-populate the iPhone because, naturally, after being used for a while, the on-board store of new works would be exhausted. In order to overcome that problem, I will stream the (AIF or MP3) from a server and have written an AppleScript to automatically upload new works.

Question: is it possible for LiveCode to identify the newest file of a certain type? eg haiku1.mp3, haiku2.mp3 etc. and then play that file ie. not based on its name but its creation date or upload date? The alternative would be to re-name the file prior to upload which would be too cumbersome.

I'll also be experimenting with using SpecialFolderPath to download to SpecialFolderPath("cache") and then add an option to retain and retrieve played files but that's for the future I guess.

Any help would be appreciated.
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 264
Joined: Mon May 18, 2009 4:12 am

Re: Possible?

Post by wsamples » Tue Mar 08, 2011 7:04 am

Just out of curiosity, how are they named now? You could name them as such: 10-10-2011.mp3 or Some_Inspired_Haiku_Title.10-10-2011.mp3 and have your app look for the file whose date 'item' matches the current (or some earlier) date. You could also upload a companion text file with the same name which could hold your title and description for your, etc., for your app to load along with the audio file.

That's just one idea. Additionally, there are any number of ways this can be handled if you are willing to do some server-side scripting to manage the rotation of the "current" file. That might also allow a web interface to all files as well as simple direct access/download of the latest one. Any of these methods also offers the possibility of uploading files in advance, which you would probably find very useful and doesn't seem to be something your current thoughts provide for.

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 264
Joined: Mon May 18, 2009 4:12 am

Re: Possible?

Post by wsamples » Tue Mar 08, 2011 7:16 am

Another very simple method if you want to only give your Haiku "normal" titles, is to have a text file on the server, which you update when you upload a file, which your app reads to determine which file to download.

dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Re: Possible?

Post by dalkin » Tue Mar 08, 2011 9:01 am

That's a terrific tip Mr/s Sample, I'll research it and talk to the client about the options. Many thanks for your advice.
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Possible?

Post by shaosean » Tue Mar 08, 2011 2:09 pm

If you are grabbing the files from FTP you can always check the file creation dates based on the directory listing.

dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Re: Possible?

Post by dalkin » Wed Mar 09, 2011 9:43 am

After a bit more research, I think it isn't possible to play the most recent file. AFAIK the player object needs a hard-coded URL. There may be some way to script it but I can't find any reference to it. If it is possible, any pointing in the right direction would be mighty appreciated. Having the player retrieve a named file from a URL works like a dream because it's hard-coded (go get file1.mov ya beast) but that's in the App itself, so I can't see a way to call anything other than the named file.
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Possible?

Post by ctflatt » Wed Mar 09, 2011 12:00 pm

Based on the text file solution mentioned above, could you:

create a variable, say tCurrentVideo
write a script to retrieve the first/last (any) line of the remote text file (containing the file name of the video)
put it into tCurrentVideo
then concatenate the url with that variable, http://www.myurl.com.au/ & tCurrentVideo

Have you tried something like this?

:Todd

observ3
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 34
Joined: Mon Oct 11, 2010 11:05 pm

Re: Possible?

Post by observ3 » Sun Mar 13, 2011 2:13 pm

Seconding Todd: If you put the URL into a variable and have your player hard coded to...
1) Check if there is a file at the variable
2) If TRUE, then play the variable
...then it should work.

I was using this method to develop a multi-channel sound player a few weeks back...
Check out my LiveCode program, WriteSpire, on the App Store!

Post Reply