Introduction

You can play sounds and videos in your PsyToolkit surveys. There are many ways to choose options. For example, it is possible that people can only listen/view a sound/video only one time.

People often ask about the option to have autoplay. Autoplay of sounds and videos is generally not recommended in browsers. People just do not like to get on a website and all of a sudden they hear a sound or watch a video. This can, for example, disrupt other people in the room. Some browsers allow this on the condition that the sound is off, which is then again not really autoplay (because the sound would still need to be switched on and that makes it just more complicated for participants). Therefore, PsyToolkit does not offer this option.
You can upload small audio files on the PsyToolkit server. Larger audio files and all video files need to be uploaded on a separate server. PsyToolkit recommends the Google Drive, this works really well and gives you fast sound/video file access. Below you will learn how to do this.

Audio/Sound

You can have one or more sounds (i.e, audio tracks) above each question. For this we use the a: option in the question description. See also main documentation.

What sound format to use

It is strongly recommended you use compressed sound files. The most common compressed audio format is the well known MP3. Uncompressed files such as WAV take much more bandwidth and will take more loading time for participants.

How to upload a sound file to PsyToolkit

You can put sound files on the PsyToolkit server or alternatively on another server, such as Google Drive and Dropbox. If you have large files, Google Drive is recommended because it is easiest to use (see tips below).

Here is what you do:

  1. Go to your survey.

  2. Click on the "Upload files (images or audio files)" button underneath the scripting area

  3. Select the audio file on your computer from your local hard drive.

  4. Click the "Save" button.

  5. Now your file is being uploaded (you can double check with the "view files" button)

How to add the audio to your question

This is very easy to do. Just add a line starting with *a:" and then add in that line the name of the audio file (including its extension, such as mp3).

The "a:" is used because "a" is the first letter of "audio".

The following example assumes you have uploaded a sound file called piano_sound.mp3

l: my_question
a: piano_sound.mp3
t: radio
q: What do you think of this music?
- I like it a lot
- I neither like it nor dislike it
- I do not like it

How to have more than one audio track in your question

You can have more than one audio file. In that case, you get multiple audio players. Participants can then play then one after another, and for example, decide which sound they like best.

The following example assumes you have uploaded a sound file called piano_sound.mp3

l: my_question
a: piano.mp3 violin.mp3 organ.mp3
t: radio
q: Which of the sounds did you like best?
- The piano
- The violin
- The organ

How to play a sound only one time

Sometimes, researchers want to play a sound only one time. They do not want that the participant can listen to the sound more than once. This is quite common in studies, and there is a simple option line you can add to your question.

l: my_question
a: piano.mp3
o: no_sound_replay
t: radio
q: Listen to the sound and tell us if which pitch the tone was
- C sharp
- C minor
- Somthing else

How to play a sound from my Google Drive

For this, you first need to setup a Google account. The Google Drive is place where you can store uploaded files, and the access to it is quite fast and easy to use.
  1. Upload the sound file to your Google Drive

  2. In your Google Drive, right clock on the file name and select share (and not get shareable link). If you do that, you get a little "Share with others" popup window.

  3. In this popup window, now click Get sharable link (in the top-right corner of the pop-up window) and then you see a long web link. Just leave it to Anyone with the link can view. Then you click Copy link

  4. In your question, write a: followed by a space and then paste the link

  5. Now it should look like something like the question below

The format of the link must be somewhat like the one in the example below. It starts with https://drive.google.com/ followed by something like /file/d/ (or another letter), a long number, then ended by _/view
In step 2 above, it would be wrong to already there to choose get sharable link, because then it will give you a link in a different format that does not work with PsyToolkit. So make sure to follow the 5 steps exactly in that order.
l: testquestion
t: radio
a: https://drive.google.com/file/d/1oHhasFAFZdkadakdlJsjXasJ/view?usp=sharing
o: no_sound_replay
q: Play the sound and say whether you like it
- Like it
- Don't like it
- No opinion

How to play a sound from DropBox

For this, you first need to setup a Dropbox account.

Take these steps:

  1. Upload your soundfile to your Dropbox account.

  2. In Dropbox, you see a list of your files, click the Share button for the uploaded sound file

  3. Select the "Share a link" options and "Copy link"

  4. In your PsyToolkit survey script, write "a:" and then paste the link.

  5. At the end, replace the dl=0 with raw=1 (this is super important)

  6. It should now look like something like below

l: testd
t: radio
a: https://www.dropbox.com/s/frwz3v2xddsdadjhh/myfile.wav?raw=1
q: Play the sound and say whether you like it
- Like it
- Don't like it
- No opinion

How to play a sound again and again (loop)

Simply add the line o: loop to your question and it will play again and again.

l: mysound
t: radio
a: https://www.dropbox.com/s/frwz3v2xddsdadjhh/myfile.wav?raw=1
o: loop
q: Play the sound and say whether you like it
- Like it
- Don't like it
- No opinion

Video

This specific lesson is not about YouTube videos. They are handled differently and there is a separate lesson about that.

You can have one or more videos files above each question. For this we use the a: option in the question description. See also main documentation.

Why can I not upload a video file to PsyToolkit?

This is not possible, because video files are too big and this is actually not necessary. Instead of uploading a video to PsyToolkit, you can use video files stored on other servers. Below you see how you can easiliy play a video from your Google Drive within PsyToolkit.

How to have more than one video track in your question

You can simply have multiple videos. This is unlikely an often used feature, but if you need it, it can be done.

How to play a video only one time

Choose the video_no_replay option in a question to make sure people can only play a video one time. It is the line o: no_video_replay

l: my_video_question
v: https://drive.google.com/file/d/1842323jsdxrandomXJs/view?usp=sharing
o: no_video_replay
t: radio
q: What do you think of this movie?
- I like it a lot
- I neither like it nor dislike it
- I do not like it

How to make the video larger

Your video will have the size you uploaded in. Thus, if your uploaded video is 2000 pixels wide, it will be shown like that. You can easily change the width of the video player area. You do this by adding a o: video_width line which should include the width in pixels.

Note that the height is automatically changed when you change the width. The video will keep its aspect ratio.

Note that in questions you can have multiple o: lines, as the example below also shows.
l: my_video_question
v: https://drive.google.com/file/d/1842323jsdxrandomXJs/view?usp=sharing
o: video_width 800
o: no_video_replay
t: radio
q: What do you think of this movie?
- I like it a lot
- I neither like it nor dislike it
- I do not like it

How to play a video from my Google Drive

For this, you first need to setup a Google account.

For this, you need to do the following:

  1. Upload a video file (ideally mp4 or webm) to your Google Drive.

  2. In your Google Drive, right clock on the file name and select "share". If you do that, you get a little "Share with others" popup window.

  3. In this popup window, select Get sharable link and then you see a long web link. Just leave it to Anyone with the link can view. Then you click Copy link

  4. Now in your survey, make sure you add to your question a line starting with v: * (don’t forget the space after the *:, that is really necessary). The paste the shared link from your Google drive here (right click and select paste, or type control-v).

That is all you need. Such a question can look, for example, like this:

l: my_video_question
v: https://drive.google.com/file/d/1842323jsdxrandomXJs/view?usp=sharing
t: radio
q: What do you think of this movie?
- I like it a lot
- I neither like it nor dislike it
- I do not like it

How to play a video from DropBox

For this, you first need to setup a Dropbox account.Take these steps:
  1. Upload your video file to your Dropbox account.

  2. In Dropbox, you see a list of your files, click the Share button for the uploaded video file

  3. Select the "Share a link" options and "Copy link"

  4. In your PsyToolkit survey script, write "a:" and then paste the link.

  5. At the end, replace the dl=0 with raw=1 (this is super important)

  6. It should now look like something like below

l: testd
t: radio
v: https://www.dropbox.com/s/ewqeJlPrwz3v2xddsdadjhh/myfile.wav?raw=1
q: Play the video and say whether you like it
- Like it
- Don't like it
- No opinion

How to play a video again and again (loop)

Simply add the line o: loop to your question and it will play again and again (the same function is also available for audio, see example there).

YouTube video

Alternative to the video examples above, you can use YouTube videos. YouTube is a popular video streaming platform owned by Google. You can use existing videos that you might want to include in your study.

The disadvantage of YouTube videos is that they often come with advertisements and suggestions for other videos and so on — that is a lot of distraction you do not always want in your psychological study.

There are two ways to include a YouTube video.

Method 1

There is a YouTube question type. There is a separate lesson about that).

Method 2

Each question time can include a YouTube video by including a y: line. The letter number code is the ID of the YouTube video. See the separate YouTube lesson to learn how to find that code.

l: testd
t: radio
y: Lq8bpo9KWa8
q: Play the video and say whether you like it
- Like it
- Don't like it
- No opinion