Audio stimuli don't play on phones

PennController for IBEX Forums Support Audio stimuli don't play on phones

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #6896
    AlexY
    Participant

    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 2 years, 12 months ago by AlexY.
    #6900
    AlexY
    Participant

    I 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!

    #6901
    Jeremy
    Keymaster

    Hi,

    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

    #6902
    AlexY
    Participant

    Thanks, 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?

    #6903
    Jeremy
    Keymaster

    OK, 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

    #6904
    AlexY
    Participant

    Thank 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?

    #6905
    Jeremy
    Keymaster

    OK, 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

    #6906
    AlexY
    Participant

    Here is the link. Thank you so much again!

    #6907
    Jeremy
    Keymaster

    The 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

    #6908
    AlexY
    Participant

    Thanks, Jeremy! I will relocate my audio files.

    #6915
    AlexY
    Participant

    Hi Jeremy,

    I put the audio files to amazon s3 bucket and I included the rules mentioned here. I was just testing it here but the audio file wouldn’t play again. Is it because of the security settings on the s3 bucket?

    #6916
    Jeremy
    Keymaster

    Hi,

    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: Config of an S3 object that the public can read

    Jeremy

    #6917
    AlexY
    Participant

    Thanks, Jeremy! I changed the settings to make my file publicly accessible, but the audio still doesn’t play here.

    #6919
    Jeremy
    Keymaster

    Hi,

    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 audio

    The 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 the play command but once again the trial ends immediately

    If I add getAudio("py55").wait("first") at the end of your second trial I do hear the audio play back

    Jeremy

    #6921
    AlexY
    Participant

    Oh 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 🙂

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.