Welcome, Guest
Username: Password: Remember me

TOPIC: Short Audio Clips for Surveys - Hosting/Streaming Advice

Short Audio Clips for Surveys - Hosting/Streaming Advice 1 year 4 months ago #94554

  • spessex
  • spessex's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 21
  • Karma: 0
Hi

I'm not sure if I'm in the right forum for this but I just wanted to know if anyone had any advice or experience with using audio clips in their surveys?

Questions include what is the best way to host the files? Should they be MP3? Can the files simply be placed on the server (Linux box) or does it require specialist streaming software? Are there simpler ways to embed audio into a survey like embedding YouTube videos using simple embedded code (and hence using their server resources)? Am I worrying too much or is this kind of thing straightforward?

For information imagine that a survey has a short 30 sec audio clip and the survey maybe hit by 1000 users. It's highly likely that the audio file maybe be called by up to 300 users in anyone time (depending on when they hit the server).

Thank you

Stephen
The administrator has disabled public write access.

Short Audio Clips for Surveys - Hosting/Streaming Advice 1 year 4 months ago #94560

  • spessex
  • spessex's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 21
  • Karma: 0
Additionally please note someone from the Drupal community has mentioned that jPlayer might be a good way to go. Has anyone any experience of integrating jPlayer into the latest LS? Does anyone have any easy integration instructions?
The administrator has disabled public write access.

Short Audio Clips for Surveys - Hosting/Streaming Advice 1 year 4 months ago #94628

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4141
  • Thank you received: 768
  • Karma: 349
As it happens, I have integrated jPlayer into LimeSurvey.

Create a new "audio" directory in your template directory and upload your audio files there. (these can be placed elsewhere but the code below would need to be modified)

Download the jPlayer plugin and add these to your template:
- Jplayer.swf
- jquery.jplayer.min.js
- The "skin" folder

Add this to startpage.pstpl after {TEMPLATEJS}
	<!-- jPlayer files -->
	<link href="{TEMPLATEURL}skin/blue.monday/jplayer.blue.monday.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="{TEMPLATEURL}jquery.jplayer.min.js"></script>

Add this code to your template.js file:
$(document).ready(function(){
 
	if($('.audioSource').length > 0) {
 
		// Define some vars
		var surveyRoot = location.pathname.split('index.php')[0];
		var templateName = $('head link[href*="template.css"]').attr('href').replace(/\/template.css/, '').split('/templates/')[1];
		var fieldNames = $('input#fieldnames').attr('value');
		var tmp = fieldNames.split('X');
		var sID = tmp[0];
		var gID = tmp[1];
 
		// Add some classes
		$('.audioSource').closest('div.question-wrapper').addClass('audioQuestion');
 
		// Loop through all player source inclusions
		$('.audioSource').each(function(i) {
 
			// The source filename
			var audioSource = $(this).text().replace(/[\s\n\t]/g,'');
 
			//Insert a wrapper for the player object
			$(this).after('<div id="player'+i+'" class="playerWrapper" />');
 
			// Insert the player user interface
			var parentClass = '';
			if($(this).closest('tr[id^="javatbd"]').length > 0) {
				parentClass = 'subQuestion';
			}
			else if($(this).closest('div.question-wrapper').length > 0) {
				parentClass = 'question';
			}
			else {
				parentClass = 'groupDescription';
			}
			var playerController = '<div id="jp_container_'+i+'" class="jp-audio '+parentClass+'"> \
									<div class="jp-type-single"> \
										<div class="jp-gui jp-gui_'+i+' jp-interface"> \
											<ul class="jp-controls"> \
												<li><a href="javascript:;" class="jp-play jp-play_'+i+'" tabindex="1">play</a></li> \
												<li><a href="javascript:;" class="jp-pause jp-pause_'+i+'" tabindex="1">pause</a></li> \
												<li><a href="javascript:;" class="jp-stop jp-stop_'+i+'" tabindex="1">stop</a></li> \
												<li><a href="javascript:;" class="jp-mute jp-mute_'+i+'" tabindex="1" title="mute">mute</a></li> \
												<li><a href="javascript:;" class="jp-unmute jp-unmute_'+i+'" tabindex="1" title="unmute">unmute</a></li> \
												<li><a href="javascript:;" class="jp-volume-max jp-volume-max_'+i+'" tabindex="1" title="max volume">max volume</a></li> \
											</ul> \
											<div class="jp-progress"> \
												<div class="jp-seek-bar jp-seek-bar_'+i+'"> \
													<div class="jp-play-bar jp-play-bar_'+i+'"></div> \
												</div> \
											</div> \
											<div class="jp-volume-bar jp-volume-bar_'+i+'"> \
												<div class="jp-volume-bar-value jp-volume-bar-value_'+i+'"></div> \
											</div> \
											<div class="jp-time-holder"> \
												<div class="jp-current-time jp-current-time_'+i+'"></div> \
												<div class="jp-duration jp-duration_'+i+'"></div> \
												<ul class="jp-toggles"> \
													<li><a href="javascript:;"class="jp-repeat jp-repeat_'+i+'" tabindex="1" title="repeat">Repeat</a></li> \
													<li><a href="javascript:;"class="jp-repeat-off jp-repeat-off_'+i+'" tabindex="1" title="repeat off">Repeat off</a></li> \
												</ul> \
											</div> \
										</div> \
									</div> \
								</div>'
 
			if(parentClass == 'question' || parentClass == 'subQuestion') {
				$(this).parent().prepend(playerController);
			}
			else {
				$(this).parent().append(playerController);
			}
 
			 // Construct the player object
			 $('#player'+i).jPlayer( {
				swfPath: surveyRoot+'upload/templates/'+templateName,
				solution: 'html, flash',
				supplied: 'mp3',
				preload: 'metadata',
				volume: 0.1,
				muted: false,
				backgroundColor: '#000000',
				cssSelectorAncestor: '#jp_container_'+i+'',
				cssSelector: {
					play: '.jp-play_'+i+'',
					pause: '.jp-pause_'+i+'',
					stop: '.jp-stop_'+i+'',
					seekBar: '.jp-seek-bar_'+i+'',
					playBar: '.jp-play-bar_'+i+'',
					mute: '.jp-mute_'+i+'',
					unmute: '.jp-unmute_'+i+'',
					volumeBar: '.jp-volume-bar_'+i+'',
					volumeBarValue: '.jp-volume-bar-value_'+i+'',
					volumeMax: '.jp-volume-max_'+i+'',
					currentTime: '.jp-current-time_'+i+'',
					duration: '.jp-duration_'+i+'',
					repeat: '.jp-repeat_'+i+'',
					repeatOff: '.jp-repeat-off_'+i+'',
					gui: '.jp-gui_'+i+''
				},
				ready: function () {
					$(this).jPlayer("setMedia", {
						mp3: surveyRoot+'upload/templates/'+templateName+'/audio/'+audioSource
					});
				},
				play: function () {
					// Pause all other players
					$(this).jPlayer('pauseOthers');
				},
				errorAlerts: false,
				warningAlerts: false
 
			});
 
		});
 
	}
});

Add this to the end of template.css:
/******** Audio player styles (additional styles in the skin folder) ********/
 
span.group-description {
	display: inline-block;
	padding: 5px;
}
 
.audioSource,
.answeredCodes {
	display: none;
}
 
.jp-audio {
	text-align: center;
}

In the group description or question source where you want a player to appear, add something like this where "question_1.mp3" is the desired audio filename. These <div> elements will be hidden by CSS and automatically detected by JavaScript which will insert the player.
<div class="audioSource">question_1.mp3</div>


Here's a working LimeSurvey 2.0 template and survey:

File Attachment:

File Name: Demo_jPlayer_Integration.zip
File Size: 319 KB

File Attachment:

File Name: limesurvey_survey_447759.lss
File Size: 14 KB
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 1 month ago by tpartner.
The administrator has disabled public write access.

Short Audio Clips for Surveys - Hosting/Streaming Advice 1 year 4 months ago #94629

  • spessex
  • spessex's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 21
  • Karma: 0
That's fantastic. Thank you Tony. Much appreciated.

PS Do you happen to know how effective jPlayer is? Basically I'm just trying to ascertain the best media player solution to ensure most devices and browsers will play the media (and I'm hoping jPlayer is the correct choice).
The administrator has disabled public write access.

Short Audio Clips for Surveys - Hosting/Streaming Advice 1 year 4 months ago #94631

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4141
  • Thank you received: 768
  • Karma: 349
For that project, we tested on just about everything except iPad. We tested IE7-10, Firefox, Chrome, Win and Linux.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 4 months ago by c_schmitz.
The administrator has disabled public write access.

Short Audio Clips for Surveys - Hosting/Streaming Advice 1 year 4 months ago #94763

  • spessex
  • spessex's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 21
  • Karma: 0
Hi Tony

I've been comparing your instructions against those in the jPlayer Quick Start Guide and was hoping you might be able to clarify a few things as I'm getting a little confused.

Re: 'Add this code to your template.js file:' is this your own created code only I can't find reference to this in the jPlayer quick start guide? (www.jplayer.org/latest/quick-start-guide/step-1/)

Additionally where jPlayer quick start also integrates the video player can you advise where I should actually add the code in LS described in www.jplayer.org/latest/quick-start-guide/step-6-video/ and the code described in www.jplayer.org/latest/quick-start-guide/step-7-video/ ?

Thanks in advance.
The administrator has disabled public write access.

Short Audio Clips for Surveys - Hosting/Streaming Advice 1 year 3 months ago #96620

  • StuTheQ
  • StuTheQ's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 26
  • Karma: 0
Dear Tony,

I'm now trying to do the jPlayer integration but I'm already (surprise, surprise... :whistle: ) a tad lost.

Could you walk me through the following, please?

I've set up a simple test survey with a single 'List (radio)' question (template = copy_of_basic)
Create a new "audio" directory in your template directory and upload your audio files there.
1. How exactly do I "Create a new "audio" directory in [my] template directory" ?
2. Once it's created, is it then just a question of browsing through my audio files and uploading the one(s) that I want?
Download the jPlayer plugin and add these to your template:
- Jplayer.swf
- jquery.jplayer.min.js
- The "skin" folder
3. Sorry, which template? (and by this I suppose you mean the 'Question page', 'Load page', 'template.js', 'template.css' etc. of the current template ('copy_of_default', 'copy_of basic' etc.) ?)
4. All in the same place ('template.js', for example?) and without adding new/modifying existing code (curly braces etc.) (sorry about this embarrassing lack of JavaScript/HTML/CSS programming skills...)
Add this to startpage.pstpl after {TEMPLATEJS}
5. Does it matter which page? ('Welcome page', 'Question page', 'Load page' etc.)
6. Before, after or instead of the line of code:
<link rel="shortcut icon" href="{TEMPLATEURL}favicon.ico" />
(I think this is HTML code?)
Add this code to your template.js file:
7. Does it matter which page? (as above)
8. Anywhere in the 'template.js' file?
Add this to the end of template.css:
9. Does it matter which page? (as above)

Once again, sorry if the answers to these questions are standard knowledge... :blush:

I imported and ran the sample survey that you posted (limesurvey_survey_447759.lss) but the jPlayer console didn't appear (hidden?) and I didn't hear anything... (deaf as well as hopeless in coding?) :(

Finally (!!), Mr Spessex's questions in his post #94763 look ominous regarding my next steps in the jPlayer integration process... would answers to them be necessary for me to?

Just when you thought you were going to get a quiet weekend! ;)

Thank you - as always! :) - for any help that you might be able to give me.

Regards,

Stu
The administrator has disabled public write access.

Short Audio Clips for Surveys - Hosting/Streaming Advice 1 year 3 months ago #96638

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4141
  • Thank you received: 768
  • Karma: 349
Hi Stu,

I should start by pointing out that you probably won't be able to implement this workaround with the template editor alone. You will need FTP access to the /upload/templates directory of your server.

1. How exactly do I "Create a new "audio" directory in [my] template directory" ?
Do this with your FTP client (like FileZilla)

2. Once it's created, is it then just a question of browsing through my audio files and uploading the one(s) that I want?
Upload these files with the FTP client - most are drag-and-drop.

3. Sorry, which template?
Again, upload these files with the FTP client. So, if your template is "copy_of_basic", they would go in /uploads/templates/copy_of_basic/.

4. All in the same place
You will just upload those complete files and the folder. not modify any existing files at this point.

5. Does it matter which page?
Nope, doesn't matter, all of those views access the same startpge.pstpl file.

6. Before, after or instead of the line of code:
After {TEMPLATEJS}, so it should look like this:
Capture3_2013-06-02.JPG


7. Does it matter which page?
Same answer as above, there is only one template.js file in your template.

8. Anywhere in the 'template.js' file?
At the end.

9. Does it matter which page?
Same answer as above, there is only one template.css file in your template.

I imported and ran the sample survey that you posted...
Did you import the attached template first and then assign it to that survey?

Finally (!!), Mr Spessex's questions in his post #94763 look ominous...
If you follow my steps, I don't think you need to worry about that.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 3 months ago by tpartner.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.167 seconds
Donation Image