Page 1 of 1
MP3 playing in HTTP - does not work
Posted: Wed Mar 02, 2011 4:04 pm
by ferrandjames
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 ...
Re: MP3 playing in HTTP - does not work
Posted: Sat Mar 05, 2011 11:17 pm
by ctflatt
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
Re: MP3 playing in HTTP - does not work
Posted: Mon Mar 07, 2011 6:32 pm
by ferrandjames
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
Re: MP3 playing in HTTP - does not work
Posted: Mon Mar 07, 2011 8:05 pm
by BvG
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"
Re: MP3 playing in HTTP - does not work
Posted: Mon Mar 07, 2011 8:19 pm
by Klaus
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
Re: MP3 playing in HTTP - does not work
Posted: Mon Mar 07, 2011 9:26 pm
by bn
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
Re: MP3 playing in HTTP - does not work
Posted: Wed Mar 09, 2011 9:34 am
by ferrandjames
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
Re: MP3 playing in HTTP - does not work
Posted: Thu Mar 10, 2011 12:50 am
by bn
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
Re: MP3 playing in HTTP - does not work
Posted: Wed Mar 16, 2011 1:45 am
by keith
bn
Does this save a permanent copy of the movie onto your device? If so, how do you delete these files?
Re: MP3 playing in HTTP - does not work
Posted: Wed Mar 16, 2011 8:47 am
by bn
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