Follow these steps to integrate jPlayer into LimeSurvey 2.5.x.
1) Copy and rename a template
2) Download jPlayer - jplayer.org/
3) Copy the downloaded jPlayer-2.9.x folder to the /scripts folder of the new template
4) Modify the config.xml file in the new template to include jquery.jplayer.js and the skin CSS file:
In the <js> block:
In the <css> block:
5) Add the following HTML to the source of a text-display question (this is the player and control elements):
6) Add the following script to the source of that text-display question (this initiates the player):
7) Add this to the end of template.css - it will render the player responsive
1) Copy and rename a template
2) Download jPlayer - jplayer.org/
3) Copy the downloaded jPlayer-2.9.x folder to the /scripts folder of the new template
4) Modify the config.xml file in the new template to include jquery.jplayer.js and the skin CSS file:
In the <js> block:
In the <css> block:
5) Add the following HTML to the source of a text-display question (this is the player and control elements):
<div id="jp_container_{QID}" class="jp-video " role="application" aria-label="media player">
<div class="jp-type-single">
<div id="jquery_jplayer_{QID}" class="jp-jplayer"></div>
<div class="jp-gui">
<div class="jp-video-play">
<button class="jp-video-play-icon" role="button" tabindex="0">play</button>
</div>
<div class="jp-interface">
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-current-time" role="timer" aria-label="time"> </div>
<div class="jp-duration" role="timer" aria-label="duration"> </div>
<div class="jp-details">
<div class="jp-title" aria-label="title"> </div>
</div>
<div class="jp-controls-holder">
<div class="jp-volume-controls">
<button class="jp-mute" role="button" tabindex="0">mute</button>
<button class="jp-volume-max" role="button" tabindex="0">max volume</button>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
<div style="clear:both"></div>
</div>
<div class="jp-controls">
<button class="jp-play" role="button" tabindex="0">play</button>
<button class="jp-stop" role="button" tabindex="0">stop</button>
<div style="clear:both"></div>
</div>
<div class="jp-toggles">
<button class="jp-repeat" role="button" tabindex="0">repeat</button>
<button class="jp-full-screen" role="button" tabindex="0">full screen</button>
<div style="clear:both"></div>
</div>
</div>
</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
</div>
</div>
</div>
6) Add the following script to the source of that text-display question (this initiates the player):
<script type="text/javascript">
$(document).ready(function(){
var thisQuestion = $('#question{QID}');
function resizePlayer() {
var playerWidth = $('#jquery_jplayer_{QID}').width();
var aspectRatio = {
'width': 16,
'height': 9
};
var playerHeight = (playerWidth*aspectRatio.height)/aspectRatio.width;
$('#jquery_jplayer_{QID}').css('height', playerHeight+'px');
$('#jquery_jplayer_{QID} img').css('height', playerHeight+'px');
$('#jp_container_{QID} .jp-video-play').css({
'height': playerHeight+'px',
'margin-top': '-'+playerHeight+'px'
});
}
$(window).resize(function() {
resizePlayer();
});
$('#jquery_jplayer_{QID}').jPlayer({
ready: function () {
resizePlayer();
$(this).jPlayer("setMedia", {
title: "Big Buck Bunny Trailer",
m4v: "http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v",
ogv: "http://www.jplayer.org/video/ogv/Big_Buck_Bunny_Trailer.ogv",
poster: "http://www.jplayer.org/video/poster/Big_Buck_Bunny_Trailer_480x270.png"
});
},
cssSelectorAncestor: "#jp_container_{QID}",
swfPath: "{TEMPLATEURL}scripts/jPlayer-2.9.2/dist/jplayer",
supplied: "m4v, ogv",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true,
size: {
'width': '100%',
'height': 'auto',
'cssClass': 'jp-video-ls' // Custom class for LimeSurvey
}
});
});
</script>
7) Add this to the end of template.css - it will render the player responsive
/*** jPlayer Styles & Overrides ***/
.jp-video,
.jp-video div {
box-sizing: content-box;
}
.jp-video {
width: 100%;
max-width: 640px;
margin: 0 auto;
}
.jp-video .jp-video-play {
height: 360px;
margin-top: -360px;
}
@media only screen and (max-width: 700px) {
.jp-video {
max-width: 400px;
}
}
@media only screen and (max-width: 480px) {
.container,
.questiontext {
padding-left: 0;
padding-right: 0;
}
#main-col {
padding-left: 3px;
padding-right: 3px;
}
.jp-video .jp-interface .jp-controls-holder {
width: 340px;
}
.jp-video .jp-interface .jp-controls-holder > div {
}
.jp-video .jp-interface .jp-volume-controls {
display: none !important;
}
.jp-video .jp-interface .jp-controls {
display: block !important;
float: none !important;
margin: 0 auto !important;;
}
.jp-video .jp-interface .jp-toggles {
display: block !important;
float: none !important;
position: relative;
margin: 10px auto 0 auto !important;;
}
.jp-video .jp-interface .jp-toggles .jp-full-screen {
float: right;
}
}