Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Audio file doesn't stop after keypress

Hello!

I want participants in my experiment to listen to a long-ish audio file so they can adjust the audio volume to a comfortable level. I would like the file to stop playing once they hit a key, and then have them move on to the experiment. I tried setting the duration of the sampler to keypress, but that didn't work as expected, the file continued to play. Is there another way to achieve this or a better way of allowing them to test and adjust the volume? I can't use Python as I'm planning to run the experiment online.

Thanks in advance!

Comments

  • Hi @sflu,

    Indeed, the sampler's keypress or mouseclick end event is not operational when you run the experiment in the browser. This makes it a little tricky to stop a actively sound, but I could think of at least one way around that problem. It does require that you store your sound file on a server that allows cross-origin resources sharing (CORS). Github does so, so you could create an account there (if you don't already have one), upload your long sound file there, and then identify the URL to the raw file.

    Once you have that set up, you can use some Javascript code to load up the sound, start it and stop it whenever you want (for example when the subject presses a key).

    Pay special attention to placing the code loading up the sound under the prepare tab of the inline_javascrpt:

    Code:

    vars.mysound = new Audio('https://www.bensound.com/bensound-music/bensound-moose.mp3')
    

    You'd have to replace the URL by that corresponding to your sound.

    Then, to play the sound:

    vars.mysound.play()
    

    And to stop it:

    vars.mysound.pause()
    

    If you only need to play the long sound at the beginning so that the subjects adjust their sound level, that should work. You can then use the sampler for the shorter sounds you may use in your task trials.

    Another option would be to provide your participants with a link to the sound file and ask them to download it, play it, adjust the sound level, and then to click on a separate link where you'd have your experiment. Just another way for them to calibrate the sound level before they do your task.

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • Hi @Fab,

    Thanks, I will try out the Github method! I was also wondering about the Break if statement in the loop. Could I add something like Break if [response] = space so that they would then exit the loop upon pressing the space bar?

  • Hi @sflu,

    You could try that method, but the "Break if" method runs full trials and then examines whether the loop should be interrupted. So if you have a long sound, pressing a key would not stop the sound right away. If you want to use a shorter sound that gets repeated many times, you could use that method and program some condition to break the loop. try it out and you'll quickly see whether that works for you.

    Best,

    Fabrice.

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games