Sound playback driving me crazy...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 95
- Joined: Wed Mar 30, 2011 10:15 am
Re: Sound playback driving me crazy...
I think I found the problem. This works in the sim, but not in LC:
on mouseUp
put specialFolderPath("engine") & "/Page1.wav" into tWholePath
play tWholePath
end mouseUp
This works in LC, but not in the sim:
on mouseUp
put specialFolderPath("engine") & "Page1.wav" into tWholePath
play tWholePath
end mouseUp
The difference is the "/" before the name of the sound file.
So how do we adjust our code so that it works in both?
Edit: I see you just answered that. How would we make this adjustment for all our sound files, including player objects and audioclips, rather than just for a single file?
on mouseUp
put specialFolderPath("engine") & "/Page1.wav" into tWholePath
play tWholePath
end mouseUp
This works in LC, but not in the sim:
on mouseUp
put specialFolderPath("engine") & "Page1.wav" into tWholePath
play tWholePath
end mouseUp
The difference is the "/" before the name of the sound file.
So how do we adjust our code so that it works in both?
Edit: I see you just answered that. How would we make this adjustment for all our sound files, including player objects and audioclips, rather than just for a single file?
Re: Sound playback driving me crazy...
Hi Britt,
now add a field "fAllFiles" to the card and change the code of the first button to
it gives you all the files in the folder soundFolder. From there you could play them. Just substitute the filenames in the paths. like in
Of course you would have to store tWholePath somewhere.
have a look at the comments and look up unfamiliar terms in the dictionary or ask here.
Kind regards
Bernd
now add a field "fAllFiles" to the card and change the code of the first button to
Code: Select all
on mouseUp
if the environment is "mobile" then
put specialFolderPath("engine") & "/soundFolder/samoashort.3gp" into tWholePath
play tWholePath
else
put the effective fileName of this stack into tWholePath
put tWholePath
set the itemdelimiter to "/"
put "/soundFolder/samoashort.3gp" into last item of tWholePath
-- get a list of all files in the "soundFolder" folder
put the defaultFolder into tOldDefaultFolder -- store the defaulfFolder
set the defaultFolder to item 1 to -2 of tWholePath
put the files into tAllFilesOfTheFolder
filter tAllFilesOfTheFolder without ".*" -- filter out invisible system files that start with .
put tAllFilesOfTheFolder into field "fAllFiles"
set the defaultFolder to tOldDefaultFolder -- lets be nice and restore the defaultFolder
set the filename of player "p1" to tWholePath
start player "p1"
end if
end mouseUp
Code: Select all
set the itemDelimiter to "/"
put line xyz of field "fAllfiles" into last item of tWholepath
have a look at the comments and look up unfamiliar terms in the dictionary or ask here.
Kind regards
Bernd
-
- Posts: 95
- Joined: Wed Mar 30, 2011 10:15 am
Re: Sound playback driving me crazy...
I don't understand much of that yet, but I will try to.
I tried this for an individual file:
on openCard
if the environment is "mobile" then
put specialFolderPath("engine") & "/Page1.wav" into tWholePath
else
put specialFolderPath("engine") & "Page1.wav" into tWholePath
end if
set the filename of player "Narration" to tWholePath
play player "Narration"
end openCard
It worked in LC, but not in the sim. Any ideas why?
I tried this for an individual file:
on openCard
if the environment is "mobile" then
put specialFolderPath("engine") & "/Page1.wav" into tWholePath
else
put specialFolderPath("engine") & "Page1.wav" into tWholePath
end if
set the filename of player "Narration" to tWholePath
play player "Narration"
end openCard
It worked in LC, but not in the sim. Any ideas why?
Re: Sound playback driving me crazy...
Hi Britt,
are you shure iOS supports wav? I just tried a .wav file and it did not play in the simulator.
Why don't you try an 3gp file. Then you know with the script I provided that they work in both environments. You get your paths straight and then tackle the sound format problem.
Kind regards
Bernd
are you shure iOS supports wav? I just tried a .wav file and it did not play in the simulator.
Why don't you try an 3gp file. Then you know with the script I provided that they work in both environments. You get your paths straight and then tackle the sound format problem.
Kind regards
Bernd
Re: Sound playback driving me crazy...
Hey Bernd,
Sorry for the pause between posts.
I have quite a mystery for you. I have been going crazy trying to figure out how to make sound happen in my app. After a couple days I came back to forums and decided to covert my .aiff file to 3gp and that didn't work, or so I thought. Well I knew that your stack worked after I tried it so I copied my button to your stack and entered in the correct path. Well I put it in the simulator and IT WORKED. But I double checked my paths in my app and they were the same but mine wasn't playing in the sim. Once I got the right path I didn't change it.
Do you know why that would be happening? I feel so close but I think it might be something really simple.
Thanks,
Danny
Sorry for the pause between posts.
I have quite a mystery for you. I have been going crazy trying to figure out how to make sound happen in my app. After a couple days I came back to forums and decided to covert my .aiff file to 3gp and that didn't work, or so I thought. Well I knew that your stack worked after I tried it so I copied my button to your stack and entered in the correct path. Well I put it in the simulator and IT WORKED. But I double checked my paths in my app and they were the same but mine wasn't playing in the sim. Once I got the right path I didn't change it.
Do you know why that would be happening? I feel so close but I think it might be something really simple.
Thanks,
Danny
Re: Sound playback driving me crazy...
Danny,
could you post your code?
Since scripts can fail silently on iOS/Simulator it is a good idea to add a temporary field to the card(s) called "fErr"
In the stack script you put a handler
if there is anything in the field then you know something is going wrong with your scripts. The error message is not all that clear but it gives you an idea.
Try this and see if another error is preventing the script to run in your app.
Kind regards
Bernd
could you post your code?
Since scripts can fail silently on iOS/Simulator it is a good idea to add a temporary field to the card(s) called "fErr"
In the stack script you put a handler
Code: Select all
on errorDialog
put the params into field "fErr"
end errorDialog
Try this and see if another error is preventing the script to run in your app.
Kind regards
Bernd
Re: Sound playback driving me crazy...
Hey Bernd,
Fortunately and unfortunately there were no errors. I'm really stumped.
This is the code in my button. This DOES work in your stack.
And here are some screen shots of the paths.
The first one is in "Copy Files" of your stack and the other is my stack (I used your button to test my app but that didn't work either)
I did notice that I seemed to get different paths on different stacks so that might be the case but I wasn't able to get identical paths. Your stack and my button played in the simulator but not in LC. That doesn't bother me at all I just wasn't sure if that would be a clue.
Thanks,
Danny
Fortunately and unfortunately there were no errors. I'm really stumped.
This is the code in my button. This DOES work in your stack.
Code: Select all
on mouseUp
put specialFolderPath("engine") & "/Sound/Bite.3gp" into tWhole
play tWhole
end mouseUp
The first one is in "Copy Files" of your stack and the other is my stack (I used your button to test my app but that didn't work either)
I did notice that I seemed to get different paths on different stacks so that might be the case but I wasn't able to get identical paths. Your stack and my button played in the simulator but not in LC. That doesn't bother me at all I just wasn't sure if that would be a clue.
Thanks,
Danny
- Attachments
-
- Screen shot 2011-03-30 at 11.18.18 PM.png (8.8 KiB) Viewed 8747 times
-
- Screen shot 2011-03-30 at 11.17.05 PM.png (9.3 KiB) Viewed 8747 times
Re: Sound playback driving me crazy...
Hi Britt and all,
and returns NOTHING (= EMPTY) in the desktop version/IDE!
And no error fortunately!
That means that:
...
put specialFolderPath("engine") & "Page1.wav" into tWholePath
...
will result in: Page1.wav
in the IDE! That's why this does work in the IDE!
Now if this does not work in the sim, then it might be a sound format problem,
as Bernd already pointed out.
P.S.
Seeing is believing so I heavily recommend to let you ANSWER your variables
that do not work as exspected!
Best
Klaus
specialfolderpath("engine") is "specially" designed for Mobile operating systemsBrittgriscom wrote:It worked in LC, but not in the sim. Any ideas why?Code: Select all
on opencard if the environment is "mobile" then put specialFolderPath("engine") & "/Page1.wav" into tWholePath else put specialFolderPath("engine") & "Page1.wav" into tWholePath end if set the filename of player "Narration" to tWholePath play player "Narration" end openCard
and returns NOTHING (= EMPTY) in the desktop version/IDE!
And no error fortunately!
That means that:
...
put specialFolderPath("engine") & "Page1.wav" into tWholePath
...
will result in: Page1.wav
in the IDE! That's why this does work in the IDE!
Now if this does not work in the sim, then it might be a sound format problem,
as Bernd already pointed out.
P.S.
Seeing is believing so I heavily recommend to let you ANSWER your variables
that do not work as exspected!
Code: Select all
on opencard
if the environment is "mobile" then
put specialFolderPath("engine") & "/Page1.wav" into tWholePath
else
put specialFolderPath("engine") & "Page1.wav" into tWholePath
end if
ANSWER tWholePath
## now you can see the content of tWholePath!
## GUESSING is no replacement for debugging!
set the filename of player "Narration" to tWholePath
play player "Narration"
end openCard
Best
Klaus
Re: Sound playback driving me crazy...
@Danny,
what version of Livecode are you using?
There is a bug in pre 4.6 in Livecode that puts a ASCII 202 into text/code copied from e.g. this forum when on a Mac. If you have copy/pasted code from various sources it just maybe that this one caught you.
The code will work in the IDE/Livecode but will fail on the Simulator/iOS device.
In 4.6 the ASCII 202 is still there but does not stop the code from working in iOS. Bug#9433
The remedy is to either paste the text into a texteditor like the free TextWrangler and do a convert to ASCII there and copy it back into the ScriptEditor. In TextWrangler you can also display hidden characters and you could tell if there are stray characters in the spaces to the left of the code.
Alternatively you could retype the pasted code in the ScriptEditor.
if you want to you can send me your stack and I will have a look at it if I can find anything in particular.
make a button and set the script of that button to:
it will put the address into the message box
Kind regards
Bernd
what version of Livecode are you using?
There is a bug in pre 4.6 in Livecode that puts a ASCII 202 into text/code copied from e.g. this forum when on a Mac. If you have copy/pasted code from various sources it just maybe that this one caught you.
The code will work in the IDE/Livecode but will fail on the Simulator/iOS device.
In 4.6 the ASCII 202 is still there but does not stop the code from working in iOS. Bug#9433
The remedy is to either paste the text into a texteditor like the free TextWrangler and do a convert to ASCII there and copy it back into the ScriptEditor. In TextWrangler you can also display hidden characters and you could tell if there are stray characters in the spaces to the left of the code.
Alternatively you could retype the pasted code in the ScriptEditor.
if you want to you can send me your stack and I will have a look at it if I can find anything in particular.
make a button and set the script of that button to:
Code: Select all
on mouseUp
put "110,105,103,103,101,109,97,110,110,64,117,110,105,45,119,104,46,100,101" into tData
set the itemDelimiter to ","
repeat with i = 1 to the number of items of tData
put numToChar (item i of tData) after tOut
end repeat
put tOut
end mouseUp
Kind regards
Bernd
Re: Sound playback driving me crazy...
I'm running the 4.6 public release. I sent you the stack.
Thanks,
Danny
Thanks,
Danny
Re: Sound playback driving me crazy...
So thanks to Bernd, I figured out what was going on with my app. I have two Main Stacks and I had only added the sound file to one of the two because I thought didn't have to. Well I did need to and once I did it was working like a champ. The 3gp format does lower the sound quality (to me personally) quite a bit, but use it until you have it working and then experiment with other formats.
I hope this will help you out. Let me know if you have any questions and i'll answer them to the best of my ability.
Danny
I hope this will help you out. Let me know if you have any questions and i'll answer them to the best of my ability.
Danny
Re: Sound playback driving me crazy...
Have you tried the .ogg format? Most AppStore apps use it in their apps.
-
- Posts: 95
- Joined: Wed Mar 30, 2011 10:15 am
Re: Sound playback driving me crazy...
Code: Select all
on mouseUp
if the environment is "mobile" then
put specialFolderPath("engine") & "/soundFolder/samoashort.3gp" into tWholePath
-- Why doesn't this work?
-- set the fileName of player "p1" to tWholePath
-- start player "p1"
play tWholePath
answer tWholePath
else
Edit: play player "p1" doesn't work either
Re: Sound playback driving me crazy...
Britt,
it does not work because the iOS does not use a player object to play sounds.
Please have a look at the iOS Release Notes under the Help menu.
change your code to
and the stopPlay button to
make shure you have a player named "p1" on the card
Now the samoashort.3gp file plays in Livecode and the Simulator.
Kind regards
Bernd
it does not work because the iOS does not use a player object to play sounds.
Please have a look at the iOS Release Notes under the Help menu.
change your code to
Code: Select all
on mouseUp
if the environment is "mobile" then
put specialFolderPath("engine") & "/soundFolder/samoashort.3gp" into tWholePath
-- Why doesn't this work?
-- set the fileName of player "p1" to tWholePath
-- start player "p1"
play tWholePath
answer tWholePath
else
put the effective filename of this stack into tPathToMe -- this gets the path to this stack
set the itemdelimiter to slash
delete last item of tPathToMe -- delete the name of the stack
-- put the folder and file path after the path to the stack. Only works if the folder is at the same level as the stack
put tPathToMe & "/soundFolder/samoashort.3gp" into tWholePath
set the fileName of player "p1" to tWholePath
start player "p1"
end if
end mouseUP
Code: Select all
on mouseUp
if the environment is "mobile" then
play empty
else
stop player "p1"
end if
end mouseUp
Now the samoashort.3gp file plays in Livecode and the Simulator.
Kind regards
Bernd
-
- Posts: 95
- Joined: Wed Mar 30, 2011 10:15 am
Re: Sound playback driving me crazy...
So then I can't do callbacks? How do I highlight the words of my storybook app as they are read?