Howdy, Stranger!

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

Supported by

playing audio in javascript: cannot load files in the file pool

Hello OSWeb community,

We want to play two sounds simultaneously using Javascript. Sound 1 plays first and sound 2 plays 500ms later on top of sound 1.

The codes are something like the following:

var audio1 = new Audio('audiofile1.wav');

var audio2 = new Audio('audiofile2.wav');

audio1.play();

setTimeout(() => {audio2.play();}, 500);

The audio clips only play if they are placed in Users\user\AppData\Local\Temp, even though they do exist in the file pool. This is not a viable solution if the script is hosted on JATOS as the audio files need to be hosted on the server.

Perhaps in the javascript, one needs to refer to the audio files in a different way (in the file pool) than just the file names alone?

Any suggestions? (PS: coroutines with two samplers does not work and Javascript seems the way to go).

Many thanks!

Bo

Comments

  • Hi Bo,

    would it help to specify the complete filepath to the pool? Or first retrieve to path of the pool and then use it to list items in it?

    Eduard

    Buy Me A Coffee

  • Hi @eduard ,

    Thank you for your reply! Do you happen to know the complete filepath to the pool if the experiment is implemented in OSWeb and hosted on JATOS? I don't know where to find that information.

    Many thanks,

    Bo

  • Hi Bo,

    You can try this code in a javascript inline item:

    vars.pool = vars.pool.__folder__
    console.log(vars.pool)
    

    I only tried it locally though. Not sure whether it would work on Jatos.

    Let me know if it doesn't work.


    Eduard

    Buy Me A Coffee

  • Hi @boyao,

    Perhaps in the javascript, one needs to refer to the audio files in a different way (in the file pool) than just the file names alone?

    That's right, only using file names alone definitely will not work. What you are asking for now is not officially supported and untested by me, but you could try to retrieve the location of a file using

    this.experiment.pool['<filename>']
    

    in an inline_javascript item. In similar vein,

    this.experiment.pool.files()
    

    should provide a list with all files and their paths currently in the filepool. Again, I haven't tried this myself so you are flying dark here. It is always helpful to check the source code of osweb to get an idea of what's possible (see https://github.com/smathot/osweb/blob/1.3/src/js/osweb/classes/file_pool_store.js for the file store for instance).

    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