Possible?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Possible?
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.
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.
while removing from the skilled the ability to access wealth.
Re: Possible?
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.
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.
Re: Possible?
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.
Re: Possible?
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.
while removing from the skilled the ability to access wealth.
Re: Possible?
If you are grabbing the files from FTP you can always check the file creation dates based on the directory listing.
Re: Possible?
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.
while removing from the skilled the ability to access wealth.
Re: Possible?
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
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
Re: Possible?
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...
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!