PennController for IBEX › Forums › Support › Audio stimuli don't play on phones
- This topic has 14 replies, 2 voices, and was last updated 3 years, 4 months ago by AlexY.
-
AuthorPosts
-
April 29, 2021 at 12:40 pm #6896AlexYParticipant
Hi,
I created an experiment where participants need to click a button to listen to an audio stimulus. I tried it out on desktop/laptop computer and it worked. However, when I tried to do the experiment with my phone or ipad, the audio just didn’t play: I was able to move forward by clicking the button, it’s just that there was no audio.
Below is the code I used to create the button:
newAudio("py22", "py22.wav") .print() .remove() , newButton("click") .callback(getAudio("py22").play()) .print() .wait()
P.S. I tried to flip the order the
- This topic was modified 3 years, 4 months ago by AlexY.
April 29, 2021 at 1:07 pm #6900AlexYParticipantI don’t know how to edit my post but I meant to add that I flipped the order of the two commands and it’s still the same: ok on desktop or laptop but not ok on phone/ipad.
There are also instructions before and after the audio is played.
Thanks!
April 29, 2021 at 1:48 pm #6901JeremyKeymasterHi,
It does play the sound file on my Android phone. Did you try it on an iPhone?
Also, I don’t know if you have more commands in your trial after that last
wait
command, but if you don’t, then you should not hear the audio: in that case, the behavior on your phone/ipad would turn out to be the correct one.I’m not sure why you print and then immediately remove the Audio element, and then make it play as a callback. Wouldn’t this purely linear code achieve what you need?
newButton("click") .print() .wait() .remove() , newAudio("py22","py22.wav") .play() .wait()
Jeremy
April 29, 2021 at 2:58 pm #6902AlexYParticipantThanks, Jeremy! For each trial, after listening to the stimulus, they will have to choose an answer. The reason why I used the callback function is because they can listen to the stimulus again before they choose an answer. With the linear code, it seems that the stimulus could only be played once. And I want the screen to have just the “click” button. If I don’t use the remove function, the audio bar also appears.
Is there a way for me to get around this?
April 29, 2021 at 3:08 pm #6903JeremyKeymasterOK, if you want to allow replay, then the
callback
method is indeed the appropriate one. If you don’t want the bar to appear, just don’t print it at all, as in the linear code. You would get:newButton("click") .callback(newAudio("py22.wav").play()) .print() .wait() , // additional code waiting for a selection
Does you experience the original problem (the audio not playing) only with an iPhone/iPad, or do you also experience it with, say, Android smartphones? Feel free to share your project with me so I can troubleshoot the issue
Jeremy
April 29, 2021 at 3:55 pm #6904AlexYParticipantThank you so much for your prompt reply, Jeremy!
I tried it on my iphone and ipad and neither worked. I used the code you suggested and I still wasn’t able to listen to the audio clip. I haven’t tried it on any android devices, though.
How do I share my project with you? Should I download the standalone version and send it to admin@pcibex.net?
April 29, 2021 at 4:03 pm #6905JeremyKeymasterOK, I’ll try to find an iphone to try it out myself
Are you using the PCIbex Farm at https://farm.pcibex.net? There is a “Share” option in the project’s right menu, then you can copy-paste the project’s demonstration link
Jeremy
April 29, 2021 at 4:08 pm #6906April 29, 2021 at 5:31 pm #6907JeremyKeymasterThe problem seems to have to do with how Safari requests audio and video files, and how the PCIbex Farm responds to those requests. I might be able to fix the issue, but I’d need to update the farm, which I don’t want to do too often (it comes with the risk of making the servers, and so data-collection, temporarily unavailable)
If you have access to an alternative storage space (eg. an s3 bucket, or a webserver) where you can host your audio files, I’d suggest you do that, and hopefully the problem should go away
Apologies for the inconvenience
Jeremy
April 29, 2021 at 6:37 pm #6908AlexYParticipantThanks, Jeremy! I will relocate my audio files.
May 1, 2021 at 11:20 pm #6915AlexYParticipantMay 2, 2021 at 7:42 pm #6916JeremyKeymasterHi,
Your zip file is not publicly accessible at all: if I try to open its URL in my browser manually, I get an “Access Denied” error
You need to expose your file, which means that your bucket should not block all public access, and your object should be readable by the public, as on this image for example:
Jeremy
May 2, 2021 at 9:10 pm #6917AlexYParticipantThanks, Jeremy! I changed the settings to make my file publicly accessible, but the audio still doesn’t play here.
May 3, 2021 at 11:33 am #6919JeremyKeymasterHi,
As I said in this message:
I don’t know if you have more commands in your trial after that last
wait
command, but if you don’t, then you should not hear the audioThe experiment at the link you shared works exactly as expected: the audio file is properly preloaded from the zip file, the first trial is instantaneous (the
play
command is executed but the trial ends immediately so it moves on to the second one) and the second trial waits for a click on the button to execute theplay
command but once again the trial ends immediatelyIf I add
getAudio("py55").wait("first")
at the end of your second trial I do hear the audio play backJeremy
May 3, 2021 at 3:28 pm #6921AlexYParticipantOh it actually worked. It’s strange because when I was previewing the experiment, the loading time was very long and I couldn’t hear anything even after adding the command you suggested. But when I clicked the demo link, I could hear the audio.
Thank you so much Jeremy, really appreciated it 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.