MP3 playing in HTTP - does not work

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ferrandjames
Posts: 20
Joined: Tue Mar 01, 2011 11:23 pm

MP3 playing in HTTP - does not work

Post by ferrandjames » Wed Mar 02, 2011 4:04 pm

hello, I have an mp3 file on my site (mysite/test.mp3) and I wish I could read it when I click a button, but with the "play url ("mysite/test.mp3) ", its not working ... could someone help you it ... I'm trying everything ... Write on using nothing but do ...

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

Re: MP3 playing in HTTP - does not work

Post by ctflatt » Sat Mar 05, 2011 11:17 pm

Could you download the resource in a startup script so that it is available when the button is pushed? Is the file a large resource? Are you including the protocol+domain+path to resource in your script?

Need more information to know where to begin.

Thanks,

Todd

ferrandjames
Posts: 20
Joined: Tue Mar 01, 2011 11:23 pm

Re: MP3 playing in HTTP - does not work

Post by ferrandjames » Mon Mar 07, 2011 6:32 pm

Thank you for the answer, todd,
So I have a file that is 1 megabyte maximum, an mp3 file is a simple http protocol is by clicking a button that launches a sub card and I wanted to throw myself in the sounds startup of the card ...
and with all the examples on the site, it does not work ...
and I do not know what to do, I am newbie and I galley, but the advantage that makes learning faster ....
Perhaps you can help me with code ....

thank you in advance

James

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: MP3 playing in HTTP - does not work

Post by BvG » Mon Mar 07, 2011 8:05 pm

play does not accept urls. It only works with the player object. so you need to create a player object on you card, and then set the fileName of it to your mp3 url. after that you can say:

play "my previously created player"
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: MP3 playing in HTTP - does not work

Post by Klaus » Mon Mar 07, 2011 8:19 pm

Hi James,

unfortunately player objects do not exist in LC iOS!
So downloading and then playing the file might be the best solution.

Download the file to one of these folders:
specialfolderpath("cache")
specialfolderpath("temporary")


Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: MP3 playing in HTTP - does not work

Post by bn » Mon Mar 07, 2011 9:26 pm

Hi James,

I put up a file on my server. It is an audio file but plays with the following code in a button in the Simulator:

Code: Select all

on mouseUp
   if the environment is not "mobile" then exit mouseUp
   set the showController of the templateplayer to true -- block this if you don't want the controller
   play  video "http://berndniggemann.on-rev.com/movieRevlet/movie/samoashort.3gp"
end mouseUp
It is just a textToSpeech example, never mind the text.

You might have to turn your mp3 into a different format though, no idea but 3gp works.

What I did with larger files (this one is only 67 KB) is to download it the first time and then play it from a local file later on.

Kind regards

Bernd

ferrandjames
Posts: 20
Joined: Tue Mar 01, 2011 11:23 pm

Re: MP3 playing in HTTP - does not work

Post by ferrandjames » Wed Mar 09, 2011 9:34 am

Hello, thank you very much for your precious help, I'll try to understand this code, for specialfolderpath, I did not really understand how to download the file in the "temp", you have an example ....
In any case, a big thank you "Bernd" and "Klaus".

cordially

James

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: MP3 playing in HTTP - does not work

Post by bn » Thu Mar 10, 2011 12:50 am

Hi James,

I attach a very small stack that shows how to play the sound file from local storage. The button first checks if the file is locally available and if not it first retrieves the file from the server and stores it in the iOS documents folder. Then it plays the file from the local file. The script is commented to show what is going on. It is all in the "click to play movie from server" button. Never mind the 'movie' the same goes for movies. It just happens that this is a sound file.
It works in the Simulator, but I used the same technique on an iPhone.


Kind regards

Bernd
Attachments
movie from Server.livecode.zip
(2 KiB) Downloaded 309 times

keith
Posts: 1
Joined: Sun Jan 23, 2011 8:37 pm

Re: MP3 playing in HTTP - does not work

Post by keith » Wed Mar 16, 2011 1:45 am

bn
Does this save a permanent copy of the movie onto your device? If so, how do you delete these files?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: MP3 playing in HTTP - does not work

Post by bn » Wed Mar 16, 2011 8:47 am

Hi Keith,

welcome to the forum.

if you look up the specialfolderpath() in the iOS release-notes you find
• documents – the folder in which the application should store any document data (this folder is backed up by iTunes on sync)
• cache – the folder in which the application should store any transient data that needs to be preserved between launches (this folder is not backed up by iTunes on sync)
• temporary – the folder in which the application should store any temporary data that is not needed between launches (this folder is not backed up by iTunes on sync)
.... the iPhoneOS filesystem is case-sensitive
The way I set it up is to put it into "documents". If you delete the app it is gone. If you want to save it only temporarily: see above.
Or you could 'delete' the file.
You see the pathname in the script.

Kind regards

Bernd

Post Reply