Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

Autoplay Audio Files Using Loop and Merge

sreisma1
sreisma1 Community Member - Trial User Qubie ✭
edited April 22 in Custom Code

Hello,

I am running an experiment where I need audio files to autoplay without a participant being able to fast forward, rewind, pause, etc. (I.e., autoplay, autostart, no controls). This files need to be randomized, so I am using the loop and merge function. Here is the code I am using:

<center>
<div>
<audio autoplay class=“qmedia” controls=“true” height=“40” preload=“auto” width=“320” autostart=“true” autoplay=“true” loop=“false” ><source src=“${lm://Field/1}” “=”" type=“audio/mp3”>
<center>
<div></div></center></audio></div></center>

This code does not work - the audio files will randomly appear, but I am able to pause/play, move around the progress bar, and they do not start playing automatically.

My colleague has used the below code for her video files, which autoplays the videos without the participant being able to manipulate them.

<center>
<div>
<div style="height=480px;width=288px;pointer-events:none;"><iframe height="480" src="${lm://Field/1}" style="border:none;" width="288"></iframe></div>
</div>
</center>

When I try and adapt it for audio files, it still doesn't work.

 
<center>
<div>
<div style="height=40";width=320";pointer-events:none;"><iframe height="40" src="${lm://Field/1}" style="border:none;" width="320"></iframe></div>
</div>
</center>

I could really use some help. Thanks in advance!

Tagged:

Best Answer

  • sreisma1
    sreisma1 Community Member - Trial User Qubie ✭
    Accepted Answer

    Thank you! the pointer events disable command helped. The above did not autoplay, however when I added autoplay = "true" it worked perfectly. Thanks!

    Final below for those curious:

    <center>
        <div>
            <audio controls autoplay class="qmedia" style="pointer-events: none" autoplay="true">
                <source src="${lm://Field/1}" type="audio/mp3" />
                <center>
                    <div></div>
                </center>
            </audio>
        </div>
    </center>
    


Answers

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭
    edited April 15

    Try this:

    <center>
        <div>
            <audio controls autoplay class="qmedia" style="pointer-events: none">
                <source src="${lm://Field/1}" type="audio/mp3" />
                <center>
                    <div></div>
                </center>
            </audio>
        </div>
    </center>
    


    You can delete controls="true" to remove the controls from the display, however, since its an audio file, you won't see anyhting. That's why add pointer-events:none to disable clicks.