====== Media Files in Questionnaires (Audio, Video, Documents) ======

Online questionnaires distinguish themselves from printed questionnaires, according to the methodological literature, because, among other things, they can incorporate audiovisual material. Few research projects currently make the effort to produce media content, but if you would like to include a document (such as a PDF), an audio file or a video in your questionnaire, this chapter will help you do so.

**Important:** Most media files (images, music, sounds, videos, and texts) are subject to the copyright. That means, you __must not__ publish (e.g., upload) or modify these files without a written consent by the copyright owners. This as well applies to materials, that can be consumed free of charge (e.g., YouTube videos) and to materials modified by you (e.g., cutted videos). In case of a copyright infringement you risk an expensive cease-and-desist order (costs a few hundret or some thousand Euros) and deletion of the uploaded files during data collection.

**Note:** Pictures in internet-appropriate formats (see [[images|Images]]) can be uploaded in the standard way at www.soscisurvey.de. Due to frequently lacking awareness of copyright violations, the server administrator must first approve uploaded media files.

**Important:** If your questionnaire makes use of media files, inform your participants of this fact as early as possible. E.g., you could point it out in the questionnaire invitation or next to the questionnaire link, so participants won’t begin the questionnaire in an inappropriate environment, such as an open-space office or the subway, and then have to abort at the video. As a control, you can also include a short video or audio file on the first or second questionnaire page, so participants will prepare their headphones or speakers early.


===== Uploading media files =====

While questions and tests are saved directly to a database, [[images|images]] and media files must first be uploaded as separate files to a host server (Images and Media Files in the menu). There are two things to keep in mind when doing so:

  - The files must be saved in an appropriate format. There are countless document formats (e.g. PDF, DOC, DOCX, ODT, TXT, RTF for text documents alone), but only very few are suitable for use in online questionnaires. Aside from the file size, a crucial factor is that all participants must be able to open the document – particularly with proprietary formats (e.g. Word DOC, Windows AVI, etc.), this is often not the case. 
  - By uploading, you are publishing the file on the internet, universally accessible to everyone. This is only permitted if you hold usage rights for the contents. This starts with text copyrights, extends to composition and performance in a piece of music, and extends well beyond the image rights for pictures and videos. If any persons are represented in the material, confidentiality rights must be respected as well. In short: Any time outside material (even as background music or only in excerpts) or representations of persons are used, written permission is required. Otherwise, a written reprimand may be issued. This can cost between several hundreds and multiple thousands or Euros.

**Note:** Capitalisation is critical in internet content. Uploading the file “Document.pdf” and then linking the file “document.pdf” will lead to errors. 


===== Linking documents =====

Most text and image contents in a questionnaire are formatted as text elements with HTML and directly embedded. However, longer documents (such as multiple-page instructions) may need to be linked as a downloadable file.  A widely-used file format is PDF.

PDF files can be created with Adobe Acrobat (if purchased) or with the freeware [[http://www.openoffice.org/de/|OpenOffice Writer]] or [[http://freepdfxp.de/|FreePDF]]. 

Once a file is uploaded to the host server, it can be linked for download with the HTML tag ''<a>''. Often (not always!) browsers will open PDF files in a new window rather than downloading them. The addition of ''target'' ensures that this occurs in a new browser window or tab.

<code html>
<a href="document.pdf" target="_blank">Download file</a>
</code>

**Note:** Whether the PDF file is opened in the browser or downloaded depends on the browser, or rather, the participant’s settings, and can’t be controlled by the researcher.


===== Incorporating audio files =====

There are several file formats that are good for use online, particularly RealMedia (RMA) and Windows Media (WMA). However, both formats exclude a relevant proportion of participants. In contrast, virtually all internet users can now play Flash files. The open-source software [[http://emff.sourceforge.net/|EMFF]] is Flash-based and can play mp3 files. EMFF is a standard plug-in on the www.soscisurvey.de server.

**Note:** The solutions below will play the audio file on one specific questionnaire page. When clicking to the next page, it stops. If you need to bypass this restriction, please read [[:en:create:frameset]].


==== Simple embedding of an mp3 ====

If an audio file is saved in mp3 format and uploaded to the host server, it can simply be dragged into the questionnaire like a text element (**Compose Questionnaire**). With the display settings {{:button.settings.png?nolink|Einstellungen}}, the user can determine how the EMFF Player should appear.

**Note:** SoSci Survey embeds audio files with a flash-based EMFF player. While this solution also works for outdated browsers, flash is not supported in iOS (iPhones/iPads). Further, Firefox now blocks flash content as a default, and requires for explicit content activation by clicking, even if autoplay is activated. We thus recommend audio file embedding using HTML5.


====Embedding of an mp3 using HTML5====

Since the HTML5 tag ''<audio>'' has become quite common now, it is well suited for embedding audio files. Only very outdated browsers (e.g. Internet Explorer older than version 9) do not support this tag.

In order to make sure the audio file is played in all contemporary browsers, it should be present in mp3 __and__ ogg format. However, mp3 alone already provides a decent coverage. There is a number of free tools available for conversion into compressed file formats, such as the Open Source Audio Editor [[http://sourceforge.net/projects/audacity/|Audacity]].

To embed a file, create a new [[en:create:texts|Text element]] in **Text Elements and Labels** with //Formatting// “HTML code”, and add the following content:

<code html>
<audio id="audio_with_controls" preload="auto" controls autoplay>
  <source src="audio.mp3" type="audio/mpeg" />
  <source src="audio.ogg" type="audio/ogg" />
  Your browser is not able to play this audio file 
</audio>
</code>

The file name(s) are entered in the ''<source>'' tags, while the options ''controls'' and ''autoplay'' enable controls and automatic playback. For more options, see [[http://www.w3schools.com/html/html5_audio.asp|w3schools: Audio]].

CSS formatting can be used to either adjust player size or to hide the player entirely. Please keep in mind that some browsers might ignore the autoplay setting, e.g. on mobile devices with limited data usage).

<code html>
<audio id="audio_with_controls" controls style="width: 200px; height: 80px">
  <source src="audio.mp3" type="audio/mpeg" />
</audio>
</code>

<code html>
<audio id="audio_with_controls" controls style="position: absolute; left: -9999px; top: -9999px">
  <source src="audio.mp3" type="audio/mpeg" />
</audio>
</code>

**Note:** Due to technical limitations, as of this time it is not (!) possible to use the audio file embed code directly in an “HTML code” element from the **Compose Questionnaire** step. As described above, a text element containing the code must be created first, which can then be added in the **Compose Questionnaire** step.


====Embedding of an mp3 using Flash====

If additional functions are needed (such as playing the file automatically) or the file must be interchangeable (e.g. as a randomised stimulus), the [[http://emff.sourceforge.net/codegenerator/|EMFF code generator]] can be used to generate the appropriate HTML code to embed the file into the questionnaire. Subsequently, the path to the EMFF player must be adjusted twice (!) (''../plugins/emff/'', see code example below) and the HTML code must be saved as a text element (Text Elements and Labelling) and dragged into the questionnaire (**Compose Questionnaire**).

<code html>
<object type="application/x-shockwave-flash" data="../plugins/emff/emff_standard.swf" width="110" height="34">
  <param name="movie" value="../plugins/emff/emff_standard.swf">
  <param name="FlashVars" value="src=audiofile.mp3&amp;autostart=yes">
</object>
</code>

**Note:** If EMFF is not present on a host server, the necessary flash files (SWF) can be downloaded from the EMFF homepage and uploaded to the user's project.


===== Embedding videos =====

**Important:** Those who have not looked into copyright laws often think public and free-access videos (such as those on YouTube) may be used in questionnaires without further consideration. This is __incorrect__. Copyright laws apply to such videos as well! 

==== The special case of YouTube videos ====

Users who upload videos to YouTube (and similar platforms) transfer a whole series of usage rights to the platform. This can be very useful in survey studies because YouTube offers the possibility of embedding videos directly into external websites (such as your online questionnaire). 

To do this, open the video on YouTube, click on the //Share// button, then //Embed//: Copy the HTML code into a text element (**Text Elements and Labels**) and drag it into the questionnaire (**Compose Questionnaire**). If necessary, replace ''%%http://%%'' by ''%%https://%%'' in the HTML code.

<code html>
<iframe width="420" height="315" src="https://www.youtube.com/embed/WtR2m20C2YM" frameborder="0" allowfullscreen></iframe>
</code>

With this HTML code, a (mostly invisible) YouTube website is opened within the questionnaire and the YouTube player is loaded. The user does not have to upload the file, nor deal with copyright laws. In exchange, YouTube is permitted to blend their own advertisements into the video.

**Warning:** The advertising spots shown previously to the video by youtube will vary for every respondent. Therefore, directly embedding the YouTube video may cause severe methodological trouble. The only solution to this case is to get the (written) consent of the copyright owner, to upload the video to the survey project, and to embed this file.

**Note:** Browser will access www.soscisurvey.de via secured (encrypted) HTTPS protocol. Some browsers deny including content from non-encrypted sources via iframe. When including external content, make sure, this content is available via HTTPS. Also use the HTTPS URL.


====Embedding videos using HTML5====

If you want to make sure your video can be displayed correctly for virtually all participants, you can embed it in your questionnaire using the HTML5 ''<video>'' tag. A disadvantage is that you first need to convert the video into 3 (!) different formats, and consequently also need to upload three files. Basically, you can also use just one of the file formats, but this way the video will only play in some browsers ([[http://www.hongkiat.com/blog/html5-videos-things-you-need-to-know/|HTML5 Videos: 10 Things Designers Need to Know]]).

**Important:** Very outdated versions of Internet Explorer (up to version 8) do not support the ''<video>'' tag. E.g. for Germany, this would affect about 3% of internet users ([[http://caniuse.com/#feat=video|Can I use: Video element]]).

To convert your video file into the file formats mp4, ogg, and webm, you can use a number of tools. It can be done quite conveniently using [[https://cloudconvert.com/|CloudConvert]] (online), and the
[[http://www.videolan.org/vlc/|VLC Media Player]] (offline) can also be used for this purpose. To 
do so with VLC, do the following (instructions based on [[http://klaesimage.com/wordpress/?p=265|Using VLC Media Player to convert video]]):

  * Open VLC Media Player
  * Menu: Media -> Convert/Save
  * File -> File Selection -> Add -> Choose video file
  * Convert/Save
  * Settings -> Profile: “Video - H.264 + MP3 (MP4)”
  * Destination -> Destination File -> Browse -> choose folder and file name, using .mp4 extension (e.g. video.mp4)
  * Start

Possibly, the conversion parameters need to be adjusted to meet the needs of your project, e.g. concerning video bitrate. You can do so in the “Edit selected profile” dialog next to the profile selection.

This procedure is repeated using the profiles “Video - VP80 + Vorbis (WebM)” -> file extension “.webm”, and “Video - Theora + Vorbis (OGG)” -> file extension “.ogg”. Once the files have been encoded, open the new video files in order to check video and audio quality.

In SoSci Survey, you create a new [[:en:create:texts|Text element]] in **Text Elements and Labels** with //Formatting// “HTML code”, and add the following content:

<code html>
<video width="512" height="288" controls>
  <source src="filename.ogg" type="video/ogg" />
  <source src="filename.mp4" type="video/mp4" />
  <source src="filename.webm" type="video/webm" />
</video>
</code>

Obviously, you can use the ''width'' and ''height'' parameters to adjust the video’s display size. Additional options are available to enable autoplay or hide the player controls ([[http://wiki.selfhtml.org/wiki/HTML/Multimedia_und_Grafiken/Video|SelfHTML: HTML/Multimedia und Grafiken/video]] (German only)).

====Embedding videos using Flash====

While video embedding using Flash has been the means of choice until just a few years ago, this solution now faces two major challenges: first, it does not work on iPhone/iPad, and second, the browser’s flash plug-in is frequently deactivated due to security concerns. 

To convert your video into a flash video file, a helpful tool is the [[http://www.dvdvideosoft.com/products/dvd/Free-Video-to-Flash-Converter.htm|Free Video to Flash Converter]].
When installing this tool, the suggested toolbars can be deactivated/not installed, and the same applies to the included add-on software (e.g. TuneUp Utilities). The programme helps the user turn videos into Flash videos and to play them via the Internet: 

  - Start the application
  - //Add files//
    - Select the desired file (the programme supports many common file formats)
    - //Open//
  - //Format//
    - "FLV"
    - The pre-set “high quality” with 1 MBit/sec is a good starting point -- yet, the image size and/or bit-rate may need adjusting.
  - Many more options can be selected under Player, such as which buttons to show, etc.
  - The box next to //Show HTML sample file// should be checked.
  - //Convert// – this will take a while

The converter will save the Flash video (FLV) and the actual player to play the video (SWF file) in the target directory. In some cases a control file (XML) is included as well. The two or three output files should be uploaded to the survey project – an eventual HTML or CSS file in the target directory does not need to be uploaded. The video file size (FLV) may not exceed 64 MB on the www.soscisurvey.de server.

**Important:** In newer versions of the Free Video to Flash Converter, output may differ significantly from the results described in this manual. In this case, some adjustments need to be done (see the (German) support forum: [[http://forum.onlineforschung.org/viewtopic.php?p=25362#p25362|Support forum: Embedding flash video]]).

After converting the video, a browser window with the necessary HTML code will open (if this window is closed by the user, it can be re-opened from the HTML file saved to the target directory by the programme). The relevant code is under //Copy the code from the box below to your web page//, and the ''<noscript>'' line can be adjusted as necessary -– it is displayed when JavaScript is deactivated and the video can’t be shown (see example below).

This HTML code is best saved as a text element (**Text Elements and Labels**). For the text element's //Formatting//, select "HTML code". Finally, drag the text element into the questionnaire (**Compose Questionnaire**).

<code html>
<object id="Object2" type="application/x-shockwave-flash" data="player_flv_classic.swf" width="480" height="360">
  <noscript>You browser does not support Flash and/or JavaScript.</noscript>
  <param name="movie" value="player_flv_classic.swf" />
  <param name="wmode" value="opaque" />
  <param name="allowScriptAccess" value="sameDomain" />
  <param name="quality" value="high" />
  <param name="menu" value="true" />
  <param name="autoplay" value="false" />
  <param name="autoload" value="false" />
  <param name="FlashVars" value="configxml=FlickAnimation.xml" />
</object>
</code>

**Tip:** This Flash application, playing the FLV files, supports a lot of parameters: [[http://www.dvdvideosoft.com/guides/new-multi-flash-player-settings.htm|DVD Video Soft: Multi Flash Player Settings]]


===== Technical hurdles =====

Regardless of whether audio files or videos are embedded following the directions above or directly from an external provider (e.g. YouTube), it can never guarantee that the participant can actually see the media file.

All options listed above (including YouTube) only work if the participant has a halfway up-to-date Flash Player. Flash is the most common media plug-in for browsers, but a relevant proportion of participants (depending on target population, 5-20%) will not have it installed. In addition, some participants use a Flash-Blocker to hide moving advertisements on some websites.

The solution to this problem is relatively simple: embed a short test video/audio clip on the first page of the questionnaire. The participants can then be asked to test the display in advance. I fit does not work properly, they should ...

  * check if the speakers are turned on,
  * possibly install the up-to-date Flash Player (include a link to the download page) and/or
  * temporarily disable an Flash blocker.

**Tip:** Optionally, some information (such as a number) can be hidden in the media file by displaying or recording it. Only users who enter this information correctly into a text box can continue to the questionnaire (this is then checked via filter on the next page of the questionnaire).

Of course, a series of other problems can also prevent the display of media. This can start with the fact that the participant is using a hopelessly out-of-date browser (e.g. Internet Explorer 5) and extend well beyond difficulties playing the file (a frighteningly small proportion of internet users comprehends the term "play button"). It has to be accepted that under some circumstances, a portion of the participants in an online questionnaire simply cannot play the files. However, with the instructions above, this portion should be reduced to very few percent. 

Finally, most of the time, it is impossible to control whether the participant has actually watched/listened to the complete file. This would require a special play-software to transmit this information to SoSci Survey (which does not currently exist). For those who do not wish to code their own software, the following options should work: 

  * Ask the participant if he/she has watched/listened to the complete file,
  * check the time spent on each page during data analysis ([[:en:results:variables#dwell_times|Dwll Times]]) or
  * only display the Continue button after a short while ([[:en:create:timer-display|Timer: Display Next Button after Defined Time]]). If you allow a Back button, do not set this time interval too long.