MP3 playing in HTTP - does not work
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 20
- Joined: Tue Mar 01, 2011 11:23 pm
MP3 playing in HTTP - does not work
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
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
Need more information to know where to begin.
Thanks,
Todd
-
- Posts: 20
- Joined: Tue Mar 01, 2011 11:23 pm
Re: MP3 playing in HTTP - does not work
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
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
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"
play "my previously created player"
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: MP3 playing in HTTP - does not work
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
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
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:
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
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
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
-
- Posts: 20
- Joined: Tue Mar 01, 2011 11:23 pm
Re: MP3 playing in HTTP - does not work
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
In any case, a big thank you "Bernd" and "Klaus".
cordially
James
Re: MP3 playing in HTTP - does not work
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
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 310 times
Re: MP3 playing in HTTP - does not work
bn
Does this save a permanent copy of the movie onto your device? If so, how do you delete these files?
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
Hi Keith,
welcome to the forum.
if you look up the specialfolderpath() in the iOS release-notes you find
Or you could 'delete' the file.
You see the pathname in the script.
Kind regards
Bernd
welcome to the forum.
if you look up the specialfolderpath() in the iOS release-notes you find
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.• 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
Or you could 'delete' the file.
You see the pathname in the script.
Kind regards
Bernd